将扩展名通过ua暴露;更改js的编码规范

This commit is contained in:
2023-11-28 10:16:27 +08:00
parent b67c75a667
commit a75ff465d0
14 changed files with 136 additions and 132 deletions

View File

@@ -1,10 +1,10 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: '{{controllerUrl}}/index',
add_url: '{{controllerUrl}}/add',
edit_url: '{{controllerUrl}}/edit',
delete_url: '{{controllerUrl}}/delete',
export_url: '{{controllerUrl}}/export',
modify_url: '{{controllerUrl}}/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: '{{controllerUrl}}/index',
addUrl: '{{controllerUrl}}/add',
editUrl: '{{controllerUrl}}/edit',
deleteUrl: '{{controllerUrl}}/delete',
exportUrl: '{{controllerUrl}}/export',
modifyUrl: '{{controllerUrl}}/modify',
};

View File

@@ -1,13 +1,13 @@
$(function () {
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'debug.log/index',
add_url: 'debug.log/add',
edit_url: 'debug.log/edit',
delete_url: 'debug.log/delete',
export_url: 'debug.log/export',
modify_url: 'debug.log/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'debug.log/index',
addUrl: 'debug.log/add',
editUrl: 'debug.log/edit',
deleteUrl: 'debug.log/delete',
exportUrl: 'debug.log/export',
modifyUrl: 'debug.log/modify',
};
var uidList = [];

View File

@@ -1,10 +1,10 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'mall.cate/index',
add_url: 'mall.cate/add',
edit_url: 'mall.cate/edit',
delete_url: 'mall.cate/delete',
export_url: 'mall.cate/export',
modify_url: 'mall.cate/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'mall.cate/index',
addUrl: 'mall.cate/add',
editUrl: 'mall.cate/edit',
deleteUrl: 'mall.cate/delete',
exportUrl: 'mall.cate/export',
modifyUrl: 'mall.cate/modify',
};

View File

@@ -1,12 +1,12 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'mall.goods/index',
add_url: 'mall.goods/add',
edit_url: 'mall.goods/edit',
delete_url: 'mall.goods/delete',
export_url: 'mall.goods/export',
modify_url: 'mall.goods/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'mall.goods/index',
addUrl: 'mall.goods/add',
editUrl: 'mall.goods/edit',
deleteUrl: 'mall.goods/delete',
exportUrl: 'mall.goods/export',
modifyUrl: 'mall.goods/modify',
stock_url: 'mall.goods/stock',
read_url: 'mall.goods/read',
formFullScreen: true,

View File

@@ -1,10 +1,10 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'mall.tag/index',
add_url: 'mall.tag/add',
edit_url: 'mall.tag/edit',
delete_url: 'mall.tag/delete',
export_url: 'mall.tag/export',
modify_url: 'mall.tag/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'mall.tag/index',
addUrl: 'mall.tag/add',
editUrl: 'mall.tag/edit',
deleteUrl: 'mall.tag/delete',
exportUrl: 'mall.tag/export',
modifyUrl: 'mall.tag/modify',
};

View File

@@ -1,11 +1,11 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'system.admin/index',
add_url: 'system.admin/add',
edit_url: 'system.admin/edit',
delete_url: 'system.admin/delete',
modify_url: 'system.admin/modify',
export_url: 'system.admin/export',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'system.admin/index',
addUrl: 'system.admin/add',
editUrl: 'system.admin/edit',
deleteUrl: 'system.admin/delete',
modifyUrl: 'system.admin/modify',
exportUrl: 'system.admin/export',
password_url: 'system.admin/password',
};

View File

@@ -1,11 +1,11 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'system.auth/index',
add_url: 'system.auth/add',
edit_url: 'system.auth/edit',
delete_url: 'system.auth/delete',
export_url: 'system.auth/export',
modify_url: 'system.auth/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'system.auth/index',
addUrl: 'system.auth/add',
editUrl: 'system.auth/edit',
deleteUrl: 'system.auth/delete',
exportUrl: 'system.auth/export',
modifyUrl: 'system.auth/modify',
authorize_url: 'system.auth/authorize',
};

