仓库初始化
This commit is contained in:
847
public/assets/js/backend/addon.js
Normal file
847
public/assets/js/backend/addon.js
Normal file
@@ -0,0 +1,847 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'], function ($, undefined, Backend, Table, Form, Template, undefined) {
|
||||
$.cookie.prototype.defaults = {path: Config.moduleurl};
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: Config.api_url ? Config.api_url + '/addon/index' : "addon/downloaded",
|
||||
add_url: '',
|
||||
edit_url: '',
|
||||
del_url: '',
|
||||
multi_url: ''
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 弹窗自适应宽高
|
||||
var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
|
||||
|
||||
var switch_local = function () {
|
||||
if ($(".btn-switch.active").data("type") != "local") {
|
||||
Layer.confirm(__('Store not available tips'), {
|
||||
title: __('Warmtips'),
|
||||
btn: [__('Switch to the local'), __('Try to reload')]
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
$(".panel .nav-tabs").hide();
|
||||
$(".toolbar > *:not(:first)").hide();
|
||||
$(".btn-switch[data-type='local']").trigger("click");
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
table.bootstrapTable('refresh');
|
||||
});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
table.on('load-success.bs.table', function (e, json) {
|
||||
if (json && typeof json.category != 'undefined' && $(".nav-category li").length == 2) {
|
||||
$.each(json.category, function (i, j) {
|
||||
$("<li><a href='javascript:;' data-id='" + j.id + "'>" + j.name + "</a></li>").insertBefore($(".nav-category li:last"));
|
||||
});
|
||||
}
|
||||
if (typeof json.rows === 'undefined' && typeof json.code != 'undefined') {
|
||||
switch_local();
|
||||
}
|
||||
});
|
||||
table.on('load-error.bs.table', function (e, status, res) {
|
||||
console.log(e, status, res);
|
||||
switch_local();
|
||||
});
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
var parenttable = table.closest('.bootstrap-table');
|
||||
var d = $(".fixed-table-toolbar", parenttable).find(".search input");
|
||||
d.off("keyup drop blur");
|
||||
d.on("keyup", function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
var that = this;
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var queryParams = options.queryParams;
|
||||
options.pageNumber = 1;
|
||||
options.queryParams = function (params) {
|
||||
var params = queryParams(params);
|
||||
params.search = $(that).val();
|
||||
return params;
|
||||
};
|
||||
table.bootstrapTable('refresh', {});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.helper("Moment", Moment);
|
||||
Template.helper("addons", Config['addons']);
|
||||
|
||||
$("#faupload-addon").data("params", function (files, xhr) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
return {
|
||||
uid: userinfo ? userinfo.id : '',
|
||||
token: userinfo ? userinfo.token : '',
|
||||
version: Config.faversion,
|
||||
force: (files[0].force || false) ? 1 : 0
|
||||
};
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pageSize: 50,
|
||||
queryParams: function (params) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
$.extend(params, {
|
||||
uid: userinfo ? userinfo.id : '',
|
||||
token: userinfo ? userinfo.token : '',
|
||||
domain: Config.domain,
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
});
|
||||
return params;
|
||||
},
|
||||
columns: [
|
||||
[
|
||||
{field: 'id', title: 'ID', operate: false, visible: false},
|
||||
{
|
||||
field: 'home',
|
||||
title: __('Index'),
|
||||
width: '50px',
|
||||
formatter: Controller.api.formatter.home
|
||||
},
|
||||
{field: 'name', title: __('Name'), operate: false, visible: false, width: '120px'},
|
||||
{
|
||||
field: 'title',
|
||||
title: __('Title'),
|
||||
operate: 'LIKE',
|
||||
align: 'left',
|
||||
formatter: Controller.api.formatter.title
|
||||
},
|
||||
{
|
||||
field: 'intro',
|
||||
title: __('Intro'),
|
||||
operate: 'LIKE',
|
||||
align: 'left',
|
||||
class: 'visible-lg',
|
||||
formatter: Controller.api.formatter.intro
|
||||
},
|
||||
{
|
||||
field: 'author',
|
||||
title: __('Author'),
|
||||
operate: 'LIKE',
|
||||
width: '100px',
|
||||
formatter: Controller.api.formatter.author
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
title: __('Price'),
|
||||
operate: 'LIKE',
|
||||
width: '100px',
|
||||
align: 'center',
|
||||
formatter: Controller.api.formatter.price
|
||||
},
|
||||
{
|
||||
field: 'downloads',
|
||||
title: __('Downloads'),
|
||||
operate: 'LIKE',
|
||||
width: '80px',
|
||||
align: 'center',
|
||||
formatter: Controller.api.formatter.downloads
|
||||
},
|
||||
{
|
||||
field: 'version',
|
||||
title: __('Version'),
|
||||
operate: 'LIKE',
|
||||
width: '80px',
|
||||
align: 'center',
|
||||
formatter: Controller.api.formatter.version
|
||||
},
|
||||
{
|
||||
field: 'toggle',
|
||||
title: __('Status'),
|
||||
width: '80px',
|
||||
formatter: Controller.api.formatter.toggle
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
formatter: Controller.api.formatter.operate,
|
||||
align: 'right',
|
||||
cellStyle: function (value, row, index) {
|
||||
return {css: {'min-width': '158px'}};
|
||||
}
|
||||
},
|
||||
]
|
||||
],
|
||||
responseHandler: function (res) {
|
||||
$.each(res.rows, function (i, j) {
|
||||
j.addon = typeof Config.addons[j.name] != 'undefined' ? Config.addons[j.name] : null;
|
||||
});
|
||||
return res;
|
||||
},
|
||||
dataType: 'jsonp',
|
||||
templateView: false,
|
||||
clickToSelect: false,
|
||||
search: true,
|
||||
showColumns: false,
|
||||
showToggle: false,
|
||||
showExport: false,
|
||||
showSearch: false,
|
||||
commonSearch: true,
|
||||
searchFormVisible: true,
|
||||
searchFormTemplate: 'searchformtpl',
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
// 离线安装
|
||||
require(['upload'], function (Upload) {
|
||||
Upload.api.upload("#faupload-addon", function (data, ret, up, file) {
|
||||
Config['addons'][data.addon.name] = data.addon;
|
||||
var addon = data.addon;
|
||||
var testdata = data.addon.testdata;
|
||||
operate(data.addon.name, 'enable', false, function (data, ret) {
|
||||
Layer.alert(__('Offline installed tips') + (testdata ? __('Testdata tips') : ""), {
|
||||
btn: testdata ? [__('Import testdata'), __('Skip testdata')] : [__('OK')],
|
||||
title: __('Warning'),
|
||||
yes: function (index) {
|
||||
if (testdata) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/testdata',
|
||||
data: {
|
||||
name: addon.name,
|
||||
version: addon.version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
Layer.close(index);
|
||||
}
|
||||
},
|
||||
icon: 1
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}, function (data, ret, up, file) {
|
||||
if (ret.msg && ret.msg.match(/(login|登录)/g)) {
|
||||
return Layer.alert(ret.msg, {
|
||||
title: __('Warning'),
|
||||
btn: [__('Login now')],
|
||||
yes: function (index, layero) {
|
||||
$(".btn-userinfo").trigger("click");
|
||||
}
|
||||
});
|
||||
} else if (ret.code === -1) {
|
||||
Layer.confirm(__('Upgrade tips', data.title), {title: __('Warmtips')}, function (index, layero) {
|
||||
up.removeFile(file);
|
||||
file.force = true;
|
||||
up.uploadFile(file);
|
||||
Layer.close(index);
|
||||
});
|
||||
return false;
|
||||
} else if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue install'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function (index) {
|
||||
up.removeFile(file);
|
||||
file.force = true;
|
||||
up.uploadFile(file);
|
||||
Layer.close(index);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
});
|
||||
|
||||
// 检测是否登录
|
||||
$(document).on("mousedown", "#faupload-addon", function (e) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
var uploadBtn = Upload.list['faupload-addon'];
|
||||
|
||||
if (parseInt(uid) === 0) {
|
||||
uploadBtn.disable();
|
||||
$(".btn-userinfo").trigger("click");
|
||||
return false;
|
||||
} else {
|
||||
if (uploadBtn.disabled) {
|
||||
uploadBtn.enable();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 查看插件首页
|
||||
$(document).on("click", ".btn-addonindex", function () {
|
||||
if ($(this).attr("href") == 'javascript:;') {
|
||||
Layer.msg(__('Not installed tips'), {icon: 7});
|
||||
} else if ($(this).closest(".operate").find("a.btn-enable").length > 0) {
|
||||
Layer.msg(__('Not enabled tips'), {icon: 7});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// 切换
|
||||
$(document).on("click", ".btn-switch", function () {
|
||||
$(".btn-switch").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$("form.form-commonsearch input[name='type']").val($(this).data("type"));
|
||||
var method = $(this).data("type") == 'local' ? 'hideColumn' : 'showColumn';
|
||||
table.bootstrapTable(method, 'price');
|
||||
table.bootstrapTable(method, 'downloads');
|
||||
table.bootstrapTable('refresh', {url: ($(this).data("url") ? $(this).data("url") : $.fn.bootstrapTable.defaults.extend.index_url), pageNumber: 1});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 切换分类
|
||||
$(document).on("click", ".nav-category li a", function () {
|
||||
$(".nav-category li").removeClass("active");
|
||||
$(this).parent().addClass("active");
|
||||
$("form.form-commonsearch input[name='category_id']").val($(this).data("id"));
|
||||
table.bootstrapTable('refresh', {url: $(this).data("url"), pageNumber: 1});
|
||||
return false;
|
||||
});
|
||||
var tables = [];
|
||||
$(document).on("click", "#droptables", function () {
|
||||
if ($(this).prop("checked")) {
|
||||
Fast.api.ajax({
|
||||
url: "addon/get_table_list",
|
||||
async: false,
|
||||
data: {name: $(this).data("name")}
|
||||
}, function (data) {
|
||||
tables = data.tables;
|
||||
return false;
|
||||
});
|
||||
var html;
|
||||
html = tables.length > 0 ? '<div class="alert alert-warning-light droptablestips" style="max-width:480px;max-height:300px;overflow-y: auto;">' + __('The following data tables will be deleted') + ':<br>' + tables.join("<br>") + '</div>'
|
||||
: '<div class="alert alert-warning-light droptablestips">' + __('The Addon did not create a data table') + '</div>';
|
||||
$(html).insertAfter($(this).closest("p"));
|
||||
} else {
|
||||
$(".droptablestips").remove();
|
||||
}
|
||||
$(window).resize();
|
||||
});
|
||||
|
||||
// 会员信息
|
||||
$(document).on("click", ".btn-userinfo", function (e, name, version) {
|
||||
var that = this;
|
||||
var area = [$(window).width() > 800 ? '500px' : '95%', $(window).height() > 600 ? '400px' : '95%'];
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
if (!userinfo) {
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/logintpl',
|
||||
type: 'post',
|
||||
loading: false,
|
||||
data: {
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
}
|
||||
}, function (tpldata, ret) {
|
||||
Layer.open({
|
||||
content: Template.render(tpldata, {}),
|
||||
zIndex: 99,
|
||||
area: area,
|
||||
title: __('Login'),
|
||||
resize: false,
|
||||
btn: [__('Login')],
|
||||
yes: function (index, layero) {
|
||||
var data = $("form", layero).serializeArray();
|
||||
data.push({name: "faversion", value: Config.faversion});
|
||||
data.push({name: "sid", value: Controller.api.sid()});
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/login',
|
||||
type: 'post',
|
||||
data: data
|
||||
}, function (data, ret) {
|
||||
Controller.api.userinfo.set(data);
|
||||
Layer.closeAll();
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 1});
|
||||
return false;
|
||||
}, function (data, ret) {
|
||||
});
|
||||
},
|
||||
success: function (layero, index) {
|
||||
this.checkEnterKey = function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
$(".layui-layer-btn0").trigger("click");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
$(document).on('keydown', this.checkEnterKey);
|
||||
},
|
||||
end: function () {
|
||||
$(document).off('keydown', this.checkEnterKey);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/userinfotpl',
|
||||
type: 'post',
|
||||
data: {
|
||||
uid: userinfo.id,
|
||||
token: userinfo.token,
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
}
|
||||
}, function (tpldata, ret) {
|
||||
Layer.open({
|
||||
content: Template.render(tpldata, userinfo),
|
||||
area: area,
|
||||
title: __('Userinfo'),
|
||||
resize: false,
|
||||
btn: [__('Logout'), __('Close')],
|
||||
yes: function () {
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/logout',
|
||||
data: {
|
||||
uid: userinfo.id,
|
||||
token: userinfo.token,
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Controller.api.userinfo.set(null);
|
||||
Layer.closeAll();
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}, function (data, ret) {
|
||||
Controller.api.userinfo.set(null);
|
||||
Layer.closeAll();
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}, function (data) {
|
||||
Controller.api.userinfo.set(null);
|
||||
$(that).trigger('click');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//刷新授权
|
||||
$(document).on("click", ".btn-authorization", function () {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
if (!userinfo) {
|
||||
$(".btn-userinfo").trigger("click");
|
||||
return false;
|
||||
}
|
||||
Layer.confirm(__('Are you sure you want to refresh authorization?'), {icon: 3, title: __('Warmtips')}, function () {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/authorization',
|
||||
data: {
|
||||
uid: userinfo.id,
|
||||
token: userinfo.token
|
||||
}
|
||||
}, function (data, ret) {
|
||||
$(".btn-refresh").trigger("click");
|
||||
Layer.closeAll();
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
var install = function (name, version, force) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
var token = userinfo ? userinfo.token : '';
|
||||
Fast.api.ajax({
|
||||
url: 'addon/install',
|
||||
data: {
|
||||
name: name,
|
||||
force: force ? 1 : 0,
|
||||
uid: uid,
|
||||
token: token,
|
||||
version: version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.closeAll();
|
||||
Config['addons'][data.addon.name] = ret.data.addon;
|
||||
operate(data.addon.name, 'enable', false, function () {
|
||||
Layer.alert(__('Online installed tips') + (data.addon.testdata ? __('Testdata tips') : ""), {
|
||||
btn: data.addon.testdata ? [__('Import testdata'), __('Skip testdata')] : [__('OK')],
|
||||
title: __('Warning'),
|
||||
yes: function (index) {
|
||||
if (data.addon.testdata) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/testdata',
|
||||
data: {
|
||||
name: name,
|
||||
uid: uid,
|
||||
token: token,
|
||||
version: version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
Layer.close(index);
|
||||
}
|
||||
},
|
||||
icon: 1
|
||||
});
|
||||
Controller.api.refresh(table, name);
|
||||
});
|
||||
}, function (data, ret) {
|
||||
var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 650 ? '650px' : '95%', $(window).height() > 710 ? '710px' : '95%'];
|
||||
if (ret && ret.code === -2) {
|
||||
//如果登录已经超时,重新提醒登录
|
||||
if (uid && uid != ret.data.uid) {
|
||||
Controller.api.userinfo.set(null);
|
||||
$(".operate[data-name='" + name + "'] .btn-install:first").trigger("click");
|
||||
return;
|
||||
}
|
||||
top.Fast.api.open(ret.data.payurl, __('Pay now'), {
|
||||
area: area,
|
||||
end: function () {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/isbuy',
|
||||
data: {
|
||||
name: name,
|
||||
force: force ? 1 : 0,
|
||||
uid: uid,
|
||||
token: token,
|
||||
version: version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function () {
|
||||
top.Layer.alert(__('Pay successful tips'), {
|
||||
btn: [__('Continue installation')],
|
||||
title: __('Warning'),
|
||||
icon: 1,
|
||||
yes: function (index) {
|
||||
top.Layer.close(index);
|
||||
install(name, version);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}, function () {
|
||||
console.log(__('Canceled'));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue install'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function () {
|
||||
install(name, version, true);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
var uninstall = function (name, force, droptables) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/uninstall',
|
||||
data: {name: name, force: force ? 1 : 0, droptables: droptables ? 1 : 0}
|
||||
}, function (data, ret) {
|
||||
delete Config['addons'][name];
|
||||
Layer.closeAll();
|
||||
Controller.api.refresh(table, name);
|
||||
}, function (data, ret) {
|
||||
if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue uninstall'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function () {
|
||||
uninstall(name, true, droptables);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
var operate = function (name, action, force, success) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/state',
|
||||
data: {name: name, action: action, force: force ? 1 : 0}
|
||||
}, function (data, ret) {
|
||||
var addon = Config['addons'][name];
|
||||
addon.state = action === 'enable' ? 1 : 0;
|
||||
Layer.closeAll();
|
||||
if (typeof success === 'function') {
|
||||
success(data, ret);
|
||||
}
|
||||
Controller.api.refresh(table, name);
|
||||
}, function (data, ret) {
|
||||
if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue operate'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function () {
|
||||
operate(name, action, true, success);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
var upgrade = function (name, version) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
var token = userinfo ? userinfo.token : '';
|
||||
Fast.api.ajax({
|
||||
url: 'addon/upgrade',
|
||||
data: {name: name, uid: uid, token: token, version: version, faversion: Config.faversion}
|
||||
}, function (data, ret) {
|
||||
Config['addons'][name] = data.addon;
|
||||
Layer.closeAll();
|
||||
Controller.api.refresh(table, name);
|
||||
}, function (data, ret) {
|
||||
Layer.alert(ret.msg, {title: __('Warning')});
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// 点击安装
|
||||
$(document).on("click", ".btn-install", function () {
|
||||
var that = this;
|
||||
var name = $(this).closest(".operate").data("name");
|
||||
var version = $(this).data("version");
|
||||
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
|
||||
if (parseInt(uid) === 0) {
|
||||
$(".btn-userinfo").trigger("click", name, version);
|
||||
return false;
|
||||
}
|
||||
install(name, version, false);
|
||||
});
|
||||
|
||||
// 点击卸载
|
||||
$(document).on("click", ".btn-uninstall", function () {
|
||||
var name = $(this).closest(".operate").data('name');
|
||||
if (Config['addons'][name].state == 1) {
|
||||
Layer.alert(__('Please disable the add before trying to uninstall'), {icon: 7});
|
||||
return false;
|
||||
}
|
||||
Template.helper("__", __);
|
||||
tables = [];
|
||||
Layer.confirm(Template("uninstalltpl", {addon: Config['addons'][name]}), {focusBtn: false, title: __("Warning")}, function (index, layero) {
|
||||
uninstall(name, false, $("input[name='droptables']", layero).prop("checked"));
|
||||
});
|
||||
});
|
||||
|
||||
// 点击配置
|
||||
$(document).on("click", ".btn-config", function () {
|
||||
var name = $(this).closest(".operate").data("name");
|
||||
Fast.api.open("addon/config?name=" + name, __('Setting'));
|
||||
});
|
||||
|
||||
// 点击启用/禁用
|
||||
$(document).on("click", ".btn-enable,.btn-disable", function () {
|
||||
var name = $(this).data("name");
|
||||
var action = $(this).data("action");
|
||||
operate(name, action, false);
|
||||
});
|
||||
|
||||
// 点击升级
|
||||
$(document).on("click", ".btn-upgrade", function () {
|
||||
var name = $(this).closest(".operate").data('name');
|
||||
if (Config['addons'][name].state == 1) {
|
||||
Layer.alert(__('Please disable the add before trying to upgrade'), {icon: 7});
|
||||
return false;
|
||||
}
|
||||
var version = $(this).data("version");
|
||||
|
||||
Layer.confirm(__('Upgrade tips', Config['addons'][name].title), {title: __('Warmtips')}, function (index, layero) {
|
||||
upgrade(name, version);
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".operate .btn-group .dropdown-toggle", function () {
|
||||
$(this).closest(".btn-group").toggleClass("dropup", $(document).height() - $(this).offset().top <= 200);
|
||||
});
|
||||
|
||||
$(document).on("click", ".view-screenshots", function () {
|
||||
var row = Table.api.getrowbyindex(table, parseInt($(this).data("index")));
|
||||
var data = [];
|
||||
$.each(row.screenshots, function (i, j) {
|
||||
data.push({
|
||||
"src": j
|
||||
});
|
||||
});
|
||||
var json = {
|
||||
"title": row.title,
|
||||
"data": data
|
||||
};
|
||||
top.Layer.photos(top.JSON.parse(JSON.stringify({photos: json})));
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
config: function () {
|
||||
$(document).on("click", ".nav-group li a[data-toggle='tab']", function () {
|
||||
if ($(this).attr("href") == "#all") {
|
||||
$(".tab-pane").addClass("active in");
|
||||
}
|
||||
return;
|
||||
var type = $(this).attr("href").substring(1);
|
||||
if (type == 'all') {
|
||||
$(".table-config tr").show();
|
||||
} else {
|
||||
$(".table-config tr").hide();
|
||||
$(".table-config tr[data-group='" + type + "']").show();
|
||||
}
|
||||
});
|
||||
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
if ($(".btn-switch.active").data("type") == "local") {
|
||||
// return value;
|
||||
}
|
||||
var title = '<a class="title" href="' + row.url + '" data-toggle="tooltip" title="' + __('View addon home page') + '" target="_blank"><span class="' + Fast.api.escape(row.color) + '">' + value + '</span></a>';
|
||||
if (row.screenshots && row.screenshots.length > 0) {
|
||||
title += ' <a href="javascript:;" data-index="' + index + '" class="view-screenshots text-success" title="' + __('View addon screenshots') + '" data-toggle="tooltip"><i class="fa fa-image"></i></a>';
|
||||
}
|
||||
return title;
|
||||
},
|
||||
intro: function (value, row, index) {
|
||||
return row.intro + (row.extend ? "<a href='" + Fast.api.escape(row.extend[1]) + "' class='" + Fast.api.escape(row.extend[2]) + "'>" + Fast.api.escape(row.extend[0]) + "</a>" : "");
|
||||
},
|
||||
operate: function (value, row, index) {
|
||||
return Template("operatetpl", {item: row, index: index});
|
||||
},
|
||||
toggle: function (value, row, index) {
|
||||
if (!row.addon) {
|
||||
return '';
|
||||
}
|
||||
return '<a href="javascript:;" data-toggle="tooltip" title="' + __('Click to toggle status') + '" class="btn btn-toggle btn-' + (row.addon.state == 1 ? "disable" : "enable") + '" data-action="' + (row.addon.state == 1 ? "disable" : "enable") + '" data-name="' + row.name + '"><i class="fa ' + (row.addon.state == 0 ? 'fa-toggle-on fa-rotate-180 text-gray' : 'fa-toggle-on text-success') + ' fa-2x"></i></a>';
|
||||
},
|
||||
author: function (value, row, index) {
|
||||
var url = 'javascript:';
|
||||
if (typeof row.homepage !== 'undefined') {
|
||||
url = row.homepage;
|
||||
} else if (typeof row.qq !== 'undefined' && row.qq) {
|
||||
url = 'https://wpa.qq.com/msgrd?v=3&uin=' + row.qq + '&site=&menu=yes';
|
||||
}
|
||||
return '<a href="' + url + '" target="_blank" data-toggle="tooltip" class="text-primary">' + value + '</a>';
|
||||
},
|
||||
price: function (value, row, index) {
|
||||
if (isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
return parseFloat(value) == 0 ? '<span class="text-success">' + __('Free') + '</span>' : '<span class="text-danger">¥' + value + '</span>';
|
||||
},
|
||||
downloads: function (value, row, index) {
|
||||
return value;
|
||||
},
|
||||
version: function (value, row, index) {
|
||||
return row.addon && row.addon.version != row.version ? '<a href="' + row.url + '?version=' + row.version + '" target="_blank"><span class="releasetips text-primary" data-toggle="tooltip" title="' + __('New version tips', row.version) + '">' + row.addon.version + '<i></i></span></a>' : row.version;
|
||||
},
|
||||
home: function (value, row, index) {
|
||||
return row.addon && parseInt(row.addon.state) > 0 ? '<a href="' + row.addon.url + '" data-toggle="tooltip" title="' + __('View addon index page') + '" target="_blank"><i class="fa fa-home text-primary"></i></a>' : '<a href="javascript:;"><i class="fa fa-home text-gray"></i></a>';
|
||||
},
|
||||
},
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
userinfo: {
|
||||
get: function () {
|
||||
if (typeof $.cookie !== 'undefined') {
|
||||
var userinfo = $.cookie('fastadmin_userinfo');
|
||||
} else {
|
||||
var userinfo = sessionStorage.getItem("fastadmin_userinfo");
|
||||
}
|
||||
return userinfo ? JSON.parse(userinfo) : null;
|
||||
},
|
||||
set: function (data) {
|
||||
if (typeof $.cookie !== 'undefined') {
|
||||
if (data) {
|
||||
$.cookie("fastadmin_userinfo", JSON.stringify(data));
|
||||
} else {
|
||||
$.removeCookie("fastadmin_userinfo");
|
||||
}
|
||||
} else {
|
||||
if (data) {
|
||||
sessionStorage.setItem("fastadmin_userinfo", JSON.stringify(data));
|
||||
} else {
|
||||
sessionStorage.removeItem("fastadmin_userinfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
sid: function () {
|
||||
var sid = $.cookie('fastadmin_sid');
|
||||
if (!sid) {
|
||||
sid = Math.random().toString(20).substr(2, 12);
|
||||
$.cookie('fastadmin_sid', sid);
|
||||
}
|
||||
return sid;
|
||||
},
|
||||
refresh: function (table, name) {
|
||||
//刷新左侧边栏
|
||||
Fast.api.refreshmenu();
|
||||
|
||||
//刷新行数据
|
||||
if ($(".operate[data-name='" + name + "']").length > 0) {
|
||||
var tr = $(".operate[data-name='" + name + "']").closest("tr[data-index]");
|
||||
var index = tr.data("index");
|
||||
var row = Table.api.getrowbyindex(table, index);
|
||||
row.addon = typeof Config['addons'][name] !== 'undefined' ? Config['addons'][name] : undefined;
|
||||
table.bootstrapTable("updateRow", {index: index, row: row});
|
||||
} else if ($(".btn-switch.active").data("type") == "local") {
|
||||
$(".btn-refresh").trigger("click");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
62
public/assets/js/backend/auth/admin.js
Normal file
62
public/assets/js/backend/auth/admin.js
Normal file
@@ -0,0 +1,62 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'auth/admin/index',
|
||||
add_url: 'auth/admin/add',
|
||||
edit_url: 'auth/admin/edit',
|
||||
del_url: 'auth/admin/del',
|
||||
multi_url: 'auth/admin/multi',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
//在表格内容渲染完成后回调的事件
|
||||
table.on('post-body.bs.table', function (e, json) {
|
||||
$("tbody tr[data-index]", this).each(function () {
|
||||
if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
|
||||
$("input[type=checkbox]", this).prop("disabled", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true, },
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'username', title: __('Username')},
|
||||
{field: 'nickname', title: __('Nickname')},
|
||||
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
|
||||
{field: 'email', title: __('Email')},
|
||||
{field: 'mobile', title: __('Mobile')},
|
||||
{field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
|
||||
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
||||
if(row.id == Config.admin.id){
|
||||
return '';
|
||||
}
|
||||
return Table.api.formatter.operate.call(this, value, row, index);
|
||||
}}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
edit: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
64
public/assets/js/backend/auth/adminlog.js
Normal file
64
public/assets/js/backend/auth/adminlog.js
Normal file
@@ -0,0 +1,64 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'auth/adminlog/index',
|
||||
add_url: '',
|
||||
edit_url: '',
|
||||
del_url: 'auth/adminlog/del',
|
||||
multi_url: 'auth/adminlog/multi',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID', operate: false},
|
||||
{field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
|
||||
{field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索'},
|
||||
{field: 'url', title: __('Url'), formatter: Table.api.formatter.url},
|
||||
{field: 'ip', title: __('IP'), events: Table.api.events.ip, formatter: Table.api.formatter.search},
|
||||
{field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table,
|
||||
events: Table.api.events.operate,
|
||||
buttons: [{
|
||||
name: 'detail',
|
||||
text: __('Detail'),
|
||||
icon: 'fa fa-list',
|
||||
classname: 'btn btn-info btn-xs btn-detail btn-dialog',
|
||||
url: 'auth/adminlog/detail'
|
||||
}],
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
formatter: {
|
||||
browser: function (value, row, index) {
|
||||
return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>';
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
160
public/assets/js/backend/auth/group.js
Normal file
160
public/assets/js/backend/auth/group.js
Normal file
@@ -0,0 +1,160 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) {
|
||||
//读取选中的条目
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
"index_url": "auth/group/index",
|
||||
"add_url": "auth/group/add",
|
||||
"edit_url": "auth/group/edit",
|
||||
"del_url": "auth/group/del",
|
||||
"multi_url": "auth/group/multi",
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
//在表格内容渲染完成后回调的事件
|
||||
table.on('post-body.bs.table', function (e, json) {
|
||||
$("tbody tr[data-index]", this).each(function () {
|
||||
if (Config.admin.group_ids.indexOf(parseInt(parseInt($("td:eq(1)", this).text()))) > -1) {
|
||||
$("input[type=checkbox]", this).prop("disabled", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'pid', title: __('Parent')},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) {
|
||||
return value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
}
|
||||
},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
||||
if (Config.admin.group_ids.indexOf(parseInt(row.id)) > -1) {
|
||||
return '';
|
||||
}
|
||||
return Table.api.formatter.operate.call(this, value, row, index);
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: false,
|
||||
commonSearch: false,
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);//当内容渲染完成后
|
||||
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"), null, null, function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[rules]']").val(r.join(','));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//变更级别后需要重建节点树
|
||||
$(document).on("change", "select[name='row[pid]']", function () {
|
||||
var pid = $(this).data("pid");
|
||||
var id = $(this).data("id");
|
||||
if ($(this).val() == id) {
|
||||
$("option[value='" + pid + "']", this).prop("selected", true).change();
|
||||
Backend.api.toastr.error(__('Can not change the parent to self'));
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url: "auth/group/roletree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {id: id, pid: $(this).val()},
|
||||
success: function (ret) {
|
||||
if (ret.hasOwnProperty("code")) {
|
||||
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : "";
|
||||
if (ret.code === 1) {
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
Controller.api.rendertree(data);
|
||||
} else {
|
||||
Backend.api.toastr.error(ret.msg);
|
||||
}
|
||||
}
|
||||
}, error: function (e) {
|
||||
Backend.api.toastr.error(e.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
221
public/assets/js/backend/auth/rule.js
Normal file
221
public/assets/js/backend/auth/rule.js
Normal file
@@ -0,0 +1,221 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
"index_url": "auth/rule/index",
|
||||
"add_url": "auth/rule/add",
|
||||
"edit_url": "auth/rule/edit",
|
||||
"del_url": "auth/rule/del",
|
||||
"multi_url": "auth/rule/multi",
|
||||
"table": "auth_rule"
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: '',
|
||||
escape: true,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title, clickToSelect: !false},
|
||||
{field: 'icon', title: __('Icon'), formatter: Controller.api.formatter.icon},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'ismenu',
|
||||
title: __('Ismenu'),
|
||||
align: 'center',
|
||||
table: table,
|
||||
formatter: Table.api.formatter.toggle
|
||||
},
|
||||
{
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: false,
|
||||
commonSearch: false,
|
||||
rowAttributes: function (row, index) {
|
||||
return row.pid == 0 ? {} : {style: "display:none"};
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
var btnSuccessEvent = function (data, ret) {
|
||||
if ($(this).hasClass("btn-change")) {
|
||||
var index = $(this).data("index");
|
||||
var row = Table.api.getrowbyindex(table, index);
|
||||
row.ismenu = $("i.fa.text-gray", this).length > 0 ? 1 : 0;
|
||||
table.bootstrapTable("updateRow", {index: index, row: row});
|
||||
} else if ($(this).hasClass("btn-delone")) {
|
||||
if ($(this).closest("tr[data-index]").find("a.btn-node-sub.disabled").length > 0) {
|
||||
$(this).closest("tr[data-index]").remove();
|
||||
} else {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
} else if ($(this).hasClass("btn-dragsort")) {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
Fast.api.refreshmenu();
|
||||
return false;
|
||||
};
|
||||
|
||||
//表格内容渲染前
|
||||
table.on('pre-body.bs.table', function (e, data) {
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
options.escape = true;
|
||||
});
|
||||
|
||||
//当内容渲染完成后
|
||||
table.on('post-body.bs.table', function (e, data) {
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
options.escape = false;
|
||||
|
||||
//点击切换/排序/删除操作后刷新左侧菜单
|
||||
$(".btn-change[data-id],.btn-delone,.btn-dragsort").data("success", btnSuccessEvent);
|
||||
|
||||
});
|
||||
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
//显示隐藏子节点
|
||||
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||
var status = $(this).data("shown") ? true : false;
|
||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||
$(this).closest("tr").toggle(!status);
|
||||
});
|
||||
if (status) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$(this).data("shown", !status);
|
||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
//隐藏子节点
|
||||
$(document).on("collapse", ".btn-node-sub", function () {
|
||||
if ($("i", this).length > 0) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
$(this).data("shown", false);
|
||||
$(this).closest("tr").toggle(false);
|
||||
});
|
||||
|
||||
//批量删除后的回调
|
||||
$(".toolbar > .btn-del,.toolbar .btn-more~ul>li>a").data("success", function (e) {
|
||||
Fast.api.refreshmenu();
|
||||
});
|
||||
|
||||
//展开隐藏一级
|
||||
$(document.body).on("click", ".btn-toggle", function (e) {
|
||||
$("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-chevron-down");
|
||||
$("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
|
||||
$("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
|
||||
$(".btn-node-sub[data-pid=0]").data("shown", show);
|
||||
});
|
||||
|
||||
//展开隐藏全部
|
||||
$(document.body).on("click", ".btn-toggle-all", function (e) {
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-plus");
|
||||
$("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
|
||||
$(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
|
||||
$(".btn-node-sub").data("shown", show);
|
||||
$(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
value = value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : '';
|
||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||
|
||||
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||
},
|
||||
name: function (value, row, index) {
|
||||
return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
},
|
||||
icon: function (value, row, index) {
|
||||
return '<span class="' + (!row.ismenu || row.status == 'hidden' ? 'text-muted' : '') + '"><i class="' + value + '"></i></span>';
|
||||
}
|
||||
},
|
||||
bindevent: function () {
|
||||
$(document).on('click', "input[name='row[ismenu]']", function () {
|
||||
var name = $("input[name='row[name]']");
|
||||
var ismenu = $(this).val() == 1;
|
||||
name.prop("placeholder", ismenu ? name.data("placeholder-menu") : name.data("placeholder-node"));
|
||||
$('div[data-type="menu"]').toggleClass("hidden", !ismenu);
|
||||
});
|
||||
$("input[name='row[ismenu]']:checked").trigger("click");
|
||||
|
||||
var iconlist = [];
|
||||
var iconfunc = function () {
|
||||
Layer.open({
|
||||
type: 1,
|
||||
area: ['80%', '80%'], //宽高
|
||||
content: Template('chooseicontpl', {iconlist: iconlist})
|
||||
});
|
||||
};
|
||||
Form.api.bindevent($("form[role=form]"), function (data) {
|
||||
Fast.api.refreshmenu();
|
||||
});
|
||||
$(document).on('change keyup', "#icon", function () {
|
||||
$(this).prev().find("i").prop("class", $(this).val());
|
||||
});
|
||||
$(document).on('click', ".btn-search-icon", function () {
|
||||
if (iconlist.length == 0) {
|
||||
$.get(Config.site.cdnurl + "/assets/libs/font-awesome/css/font-awesome.css", function (ret) {
|
||||
var exp = /fa-(.*):before/ig;
|
||||
var result;
|
||||
while ((result = exp.exec(ret)) != null) {
|
||||
iconlist.push(result[1]);
|
||||
}
|
||||
iconfunc();
|
||||
});
|
||||
} else {
|
||||
iconfunc();
|
||||
}
|
||||
});
|
||||
$(document).on('click', '#chooseicon ul li', function () {
|
||||
$("input[name='row[icon]']").val('fa fa-' + $(this).data("font")).trigger("change");
|
||||
Layer.closeAll();
|
||||
});
|
||||
$(document).on('keyup', 'input.js-icon-search', function () {
|
||||
$("#chooseicon ul li").show();
|
||||
if ($(this).val() != '') {
|
||||
$("#chooseicon ul li:not([data-font*='" + $(this).val() + "'])").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
93
public/assets/js/backend/category.js
Normal file
93
public/assets/js/backend/category.js
Normal file
@@ -0,0 +1,93 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'category/index',
|
||||
add_url: 'category/add',
|
||||
edit_url: 'category/edit',
|
||||
del_url: 'category/del',
|
||||
multi_url: 'category/multi',
|
||||
dragsort_url: 'ajax/weigh',
|
||||
table: 'category',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'weigh',
|
||||
pagination: false,
|
||||
commonSearch: false,
|
||||
search: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'type', title: __('Type'), operate: false, searchList: Config.searchList, formatter: Table.api.formatter.label},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) {
|
||||
return value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
}
|
||||
},
|
||||
{field: 'nickname', title: __('Nickname')},
|
||||
{field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag},
|
||||
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
//绑定TAB事件
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
// var options = table.bootstrapTable(tableOptions);
|
||||
var typeStr = $(this).attr("href").replace('#', '');
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
options.pageNumber = 1;
|
||||
options.queryParams = function (params) {
|
||||
// params.filter = JSON.stringify({type: typeStr});
|
||||
params.type = typeStr;
|
||||
|
||||
return params;
|
||||
};
|
||||
table.bootstrapTable('refresh', {});
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
//必须默认触发shown.bs.tab事件
|
||||
// $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
|
||||
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
setTimeout(function () {
|
||||
$("#c-type").trigger("change");
|
||||
}, 100);
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
$(document).on("change", "#c-type", function () {
|
||||
$("#c-pid option[data-type='all']").prop("selected", true);
|
||||
$("#c-pid option").removeClass("hide");
|
||||
$("#c-pid option[data-type!='" + $(this).val() + "'][data-type!='all']").addClass("hide");
|
||||
$("#c-pid").data("selectpicker") && $("#c-pid").selectpicker("refresh");
|
||||
});
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
80
public/assets/js/backend/dashboard.js
Normal file
80
public/assets/js/backend/dashboard.js
Normal file
@@ -0,0 +1,80 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = Echarts.init(document.getElementById('echart'), 'walden');
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
title: {
|
||||
text: '',
|
||||
subtext: ''
|
||||
},
|
||||
color: [
|
||||
"#18d1b1",
|
||||
"#3fb1e3",
|
||||
"#626c91",
|
||||
"#a0a7e6",
|
||||
"#c4ebad",
|
||||
"#96dee8"
|
||||
],
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: [__('Register user')]
|
||||
},
|
||||
toolbox: {
|
||||
show: false,
|
||||
feature: {
|
||||
magicType: {show: true, type: ['stack', 'tiled']},
|
||||
saveAsImage: {show: true}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: Config.column
|
||||
},
|
||||
yAxis: {},
|
||||
grid: [{
|
||||
left: 'left',
|
||||
top: 'top',
|
||||
right: '10',
|
||||
bottom: 30
|
||||
}],
|
||||
series: [{
|
||||
name: __('Register user'),
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
areaStyle: {
|
||||
normal: {}
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 1.5
|
||||
}
|
||||
},
|
||||
data: Config.userdata
|
||||
}]
|
||||
};
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
|
||||
$(window).resize(function () {
|
||||
myChart.resize();
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-refresh", function () {
|
||||
setTimeout(function () {
|
||||
myChart.resize();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return Controller;
|
||||
});
|
||||
261
public/assets/js/backend/general/attachment.js
Normal file
261
public/assets/js/backend/general/attachment.js
Normal file
@@ -0,0 +1,261 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'general/attachment/index',
|
||||
add_url: 'general/attachment/add',
|
||||
edit_url: 'general/attachment/edit',
|
||||
del_url: 'general/attachment/del',
|
||||
multi_url: 'general/attachment/multi',
|
||||
table: 'attachment'
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'admin_id', title: __('Admin_id'), visible: false, addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
|
||||
{field: 'user_id', title: __('User_id'), visible: false, addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
|
||||
{field: 'preview', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
|
||||
{field: 'url', title: __('Url'), formatter: Controller.api.formatter.url, visible: false},
|
||||
{field: 'filename', title: __('Filename'), sortable: true, formatter: Controller.api.formatter.filename, operate: 'like'},
|
||||
{
|
||||
field: 'filesize', title: __('Filesize'), operate: 'BETWEEN', sortable: true, formatter: function (value, row, index) {
|
||||
var size = parseFloat(value);
|
||||
var i = Math.floor(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
},
|
||||
{field: 'imagewidth', title: __('Imagewidth'), sortable: true},
|
||||
{field: 'imageheight', title: __('Imageheight'), sortable: true},
|
||||
{field: 'imagetype', title: __('Imagetype'), sortable: true, formatter: Table.api.formatter.search, operate: 'like'},
|
||||
{field: 'storage', title: __('Storage'), formatter: Table.api.formatter.search, operate: 'like'},
|
||||
{field: 'mimetype', title: __('Mimetype'), formatter: Controller.api.formatter.mimetype},
|
||||
{
|
||||
field: 'createtime',
|
||||
title: __('Createtime'),
|
||||
formatter: Table.api.formatter.datetime,
|
||||
operate: 'RANGE',
|
||||
addclass: 'datetimerange',
|
||||
sortable: true,
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
],
|
||||
});
|
||||
|
||||
// 绑定过滤事件
|
||||
$('.filter-type ul li a', table.closest(".panel-intro")).on('click', function (e) {
|
||||
$(this).closest("ul").find("li").removeClass("active");
|
||||
$(this).closest("li").addClass("active");
|
||||
var field = 'mimetype';
|
||||
var value = $(this).data("value") || '';
|
||||
var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
|
||||
if (object.prop('tagName') == "SELECT") {
|
||||
$("option[value='" + value + "']", object).prop("selected", true);
|
||||
} else {
|
||||
object.val(value);
|
||||
}
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh', {pageNumber: 1});
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
// 附件归类
|
||||
$(document).on('click', '.btn-classify', function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
Layer.open({
|
||||
title: __('Classify'),
|
||||
content: Template("typetpl", {}),
|
||||
btn: [__('OK')],
|
||||
yes: function (index, layero) {
|
||||
var category = $("select[name='category']", layero).val();
|
||||
Fast.api.ajax({
|
||||
url: "general/attachment/classify",
|
||||
type: "post",
|
||||
data: {category: category, ids: ids.join(',')},
|
||||
}, function () {
|
||||
table.bootstrapTable('refresh', {});
|
||||
Layer.close(index);
|
||||
});
|
||||
},
|
||||
success: function (layero, index) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
select: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'general/attachment/select',
|
||||
}
|
||||
});
|
||||
var urlArr = [];
|
||||
var multiple = Backend.api.query('multiple');
|
||||
multiple = multiple == 'true' ? true : false;
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function (e, row) {
|
||||
if (e.type == 'check' || e.type == 'uncheck') {
|
||||
row = [row];
|
||||
} else {
|
||||
urlArr = [];
|
||||
}
|
||||
$.each(row, function (i, j) {
|
||||
if (e.type.indexOf("uncheck") > -1) {
|
||||
var index = urlArr.indexOf(j.url);
|
||||
if (index > -1) {
|
||||
urlArr.splice(index, 1);
|
||||
}
|
||||
} else {
|
||||
urlArr.indexOf(j.url) == -1 && urlArr.push(j.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'id',
|
||||
showToggle: false,
|
||||
showExport: false,
|
||||
maintainSelected: true,
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: multiple, visible: multiple, operate: false},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'url', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
|
||||
{field: 'filename', title: __('Filename'), sortable: true, formatter: Controller.api.formatter.filename, operate: 'like'},
|
||||
{field: 'imagewidth', title: __('Imagewidth'), operate: false, sortable: true},
|
||||
{field: 'imageheight', title: __('Imageheight'), operate: false, sortable: true},
|
||||
{
|
||||
field: 'mimetype', title: __('Mimetype'), sortable: true, operate: 'LIKE %...%',
|
||||
process: function (value, arg) {
|
||||
return value.replace(/\*/g, '%');
|
||||
},
|
||||
formatter: Controller.api.formatter.mimetype
|
||||
},
|
||||
{field: 'createtime', title: __('Createtime'), width: 120, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD', operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), width: 85, events: {
|
||||
'click .btn-chooseone': function (e, value, row, index) {
|
||||
Fast.api.close($.extend({multiple: multiple}, row));
|
||||
},
|
||||
}, formatter: function () {
|
||||
return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 绑定过滤事件
|
||||
$('.filter-type ul li a', table.closest(".panel-intro")).on('click', function (e) {
|
||||
$(this).closest("ul").find("li").removeClass("active");
|
||||
$(this).closest("li").addClass("active");
|
||||
var field = 'mimetype';
|
||||
var value = $(this).data("value") || '';
|
||||
var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
|
||||
if (object.prop('tagName') == "SELECT") {
|
||||
$("option[value='" + value + "']", object).prop("selected", true);
|
||||
} else {
|
||||
object.val(value);
|
||||
}
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh', {pageNumber: 1});
|
||||
});
|
||||
|
||||
// 选中多个
|
||||
$(document).on("click", ".btn-choose-multi", function () {
|
||||
Fast.api.close({url: urlArr.join(","), multiple: multiple});
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
require(['upload'], function (Upload) {
|
||||
$("#toolbar .faupload").data("category", function (file) {
|
||||
var category = $("ul.nav-tabs[data-field='category'] li.active a").data("value");
|
||||
return category;
|
||||
});
|
||||
Upload.api.upload($("#toolbar .faupload"), function () {
|
||||
$(".btn-refresh").trigger("click");
|
||||
});
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
//上传完成后刷新父窗口
|
||||
$(".faupload").data("upload-complete", function (files) {
|
||||
setTimeout(function () {
|
||||
window.parent.$(".btn-refresh").trigger("click");
|
||||
}, 100);
|
||||
});
|
||||
// 获取上传类别
|
||||
$("#faupload-third,#faupload-third-chunking").data("category", function (file) {
|
||||
return $("#category-third").val();
|
||||
});
|
||||
// 获取上传类别
|
||||
$("#faupload-local,#faupload-local-chunking").data("category", function (file) {
|
||||
return $("#category-local").val();
|
||||
});
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
formatter: {
|
||||
thumb: function (value, row, index) {
|
||||
var html = '';
|
||||
if (row.mimetype.indexOf("image") > -1) {
|
||||
html = '<a href="' + row.fullurl + '" target="_blank"><img src="' + row.fullurl + row.thumb_style + '" alt="" style="max-height:60px;max-width:120px"></a>';
|
||||
} else {
|
||||
html = '<a href="' + row.fullurl + '" target="_blank"><img src="' + Fast.api.fixurl("ajax/icon") + "?suffix=" + row.imagetype + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
||||
}
|
||||
return '<div style="width:120px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + html + '</div>';
|
||||
},
|
||||
url: function (value, row, index) {
|
||||
return '<a href="' + row.fullurl + '" target="_blank" class="label bg-green">' + row.url + '</a>';
|
||||
},
|
||||
filename: function (value, row, index) {
|
||||
return '<div style="width:150px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
|
||||
},
|
||||
mimetype: function (value, row, index) {
|
||||
return '<div style="width:80px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
140
public/assets/js/backend/general/config.js
Normal file
140
public/assets/js/backend/general/config.js
Normal file
@@ -0,0 +1,140 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
$("form.edit-form").data("validator-options", {
|
||||
display: function (elem) {
|
||||
return $(elem).closest('tr').find("td:first").text();
|
||||
}
|
||||
});
|
||||
Form.api.bindevent($("form.edit-form"));
|
||||
|
||||
//不可见的元素不验证
|
||||
$("form#add-form").data("validator-options", {
|
||||
ignore: ':hidden',
|
||||
rules: {
|
||||
content: function () {
|
||||
return ['radio', 'checkbox', 'select', 'selects'].indexOf($("#add-form select[name='row[type]']").val()) > -1;
|
||||
},
|
||||
extend: function () {
|
||||
return $("#add-form select[name='row[type]']").val() == 'custom';
|
||||
}
|
||||
}
|
||||
});
|
||||
Form.api.bindevent($("form#add-form"), function (ret) {
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
//渲染关联显示字段和存储字段
|
||||
var renderselect = function (id, data, defaultvalue) {
|
||||
var html = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
html.push("<option value='" + data[i].name + "' " + (defaultvalue == data[i].name ? "selected" : "") + " data-subtext='" + data[i].title + "'>" + data[i].name + "</option>");
|
||||
}
|
||||
var select = $(id);
|
||||
$(select).html(html.join(""));
|
||||
select.trigger("change");
|
||||
if (select.data("selectpicker")) {
|
||||
select.selectpicker('refresh');
|
||||
}
|
||||
};
|
||||
//关联表切换
|
||||
$(document).on('change', "#c-selectpage-table", function (e, first) {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: "general/config/get_fields_list",
|
||||
data: {table: $(that).val()},
|
||||
}, function (data, ret) {
|
||||
renderselect("#c-selectpage-primarykey", data.fieldList, first ? $("#c-selectpage-primarykey").data("value") : '');
|
||||
renderselect("#c-selectpage-field", data.fieldList, first ? $("#c-selectpage-field").data("value") : '');
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
//如果编辑模式则渲染已知数据
|
||||
if (['selectpage', 'selectpages'].indexOf($("#c-type").val()) > -1) {
|
||||
$("#c-selectpage-table").trigger("change", true);
|
||||
}
|
||||
|
||||
//切换类型时
|
||||
$(document).on("change", "#c-type", function () {
|
||||
var value = $(this).val();
|
||||
$(".tf").addClass("hidden");
|
||||
$(".tf.tf-" + value).removeClass("hidden");
|
||||
if (["selectpage", "selectpages"].indexOf(value) > -1 && $("#c-selectpage-table option").length == 1) {
|
||||
//异步加载表列表
|
||||
Fast.api.ajax({
|
||||
url: "general/config/get_table_list",
|
||||
}, function (data, ret) {
|
||||
renderselect("#c-selectpage-table", data.tableList);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//切换显示隐藏变量字典列表
|
||||
$(document).on("change", "form#add-form select[name='row[type]']", function (e) {
|
||||
$("#add-content-container").toggleClass("hide", ['select', 'selects', 'checkbox', 'radio'].indexOf($(this).val()) > -1 ? false : true);
|
||||
});
|
||||
|
||||
//选择规则
|
||||
$(document).on("click", ".rulelist > li > a", function () {
|
||||
var ruleArr = $("#rule").val() == '' ? [] : $("#rule").val().split(";");
|
||||
var rule = $(this).data("value");
|
||||
var index = ruleArr.indexOf(rule);
|
||||
if (index > -1) {
|
||||
ruleArr.splice(index, 1);
|
||||
} else {
|
||||
ruleArr.push(rule);
|
||||
}
|
||||
$("#rule").val(ruleArr.join(";"));
|
||||
$(this).parent().toggleClass("active");
|
||||
});
|
||||
|
||||
//添加向发件人发送测试邮件按钮和方法
|
||||
$('input[name="row[mail_from]"]').parent().next().append('<a class="btn btn-info testmail">' + __('Send a test message') + '</a>');
|
||||
$(document).on("click", ".testmail", function () {
|
||||
var that = this;
|
||||
Layer.prompt({title: __('Please input your email'), formType: 0}, function (value, index) {
|
||||
Backend.api.ajax({
|
||||
url: "general/config/emailtest",
|
||||
data: $(that).closest("form").serialize() + "&receiver=" + value
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//删除配置
|
||||
$(document).on("click", ".btn-delcfg", function () {
|
||||
var that = this;
|
||||
Layer.confirm(__('Are you sure you want to delete this item?'), {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function (index) {
|
||||
Backend.api.ajax({
|
||||
url: "general/config/del",
|
||||
data: {name: $(that).data("name")}
|
||||
}, function () {
|
||||
$(that).closest("tr").remove();
|
||||
Layer.close(index);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
104
public/assets/js/backend/general/crontab.js
Normal file
104
public/assets/js/backend/general/crontab.js
Normal file
@@ -0,0 +1,104 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'general/crontab/index',
|
||||
add_url: 'general/crontab/add',
|
||||
edit_url: 'general/crontab/edit',
|
||||
del_url: 'general/crontab/del',
|
||||
multi_url: 'general/crontab/multi',
|
||||
table: 'crontab'
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'weigh',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'type', title: __('Type'), searchList: Config.typeList, formatter: Table.api.formatter.label, custom: {sql: 'warning', url: 'info', shell: 'success'}},
|
||||
{field: 'title', title: __('Title')},
|
||||
{field: 'maximums', title: __('Maximums'), formatter: Controller.api.formatter.maximums},
|
||||
{field: 'executes', title: __('Executes')},
|
||||
{field: 'begintime', title: __('Begin time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
|
||||
{field: 'endtime', title: __('End time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
|
||||
{field: 'nexttime', title: __('Next execute time'), formatter: Controller.api.formatter.nexttime, operate: false, addclass: 'datetimerange', sortable: true},
|
||||
{field: 'executetime', title: __('Execute time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), searchList: {"normal": __('Normal'), "hidden": __('Hidden'), "expired": __('Expired'), "completed": __('Completed')}, formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
||||
buttons: [
|
||||
{
|
||||
name: "detail",
|
||||
icon: "fa fa-list",
|
||||
title: function (row, index) {
|
||||
return __('Logs') + "[" + row['title'] + "]";
|
||||
},
|
||||
text: __('Logs'),
|
||||
classname: "btn btn-xs btn-info btn-dialog",
|
||||
url: "general/crontab_log/index?crontab_id={ids}",
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
$('#schedule').on('valid.field', function (e, result) {
|
||||
$("#pickdays").trigger("change");
|
||||
});
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
$(document).on("change", "#pickdays", function () {
|
||||
Fast.api.ajax({url: "general/crontab/get_schedule_future", data: {schedule: $("#schedule").val(), days: $(this).val()}}, function (data, ret) {
|
||||
if (typeof data.futuretime !== 'undefined' && $.isArray(data.futuretime)) {
|
||||
var result = [];
|
||||
$.each(data.futuretime, function (i, j) {
|
||||
result.push("<li class='list-group-item'>" + j + "<span class='badge'>" + (i + 1) + "</span></li>");
|
||||
});
|
||||
$("#scheduleresult").html(result.join(""));
|
||||
} else {
|
||||
$("#scheduleresult").html("");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$("#pickdays").trigger("change");
|
||||
},
|
||||
formatter: {
|
||||
nexttime: function (value, row, index) {
|
||||
if (isNaN(value)) {
|
||||
return value;
|
||||
} else {
|
||||
return Table.api.formatter.datetime.call(this, value, row, index);
|
||||
}
|
||||
},
|
||||
maximums: function (value, row, index) {
|
||||
return value === 0 ? __('No limit') : value;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
67
public/assets/js/backend/general/crontab_log.js
Normal file
67
public/assets/js/backend/general/crontab_log.js
Normal file
@@ -0,0 +1,67 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'general/crontab_log/index',
|
||||
add_url: 'general/crontab_log/add',
|
||||
edit_url: '',
|
||||
del_url: 'general/crontab_log/del',
|
||||
multi_url: 'general/crontab_log/multi',
|
||||
table: 'crontab'
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'crontab_id', title: __('Crontab_id'), formatter: Table.api.formatter.search},
|
||||
{field: 'executetime', title: __('Execute time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'completetime', title: __('Complete time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'status', title: __('Status'), searchList: Config.statusList, custom: {success: 'success', failure: 'danger', 'inprogress': 'warning'}, formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
||||
buttons: [
|
||||
{
|
||||
name: "detail",
|
||||
text: __("Result"),
|
||||
classname: "btn btn-xs btn-info btn-dialog",
|
||||
icon: "fa fa-file",
|
||||
url: "general/crontab_log/detail",
|
||||
extend: "data-window='parent'"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
|
||||
},
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
57
public/assets/js/backend/general/profile.js
Normal file
57
public/assets/js/backend/general/profile.js
Normal file
@@ -0,0 +1,57 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
search: true,
|
||||
advancedSearch: true,
|
||||
pagination: true,
|
||||
extend: {
|
||||
"index_url": "general/profile/index",
|
||||
"add_url": "",
|
||||
"edit_url": "",
|
||||
"del_url": "",
|
||||
"multi_url": "",
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'title', title: __('Title')},
|
||||
{field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url},
|
||||
{field: 'ip', title: __('ip'), formatter:Table.api.formatter.search},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
]
|
||||
],
|
||||
commonSearch: false
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);//当内容渲染完成后
|
||||
|
||||
// 给上传按钮添加上传成功事件
|
||||
$("#faupload-avatar").data("upload-success", function (data) {
|
||||
var url = Backend.api.cdnurl(data.url);
|
||||
$(".profile-user-img").prop("src", url);
|
||||
Toastr.success("上传成功!");
|
||||
});
|
||||
|
||||
// 给表单绑定事件
|
||||
Form.api.bindevent($("#update-form"), function () {
|
||||
$("input[name='row[password]']").val('');
|
||||
var url = Backend.api.cdnurl($("#c-avatar").val());
|
||||
top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
423
public/assets/js/backend/index.js
Normal file
423
public/assets/js/backend/index.js
Normal file
@@ -0,0 +1,423 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], function ($, undefined, Backend, undefined, AdminLTE, Form) {
|
||||
var Controller = {
|
||||
index: function () {
|
||||
//双击重新加载页面
|
||||
$(document).on("dblclick", ".sidebar-menu li > a", function (e) {
|
||||
$("#con_" + $(this).attr("addtabs") + " iframe").attr('src', function (i, val) {
|
||||
return val;
|
||||
});
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
//修复在移除窗口时下拉框不隐藏的BUG
|
||||
$(window).on("blur", function () {
|
||||
$("[data-toggle='dropdown']").parent().removeClass("open");
|
||||
if ($("body").hasClass("sidebar-open")) {
|
||||
$(".sidebar-toggle").trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
//快捷搜索
|
||||
$(".menuresult").width($("form.sidebar-form > .input-group").width());
|
||||
var searchResult = $(".menuresult");
|
||||
$("form.sidebar-form").on("blur", "input[name=q]", function () {
|
||||
searchResult.addClass("hide");
|
||||
}).on("focus", "input[name=q]", function () {
|
||||
if ($("a", searchResult).length > 0) {
|
||||
searchResult.removeClass("hide");
|
||||
}
|
||||
}).on("keyup", "input[name=q]", function () {
|
||||
searchResult.html('');
|
||||
var val = $(this).val();
|
||||
var html = [];
|
||||
if (val != '') {
|
||||
$("ul.sidebar-menu li a[addtabs]:not([href^='javascript:;'])").each(function () {
|
||||
if ($("span:first", this).text().indexOf(val) > -1 || $(this).attr("py").indexOf(val) > -1 || $(this).attr("pinyin").indexOf(val) > -1) {
|
||||
html.push('<a data-url="' + ($(this).attr("url") || $(this).attr("href")) + '" href="javascript:;">' + $("span:first", this).text() + '</a>');
|
||||
if (html.length >= 100) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(searchResult).append(html.join(""));
|
||||
if (html.length > 0) {
|
||||
searchResult.removeClass("hide");
|
||||
} else {
|
||||
searchResult.addClass("hide");
|
||||
}
|
||||
});
|
||||
//快捷搜索点击事件
|
||||
$("form.sidebar-form").on('mousedown click', '.menuresult a[data-url]', function () {
|
||||
Backend.api.addtabs($(this).data("url"));
|
||||
});
|
||||
|
||||
//切换左侧sidebar显示隐藏
|
||||
$(document).on("click fa.event.toggleitem", ".sidebar-menu li > a", function (e) {
|
||||
var nextul = $(this).next("ul");
|
||||
if (nextul.length == 0 && (!$(this).parent("li").hasClass("treeview") || ($("body").hasClass("multiplenav") && $(this).parent().parent().hasClass("sidebar-menu")))) {
|
||||
$(".sidebar-menu li").not($(this).parents("li")).removeClass("active");
|
||||
}
|
||||
//当外部触发隐藏的a时,触发父辈a的事件
|
||||
if (!$(this).closest("ul").is(":visible")) {
|
||||
//如果不需要左侧的菜单栏联动可以注释下面一行即可
|
||||
$(this).closest("ul").prev().trigger("click");
|
||||
}
|
||||
|
||||
var visible = nextul.is(":visible");
|
||||
if (nextul.length == 0) {
|
||||
$(this).parents("li").addClass("active");
|
||||
$(this).closest(".treeview").addClass("treeview-open");
|
||||
} else {
|
||||
}
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
//清除缓存
|
||||
$(document).on('click', "ul.wipecache li a,a.wipecache", function () {
|
||||
$.ajax({
|
||||
url: 'ajax/wipecache',
|
||||
dataType: 'json',
|
||||
data: {type: $(this).data("type")},
|
||||
cache: false,
|
||||
success: function (ret) {
|
||||
if (ret.hasOwnProperty("code")) {
|
||||
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||
if (ret.code === 1) {
|
||||
Toastr.success(msg ? msg : __('Wipe cache completed'));
|
||||
} else {
|
||||
Toastr.error(msg ? msg : __('Wipe cache failed'));
|
||||
}
|
||||
} else {
|
||||
Toastr.error(__('Unknown data format'));
|
||||
}
|
||||
}, error: function () {
|
||||
Toastr.error(__('Network error'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//全屏事件
|
||||
$(document).on('click', "[data-toggle='fullscreen']", function () {
|
||||
var doc = document.documentElement;
|
||||
if ($(document.body).hasClass("full-screen")) {
|
||||
$(document.body).removeClass("full-screen");
|
||||
document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen();
|
||||
} else {
|
||||
$(document.body).addClass("full-screen");
|
||||
doc.requestFullscreen ? doc.requestFullscreen() : doc.mozRequestFullScreen ? doc.mozRequestFullScreen() : doc.webkitRequestFullscreen ? doc.webkitRequestFullscreen() : doc.msRequestFullscreen && doc.msRequestFullscreen();
|
||||
}
|
||||
});
|
||||
|
||||
var multiplenav = $("body").hasClass("multiplenav") > 0 ? true : false;
|
||||
var firstnav = $("#firstnav .nav-addtabs");
|
||||
var nav = multiplenav ? $("#secondnav .nav-addtabs") : firstnav;
|
||||
|
||||
//刷新菜单事件
|
||||
$(document).on('refresh', '.sidebar-menu', function () {
|
||||
Fast.api.ajax({
|
||||
url: 'index/index',
|
||||
data: {action: 'refreshmenu'},
|
||||
loading: false
|
||||
}, function (data) {
|
||||
$(".sidebar-menu li:not([data-rel='external'])").remove();
|
||||
$(".sidebar-menu").prepend(data.menulist);
|
||||
if (multiplenav) {
|
||||
firstnav.html(data.navlist);
|
||||
}
|
||||
$("li[role='presentation'].active a", nav).trigger('click');
|
||||
$(window).trigger("resize");
|
||||
return false;
|
||||
}, function () {
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
if (multiplenav) {
|
||||
firstnav.css("overflow", "inherit");
|
||||
//一级菜单自适应
|
||||
$(window).resize(function () {
|
||||
var siblingsWidth = 0;
|
||||
firstnav.siblings().each(function () {
|
||||
siblingsWidth += $(this).outerWidth();
|
||||
});
|
||||
firstnav.width(firstnav.parent().width() - siblingsWidth);
|
||||
firstnav.refreshAddtabs();
|
||||
});
|
||||
|
||||
//点击顶部第一级菜单栏
|
||||
firstnav.on("click", "li a", function () {
|
||||
$("li", firstnav).removeClass("active");
|
||||
$(this).closest("li").addClass("active");
|
||||
$(".sidebar-menu > li[pid]").addClass("hidden");
|
||||
if ($(this).attr("url") == "javascript:;") {
|
||||
var sonlist = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "']");
|
||||
sonlist.removeClass("hidden");
|
||||
var sidenav;
|
||||
var last_id = $(this).attr("last-id");
|
||||
if (last_id) {
|
||||
sidenav = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "'] a[addtabs='" + last_id + "']");
|
||||
} else {
|
||||
sidenav = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "']:first > a");
|
||||
}
|
||||
if (sidenav) {
|
||||
sidenav.attr("href") != "javascript:;" && sidenav.trigger('click');
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var mobilenav = $(".mobilenav");
|
||||
$("#firstnav .nav-addtabs li a").each(function () {
|
||||
mobilenav.append($(this).clone().addClass("btn btn-app"));
|
||||
});
|
||||
|
||||
//点击移动端一级菜单
|
||||
mobilenav.on("click", "a", function () {
|
||||
$("a", mobilenav).removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$(".sidebar-menu > li[pid]").addClass("hidden");
|
||||
if ($(this).attr("url") == "javascript:;") {
|
||||
var sonlist = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "']");
|
||||
sonlist.removeClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
//点击左侧菜单栏
|
||||
$(document).on('click', '.sidebar-menu li a[addtabs]', function (e) {
|
||||
var parents = $(this).parentsUntil("ul.sidebar-menu", "li");
|
||||
var top = parents[parents.length - 1];
|
||||
var pid = $(top).attr("pid");
|
||||
if (pid) {
|
||||
var obj = $("li a[addtabs=" + pid + "]", firstnav);
|
||||
var last_id = obj.attr("last-id");
|
||||
if (!last_id || last_id != pid) {
|
||||
obj.attr("last-id", $(this).attr("addtabs"));
|
||||
if (!obj.closest("li").hasClass("active")) {
|
||||
obj.trigger("click");
|
||||
}
|
||||
}
|
||||
mobilenav.find("a").removeClass("active");
|
||||
mobilenav.find("a[addtabs='" + pid + "']").addClass("active");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//这一行需要放在点击左侧链接事件之前
|
||||
var addtabs = Config.referer ? sessionStorage.getItem("addtabs") : null;
|
||||
|
||||
//绑定tabs事件,如果需要点击强制刷新iframe,则请将iframeForceRefresh置为true,iframeForceRefreshTable只强制刷新表格
|
||||
nav.addtabs({iframeHeight: "100%", iframeForceRefresh: false, iframeForceRefreshTable: true, nav: nav});
|
||||
|
||||
if ($("ul.sidebar-menu li.active a").length > 0) {
|
||||
$("ul.sidebar-menu li.active a").trigger("click");
|
||||
} else {
|
||||
if (multiplenav) {
|
||||
$("li:first > a", firstnav).trigger("click");
|
||||
} else {
|
||||
$("ul.sidebar-menu li a[url!='javascript:;']:first").trigger("click");
|
||||
}
|
||||
}
|
||||
|
||||
//如果是刷新操作则直接返回刷新前的页面
|
||||
if (Config.referer) {
|
||||
if (Config.referer === $(addtabs).attr("url")) {
|
||||
var active = $("ul.sidebar-menu li a[addtabs=" + $(addtabs).attr("addtabs") + "]");
|
||||
if (multiplenav && active.length == 0) {
|
||||
active = $("ul li a[addtabs='" + $(addtabs).attr("addtabs") + "']");
|
||||
}
|
||||
if (active.length > 0) {
|
||||
active.trigger("click");
|
||||
} else {
|
||||
$(addtabs).appendTo(document.body).addClass("hide").trigger("click");
|
||||
}
|
||||
} else {
|
||||
//刷新页面后跳到到刷新前的页面
|
||||
Backend.api.addtabs(Config.referer);
|
||||
}
|
||||
}
|
||||
|
||||
var createCookie = function (name, value) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
|
||||
var path = Config.moduleurl;
|
||||
document.cookie = encodeURIComponent(Config.cookie.prefix + name) + "=" + encodeURIComponent(value) + "; path=" + path + "; expires=" + date.toGMTString();
|
||||
};
|
||||
|
||||
var my_skins = [
|
||||
"skin-blue",
|
||||
"skin-black",
|
||||
"skin-red",
|
||||
"skin-yellow",
|
||||
"skin-purple",
|
||||
"skin-green",
|
||||
"skin-blue-light",
|
||||
"skin-black-light",
|
||||
"skin-red-light",
|
||||
"skin-yellow-light",
|
||||
"skin-purple-light",
|
||||
"skin-green-light",
|
||||
"skin-black-blue",
|
||||
"skin-black-purple",
|
||||
"skin-black-red",
|
||||
"skin-black-green",
|
||||
"skin-black-yellow",
|
||||
"skin-black-pink",
|
||||
];
|
||||
|
||||
// 皮肤切换
|
||||
$("[data-skin]").on('click', function (e) {
|
||||
var skin = $(this).data('skin');
|
||||
if (!$("body").hasClass(skin)) {
|
||||
$("body").removeClass(my_skins.join(' ')).addClass(skin);
|
||||
var cssfile = Config.site.cdnurl + "/assets/css/skins/" + skin + ".css";
|
||||
$('head').append('<link rel="stylesheet" href="' + cssfile + '" type="text/css" />');
|
||||
$(".skin-list li.active").removeClass("active");
|
||||
$(".skin-list li a[data-skin='" + skin + "']").parent().addClass("active");
|
||||
createCookie('adminskin', skin);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 收起菜单栏切换
|
||||
$("[data-layout='sidebar-collapse']").on('click', function () {
|
||||
$(".sidebar-toggle").trigger("click");
|
||||
});
|
||||
|
||||
// 切换子菜单显示和菜单小图标的显示
|
||||
$("[data-menu='show-submenu']").on('click', function () {
|
||||
createCookie('show_submenu', $(this).prop("checked") ? 1 : 0);
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// 右侧控制栏切换
|
||||
$("[data-controlsidebar]").on('click', function () {
|
||||
var cls = $(this).data('controlsidebar');
|
||||
$("body").toggleClass(cls);
|
||||
AdminLTE.layout.fixSidebar();
|
||||
//Fix the problem with right sidebar and layout boxed
|
||||
if (cls == "layout-boxed")
|
||||
AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
|
||||
if ($('body').hasClass('fixed') && cls == 'fixed') {
|
||||
AdminLTE.pushMenu.expandOnHover();
|
||||
AdminLTE.layout.activate();
|
||||
}
|
||||
AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
|
||||
AdminLTE.controlSidebar._fix($(".control-sidebar"));
|
||||
var slide = !AdminLTE.options.controlSidebarOptions.slide;
|
||||
AdminLTE.options.controlSidebarOptions.slide = slide;
|
||||
if (!slide)
|
||||
$('.control-sidebar').removeClass('control-sidebar-open');
|
||||
});
|
||||
|
||||
// 右侧控制栏背景切换
|
||||
$("[data-sidebarskin='toggle']").on('click', function () {
|
||||
var sidebar = $(".control-sidebar");
|
||||
if (sidebar.hasClass("control-sidebar-dark")) {
|
||||
sidebar.removeClass("control-sidebar-dark")
|
||||
sidebar.addClass("control-sidebar-light")
|
||||
} else {
|
||||
sidebar.removeClass("control-sidebar-light")
|
||||
sidebar.addClass("control-sidebar-dark")
|
||||
}
|
||||
});
|
||||
|
||||
// 菜单栏展开或收起
|
||||
$("[data-enable='expandOnHover']").on('click', function () {
|
||||
$.AdminLTE.options.sidebarExpandOnHover = $(this).prop("checked") ? 1 : 0;
|
||||
localStorage.setItem('sidebarExpandOnHover', $.AdminLTE.options.sidebarExpandOnHover);
|
||||
AdminLTE.pushMenu.expandOnHover();
|
||||
$.AdminLTE.layout.fixSidebar();
|
||||
});
|
||||
|
||||
// 切换菜单栏
|
||||
$(document).on("click", ".sidebar-toggle", function () {
|
||||
setTimeout(function(){
|
||||
var value = $("body").hasClass("sidebar-collapse") ? 1 : 0;
|
||||
setTimeout(function () {
|
||||
$(window).trigger("resize");
|
||||
}, 300);
|
||||
createCookie('sidebar_collapse', value);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// 切换多级菜单
|
||||
$(document).on("click", "[data-config='multiplenav']", function () {
|
||||
var value = $(this).prop("checked") ? 1 : 0;
|
||||
createCookie('multiplenav', value);
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// 切换多选项卡
|
||||
$(document).on("click", "[data-config='multipletab']", function () {
|
||||
var value = $(this).prop("checked") ? 1 : 0;
|
||||
$("body").toggleClass("multipletab", value);
|
||||
createCookie('multipletab', value);
|
||||
});
|
||||
|
||||
// 重设选项
|
||||
if ($('body').hasClass('fixed')) {
|
||||
$("[data-layout='fixed']").attr('checked', 'checked');
|
||||
}
|
||||
if ($('body').hasClass('layout-boxed')) {
|
||||
$("[data-layout='layout-boxed']").attr('checked', 'checked');
|
||||
}
|
||||
if ($('body').hasClass('sidebar-collapse')) {
|
||||
$("[data-layout='sidebar-collapse']").attr('checked', 'checked');
|
||||
}
|
||||
if ($('ul.sidebar-menu').hasClass('show-submenu')) {
|
||||
$("[data-menu='show-submenu']").attr('checked', 'checked');
|
||||
}
|
||||
|
||||
var sidebarExpandOnHover = localStorage.getItem('sidebarExpandOnHover');
|
||||
if (sidebarExpandOnHover == '1') {
|
||||
$("[data-enable='expandOnHover']").trigger("click");
|
||||
}
|
||||
|
||||
$.each(my_skins, function (i, j) {
|
||||
if ($("body").hasClass(j)) {
|
||||
$(".skin-list li a[data-skin='" + j + "']").parent().addClass("active");
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize();
|
||||
|
||||
},
|
||||
login: function () {
|
||||
var lastlogin = localStorage.getItem("lastlogin");
|
||||
if (lastlogin) {
|
||||
lastlogin = JSON.parse(lastlogin);
|
||||
$("#profile-img").attr("src", Backend.api.cdnurl(lastlogin.avatar));
|
||||
$("#profile-name").val(lastlogin.username);
|
||||
}
|
||||
|
||||
//让错误提示框居中
|
||||
Fast.config.toastr.positionClass = "toast-top-center";
|
||||
|
||||
//本地验证未通过时提示
|
||||
$("#login-form").data("validator-options", {
|
||||
invalid: function (form, errors) {
|
||||
$.each(errors, function (i, j) {
|
||||
Toastr.error(j);
|
||||
});
|
||||
},
|
||||
target: '#errtips'
|
||||
});
|
||||
|
||||
//为表单绑定事件
|
||||
Form.api.bindevent($("#login-form"), function (data) {
|
||||
localStorage.setItem("lastlogin", JSON.stringify({
|
||||
id: data.id,
|
||||
username: data.username,
|
||||
avatar: data.avatar
|
||||
}));
|
||||
location.href = Backend.api.fixurl(data.url);
|
||||
}, function (data) {
|
||||
$("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return Controller;
|
||||
});
|
||||
114
public/assets/js/backend/user/group.js
Normal file
114
public/assets/js/backend/user/group.js
Normal file
@@ -0,0 +1,114 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) {
|
||||
//读取选中的条目
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/group/index',
|
||||
add_url: 'user/group/add',
|
||||
edit_url: 'user/group/edit',
|
||||
del_url: 'user/group/del',
|
||||
multi_url: 'user/group/multi',
|
||||
table: 'user_group',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'name', title: __('Name')},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"), null, null, function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[rules]']").val(r.join(','));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
Controller.api.rendertree(nodeData);
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
130
public/assets/js/backend/user/rule.js
Normal file
130
public/assets/js/backend/user/rule.js
Normal file
@@ -0,0 +1,130 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/rule/index',
|
||||
add_url: 'user/rule/add',
|
||||
edit_url: 'user/rule/edit',
|
||||
del_url: 'user/rule/del',
|
||||
multi_url: 'user/rule/multi',
|
||||
table: 'user_rule',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'weigh',
|
||||
escape: true,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'pid', title: __('Pid'), visible: false},
|
||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
||||
{field: 'remark', title: __('Remark')},
|
||||
// {field: 'ismenu', title: __('Ismenu'), formatter: Table.api.formatter.toggle},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
||||
{field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: false,
|
||||
commonSearch: false,
|
||||
rowAttributes: function (row, index) {
|
||||
return row.pid == 0 ? {} : {style: "display:none"};
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
//显示隐藏子节点
|
||||
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||
var status = $(this).data("shown") ? true : false;
|
||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||
$(this).closest("tr").toggle(!status);
|
||||
});
|
||||
if (status) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$(this).data("shown", !status);
|
||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
//隐藏子节点
|
||||
$(document).on("collapse", ".btn-node-sub", function () {
|
||||
if ($("i", this).length > 0) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
$(this).data("shown", false);
|
||||
$(this).closest("tr").toggle(false);
|
||||
});
|
||||
|
||||
//展开隐藏一级
|
||||
$(document.body).on("click", ".btn-toggle", function (e) {
|
||||
$("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-chevron-down");
|
||||
$("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
|
||||
$("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
|
||||
$(".btn-node-sub[data-pid=0]").data("shown", show);
|
||||
});
|
||||
|
||||
//展开隐藏全部
|
||||
$(document.body).on("click", ".btn-toggle-all", function (e) {
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-plus");
|
||||
$("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
|
||||
$(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
|
||||
$(".btn-node-sub").data("shown", show);
|
||||
$(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
value = value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : '';
|
||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||
|
||||
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||
},
|
||||
name: function (value, row, index) {
|
||||
return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
},
|
||||
},
|
||||
bindevent: function () {
|
||||
$(document).on('click', "input[name='row[ismenu]']", function () {
|
||||
var name = $("input[name='row[name]']");
|
||||
name.prop("placeholder", $(this).val() == 1 ? name.data("placeholder-menu") : name.data("placeholder-node"));
|
||||
});
|
||||
$("input[name='row[ismenu]']:checked").trigger("click");
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
67
public/assets/js/backend/user/user.js
Normal file
67
public/assets/js/backend/user/user.js
Normal file
@@ -0,0 +1,67 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/user/index',
|
||||
add_url: 'user/user/add',
|
||||
edit_url: 'user/user/edit',
|
||||
del_url: 'user/user/del',
|
||||
multi_url: 'user/user/multi',
|
||||
table: 'user',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'user.id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id'), sortable: true},
|
||||
{field: 'group.name', title: __('Group')},
|
||||
{field: 'username', title: __('Username'), operate: 'LIKE'},
|
||||
{field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
|
||||
{field: 'email', title: __('Email'), operate: 'LIKE'},
|
||||
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
|
||||
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
|
||||
{field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
|
||||
{field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}},
|
||||
{field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true},
|
||||
{field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true},
|
||||
{field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true},
|
||||
{field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
|
||||
{field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
58
public/assets/js/backend/version.js
Normal file
58
public/assets/js/backend/version.js
Normal file
@@ -0,0 +1,58 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'version/index',
|
||||
add_url: 'version/add',
|
||||
edit_url: 'version/edit',
|
||||
del_url: 'version/del',
|
||||
multi_url: 'version/multi',
|
||||
table: 'version',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'weigh',
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'oldversion', title: __('Oldversion')},
|
||||
{field: 'newversion', title: __('Newversion')},
|
||||
{field: 'packagesize', title: __('Packagesize')},
|
||||
{field: 'content', title: __('Content'), formatter: Table.api.formatter.content},
|
||||
{field: 'downloadurl', title: __('Downloadurl'), formatter: Table.api.formatter.url},
|
||||
{field: 'enforce', title: __('Enforce'), searchList: {"1":__('Yes'),"0":__('No')}, table: table, formatter: Table.api.formatter.toggle},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
|
||||
{field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Reference in New Issue
Block a user