View File

@@ -4,11 +4,11 @@ iconPickerFa = layui.iconPickerFa,
autocomplete = layui.autocomplete;
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'system.menu/index',
add_url: 'system.menu/add',
delete_url: 'system.menu/delete',
edit_url: 'system.menu/edit',
modify_url: 'system.menu/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'system.menu/index',
addUrl: 'system.menu/add',
deleteUrl: 'system.menu/delete',
editUrl: 'system.menu/edit',
modifyUrl: 'system.menu/modify',
};

View File

@@ -8,9 +8,9 @@ $(function () {
homdPid: 99999999,
treeIdName: 'id',
treePidName: 'pid',
url: ua.url(init.index_url),
elem: init.table_elem,
id: init.table_render_id,
url: ua.url(init.indexUrl),
elem: init.tableElem,
id: init.tableRenderId,
toolbar: '#toolbar',
page: false,
skin: 'line',
@@ -46,7 +46,7 @@ $(function () {
operat: [
[{
text: '添加下级',
url: init.add_url,
url: init.addUrl,
method: 'open',
auth: 'add',
class: 'layui-btn layui-btn-xs layui-btn-normal',
@@ -61,7 +61,7 @@ $(function () {
}, {
text: '编辑',
url: init.edit_url,
url: init.editUrl,
method: 'open',
auth: 'edit',
class: 'layui-btn layui-btn-xs layui-btn-success',
@@ -72,7 +72,7 @@ $(function () {
method: 'none',
auth: 'delete',
class: 'layui-btn layui-btn-xs layui-btn-danger',
extend: 'data-treetable-delete-item="1" data-url="' + init.delete_url + '"',
extend: 'data-treetable-delete-item="1" data-url="' + init.deleteUrl + '"',
data: ['id', 'title'],
_if(data) {
@@ -127,7 +127,7 @@ $(function () {
$('body').on('click', '[data-treetable-delete]', function () {
var tableId = $(this).attr('data-treetable-delete'),
url = $(this).attr('data-url');
tableId = tableId || init.table_render_id;
tableId = tableId || init.tableRenderId;
url = url != undefined ? ua.url(url) : window.location.href;
var checkStatus = table.checkStatus(tableId),
data = checkStatus.data;
@@ -154,9 +154,9 @@ $(function () {
return false;
});
ua.table.listenSwitch({ filter: 'status', url: init.modify_url });
ua.table.listenSwitch({ filter: 'status', url: init.modifyUrl });
ua.table.listenEdit(init, 'currentTable', init.table_render_id, false);
ua.table.listenEdit(init, 'currentTable', init.tableRenderId, false);
ua.listen();
});

View File

@@ -1,9 +1,9 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'system.node/index',
add_url: 'system.node/add',
edit_url: 'system.node/edit',
delete_url: 'system.node/delete',
modify_url: 'system.node/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'system.node/index',
addUrl: 'system.node/add',
editUrl: 'system.node/edit',
deleteUrl: 'system.node/delete',
modifyUrl: 'system.node/modify',
};

View File

@@ -13,7 +13,7 @@ $(function () {
auth: 'refresh',
class: 'layui-btn layui-btn-success layui-btn-sm',
icon: 'fa fa-hourglass',
extend: 'data-table="' + init.table_render_id + '"',
extend: 'data-table="' + init.tableRenderId + '"',
}, {
text: '强制更新节点',
title: '该操作会覆盖已存在的节点信息。<br>确定强制更新节点?',
@@ -22,7 +22,7 @@ $(function () {
auth: 'refresh',
class: 'layui-btn layui-btn-sm layui-btn-normal',
icon: 'fa fa-hourglass',
extend: 'data-table="' + init.table_render_id + '"',
extend: 'data-table="' + init.tableRenderId + '"',
}, {
text: '清除失效节点',
@@ -32,7 +32,7 @@ $(function () {
auth: 'clear',
class: 'layui-btn layui-btn-sm layui-btn-danger',
icon: 'fa fa-trash-o',
extend: 'data-table="' + init.table_render_id + '"',
extend: 'data-table="' + init.tableRenderId + '"',
}
]],
cols: [[

View File

@@ -2,12 +2,12 @@ var iconPickerFa = layui.iconPickerFa,
autocomplete = layui.autocomplete;
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'system.quick/index',
add_url: 'system.quick/add',
edit_url: 'system.quick/edit',
delete_url: 'system.quick/delete',
export_url: 'system.quick/export',
modify_url: 'system.quick/modify',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'system.quick/index',
addUrl: 'system.quick/add',
editUrl: 'system.quick/edit',
deleteUrl: 'system.quick/delete',
exportUrl: 'system.quick/export',
modifyUrl: 'system.quick/modify',
};

View File

@@ -1,10 +1,10 @@
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'system.uploadfile/index',
add_url: 'system.uploadfile/add',
edit_url: 'system.uploadfile/edit',
delete_url: 'system.uploadfile/delete',
modify_url: 'system.uploadfile/modify',
export_url: 'system.uploadfile/export',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
indexUrl: 'system.uploadfile/index',
addUrl: 'system.uploadfile/add',
editUrl: 'system.uploadfile/edit',
deleteUrl: 'system.uploadfile/delete',
modifyUrl: 'system.uploadfile/modify',
exportUrl: 'system.uploadfile/export',
};

View File

@@ -30,10 +30,11 @@
});
var init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
upload_url: 'ajax/upload',
upload_exts: '',
tableElem: '#currentTable',
tableRenderId: 'currentTableRenderId',
uploadUrl: 'ajax/upload',
uploadExts: '',
extGroup:{}
};
var table;
@@ -78,12 +79,15 @@
}
}
init.upload_exts += allExtGroup.join('|');
extGroup['office'] = [].concat(extGroup['word'], extGroup['excel'], extGroup['ppt'], extGroup['pdf']);
extGroup['media'] = [].concat(extGroup['image'], extGroup['music'], extGroup['video']);
init.uploadExts += allExtGroup.join('|');
init.extGroup = extGroup;
var admin = {
init: init,
config: {
shade: [0.02, '#000'],
},
@@ -256,11 +260,11 @@
render: function (options) {
options.init = options.init || init;
options.modifyReload = admin.parame(options.modifyReload, true);
options.elem = options.elem || options.init.table_elem;
options.id = options.id || options.init.table_render_id;
options.elem = options.elem || options.init.tableElem;
options.id = options.id || options.init.tableRenderId;
options.scrollPos = options.scrollPos || 'fixed';
options.layFilter = options.id + '_LayFilter';
options.url = options.url || admin.url(options.init.index_url);
options.url = options.url || admin.url(options.init.indexUrl);
options.headers = admin.headers();
options.page = admin.parame(options.page, true);
options.search = admin.parame(options.search, true);
@@ -437,15 +441,15 @@
toolbarHtml += ' <button class="layui-btn layui-btn-sm layuimini-btn-primary" data-table-refresh="' + tableId + '"><i class="fa fa-refresh"></i> </button>\n';
} else if (v === 'add') {
if (admin.checkAuth('add', elem)) {
toolbarHtml += '<button class="layui-btn layui-btn-normal layui-btn-sm" data-open="' + init.add_url + '" data-title="添加" data-full="' + init.formFullScreen + '"><i class="fa fa-plus"></i> 添加</button>\n';
toolbarHtml += '<button class="layui-btn layui-btn-normal layui-btn-sm" data-open="' + init.addUrl + '" data-title="添加" data-full="' + init.formFullScreen + '"><i class="fa fa-plus"></i> 添加</button>\n';
}
} else if (v === 'delete') {
if (admin.checkAuth('delete', elem)) {
toolbarHtml += '<button class="layui-btn layui-btn-sm layui-btn-danger" data-url="' + init.delete_url + '" data-table-delete="' + tableId + '"><i class="fa fa-trash-o"></i> 删除</button>\n';
toolbarHtml += '<button class="layui-btn layui-btn-sm layui-btn-danger" data-url="' + init.deleteUrl + '" data-table-delete="' + tableId + '"><i class="fa fa-trash-o"></i> 删除</button>\n';
}
} else if (v === 'export') {
if (admin.checkAuth('export', elem)) {
toolbarHtml += '<button class="layui-btn layui-btn-sm layui-btn-success easyadmin-export-btn" data-url="' + init.export_url + '" data-table-export="' + tableId + '"><i class="fa fa-file-excel-o"></i> 导出</button>\n';
toolbarHtml += '<button class="layui-btn layui-btn-sm layui-btn-success easyadmin-export-btn" data-url="' + init.exportUrl + '" data-table-export="' + tableId + '"><i class="fa fa-file-excel-o"></i> 导出</button>\n';
}
} else if (v === 'selectConfirm') {
toolbarHtml += '<button class="layui-btn layui-btn-sm layui-btn-success select-confirm" data-table-target="' + tableId + '"> 确定选择</button>\n';
@@ -633,14 +637,14 @@
return options;
},
renderSwitch: function (cols, tableInit, tableId, modifyReload) {
tableInit.modify_url = tableInit.modify_url || false;
tableInit.modifyUrl = tableInit.modifyUrl || false;
cols = cols[0] || {};
tableId = tableId || init.table_render_id;
tableId = tableId || init.tableRenderId;
if (cols.length > 0) {
$.each(cols, function (i, v) {
v.filter = v.filter || false;
if (v.filter !== false && tableInit.modify_url !== false) {
admin.table.listenSwitch({ filter: v.filter, url: tableInit.modify_url, tableId: tableId, modifyReload: modifyReload });
if (v.filter !== false && tableInit.modifyUrl !== false) {
admin.table.listenSwitch({ filter: v.filter, url: tableInit.modifyUrl, tableId: tableId, modifyReload: modifyReload });
}
});
}
@@ -926,7 +930,7 @@
tool: function (data) {
var option = data.LAY_COL;
option.operat = option.operat || ['edit', 'delete'];
var elem = option.init.table_elem || init.table_elem;
var elem = option.init.tableElem || init.tableElem;
var html = '';
$.each(option.operat, function (i, item) {
if (typeof item === 'string') {
@@ -940,7 +944,7 @@
text: '编辑',
title: '编辑信息',
auth: 'edit',
url: option.init.edit_url,
url: option.init.editUrl,
extend: option.init.formFullScreen == 'true' ? ' data-full="true"' : ''
};
operat.url = admin.table.toolSpliceUrl(operat.url, operat.field, data);
@@ -957,7 +961,7 @@
text: '删除',
title: '确定删除?',
auth: 'delete',
url: option.init.delete_url,
url: option.init.deleteUrl,
extend: ""
};
operat.url = admin.table.toolSpliceUrl(operat.url, operat.field, data);
@@ -1114,7 +1118,7 @@
switch: function (data) {
var option = data.LAY_COL;
if (!admin.checkAuth('modify', option.init.table_elem)) {
if (!admin.checkAuth('modify', option.init.tableElem)) {
return admin.table.list(data);
}
@@ -1230,7 +1234,7 @@
option.filter = option.filter || '';
option.url = option.url || '';
option.field = option.field || option.filter || '';
option.tableId = option.tableId || init.table_render_id;
option.tableId = option.tableId || init.tableRenderId;
option.modifyReload = option.modifyReload || false;
form.on('switch(' + option.filter + ')', function (obj) {
var checked = obj.elem.checked ? 1 : 0;
@@ -1298,9 +1302,9 @@
});
},
listenEdit: function (tableInit, layFilter, tableId, modifyReload) {
tableInit.modify_url = tableInit.modify_url || false;
tableId = tableId || init.table_render_id;
if (tableInit.modify_url !== false) {
tableInit.modifyUrl = tableInit.modifyUrl || false;
tableId = tableId || init.tableRenderId;
if (tableInit.modifyUrl !== false) {
table.on('edit(' + layFilter + ')', function (obj) {
var value = obj.value,
data = obj.data,
@@ -1312,7 +1316,7 @@
value: value,
};
admin.request.post({
url: tableInit.modify_url,
url: tableInit.modifyUrl,
prefix: true,
data: _data,
}, function (res) {
@@ -1547,7 +1551,7 @@
tableId = $(this).attr('data-table');
if (checkbox === 'true') {
tableId = tableId || init.table_render_id;
tableId = tableId || init.tableRenderId;
var checkStatus = table.checkStatus(tableId),
data = checkStatus.data;
if (data.length <= 0) {
@@ -1658,7 +1662,7 @@
$('body').on('click', '[data-table-refresh]', function () {
var tableId = $(this).attr('data-table-refresh');
if (tableId === undefined || tableId === '' || tableId == null) {
tableId = init.table_render_id;
tableId = init.tableRenderId;
}
table.reloadData(tableId);
});
@@ -1667,7 +1671,7 @@
$('body').on('click', '[data-table-reset]', function () {
var tableId = $(this).attr('data-table-reset');
if (tableId === undefined || tableId === '' || tableId == null) {
tableId = init.table_render_id;
tableId = init.tableRenderId;
}
var where = {
filter: '{}',
@@ -1702,7 +1706,7 @@
var postData = {};
if (checkbox === 'true') {
tableId = tableId || init.table_render_id;
tableId = tableId || init.tableRenderId;
var checkStatus = table.checkStatus(tableId),
data = checkStatus.data;
if (data.length <= 0) {
@@ -1725,7 +1729,7 @@
}, function (res) {
admin.msg.success(res.msg, function () {
if (endMethod == 'reload-table') {
tableId = tableId || init.table_render_id;
tableId = tableId || init.tableRenderId;
table.reloadData(tableId);
} else if (endMethod == 'refresh-page') {
location.reload();
@@ -1742,7 +1746,7 @@
$('body').on('click', '[data-table-delete]', function () {
var tableId = $(this).attr('data-table-delete'),
url = $(this).attr('data-url');
tableId = tableId || init.table_render_id;
tableId = tableId || init.tableRenderId;
url = url !== undefined ? admin.url(url) : window.location.href;
var checkStatus = table.checkStatus(tableId),
data = checkStatus.data;
@@ -1800,7 +1804,7 @@
option.refreshTable = option.refreshTable || false;
option.refreshFrame = option.refreshFrame || false;
if (option.refreshTable === true) {
option.refreshTable = init.table_render_id;
option.refreshTable = init.tableRenderId;
}
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
@@ -2016,7 +2020,7 @@
var elemFilenameField = "input[name='" + uploadFilenameField + "']";
}
if (uploadExts == '*') {
uploadExts = init.upload_exts;
uploadExts = init.uploadExts;
} else if (uploadExts.charAt(0) == '*') {
var extGroupName = uploadExts.slice(1);
if (extGroup[extGroupName]) {
@@ -2027,7 +2031,7 @@
// 监听上传事件
upload.render({
elem: this,
url: admin.url(init.upload_url),
url: admin.url(init.uploadUrl),
exts: uploadExts,
accept: uploadAccept,//指定允许上传时校验的文件类型
acceptMime: uploadAcceptMime,//规定打开文件选择框时,筛选出的文件类型