save
This commit is contained in:
parent
14867a1137
commit
b6c914e0ad
@ -106,44 +106,44 @@
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: '/app/admin/account/info',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/account/info",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
form.val('baseInfo', res.data);
|
||||
form.val("baseInfo", res.data);
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(saveBaseInfo)', function(data){
|
||||
form.on("submit(saveBaseInfo)", function(data){
|
||||
$.ajax({
|
||||
url: '/app/admin/account/update',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: "/app/admin/account/update",
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功');
|
||||
return layui.popup.success("操作成功");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
form.on('submit(savePassword)', function(data){
|
||||
form.on("submit(savePassword)", function(data){
|
||||
$.ajax({
|
||||
url: '/app/admin/account/password',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: "/app/admin/account/password",
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功');
|
||||
return layui.popup.success("操作成功");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
@ -78,8 +78,8 @@
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = 'id';
|
||||
const CONTROLLER = 'plugin\\admin\\app\\controller\\AdminRoleController';
|
||||
const PRIMARY_KEY = "id";
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\AdminRoleController";
|
||||
const SELECT_API = "/app/admin/admin-role/select";
|
||||
const UPDATE_API = "/app/admin/admin-role/update";
|
||||
const DELETE_API = "/app/admin/admin-role/delete";
|
||||
@ -95,7 +95,7 @@
|
||||
})
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -157,16 +157,16 @@
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
layer.photos({photos: "div[lay-id="data-table"]", anim: 5});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取表格中下拉或树形组件数据
|
||||
let apis = [];
|
||||
apis.push(['rules', '/app/admin/admin-rule/get?type=0,1,2']);
|
||||
apis.push(["rules", "/app/admin/admin-rule/get?type=0,1,2"]);
|
||||
let apiResults = {};
|
||||
apiResults['rules'] = [];
|
||||
apiResults["rules"] = [];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
@ -197,45 +197,45 @@
|
||||
}
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -247,9 +247,9 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@ -259,10 +259,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
content: UPDATE_URL + '?' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -275,33 +275,33 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -309,8 +309,8 @@
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -63,8 +63,8 @@
|
||||
el: "#rules",
|
||||
name: "rules",
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
tree: {"show":true},
|
||||
data: e.data,
|
||||
tree: {"show":true},
|
||||
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||
})
|
||||
}
|
||||
@ -72,18 +72,18 @@
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -48,30 +48,30 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/admin-role/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/admin-role/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(['form', 'util'], function () {
|
||||
layui.use(["form", "util"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === 'password') {
|
||||
obj.attr('placeholder', '不更新密码请留空');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.val(layui.util.escape(value));
|
||||
} else {
|
||||
obj.attr('value', value);
|
||||
obj.attr("value", value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -87,8 +87,8 @@
|
||||
el: "#rules",
|
||||
name: "rules",
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
tree: {"show":true},
|
||||
data: e.data,
|
||||
tree: {"show":true},
|
||||
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||
})
|
||||
}
|
||||
@ -101,19 +101,19 @@
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -66,8 +66,8 @@
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = 'id';
|
||||
const CONTROLLER = 'plugin\\admin\\app\\controller\\AdminRuleController';
|
||||
const PRIMARY_KEY = "id";
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\AdminRuleController";
|
||||
const SELECT_API = "/app/admin/admin-rule/select?limit=5000";
|
||||
const DELETE_API = "/app/admin/admin-rule/delete";
|
||||
const UPDATE_API = "/app/admin/admin-rule/update";
|
||||
@ -75,7 +75,7 @@
|
||||
const UPDATE_URL = "/app/admin/admin-rule/update";
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'treetable', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "treetable", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -86,60 +86,60 @@
|
||||
// 表格头部列数据
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox'
|
||||
type: "checkbox"
|
||||
},{
|
||||
title: '标题',
|
||||
field: 'title',
|
||||
title: "标题",
|
||||
field: "title",
|
||||
},{
|
||||
title: '图标',
|
||||
field: 'icon',
|
||||
title: "图标",
|
||||
field: "icon",
|
||||
templet: function (d) {
|
||||
return '<i class="layui-icon ' + util.escape(d['icon']) + '"></i>';
|
||||
return '<i class="layui-icon ' + util.escape(d["icon"]) + '"></i>';
|
||||
}
|
||||
},{
|
||||
title: '主键',
|
||||
field: 'id',
|
||||
title: "主键",
|
||||
field: "id",
|
||||
hide: true,
|
||||
},{
|
||||
title: 'key',
|
||||
field: 'key',
|
||||
title: "key",
|
||||
field: "key",
|
||||
},{
|
||||
title: '上级菜单',
|
||||
field: 'pid',
|
||||
title: "上级菜单",
|
||||
field: "pid",
|
||||
hide: true,
|
||||
templet: function (d) {
|
||||
let field = 'pid';
|
||||
if (typeof d[field] == "undefined") return '';
|
||||
let field = "pid";
|
||||
if (typeof d[field] == "undefined") return "";
|
||||
let items = [];
|
||||
layui.each((d[field] + '').split(','), function (k , v) {
|
||||
layui.each((d[field] + "").split(","), function (k , v) {
|
||||
items.push(apiResults[field][v] || v);
|
||||
});
|
||||
return util.escape(items.join(','));
|
||||
return util.escape(items.join(","));
|
||||
}
|
||||
},{
|
||||
title: '创建时间',
|
||||
field: 'created_at',
|
||||
title: "创建时间",
|
||||
field: "created_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: '更新时间',
|
||||
field: 'updated_at',
|
||||
title: "更新时间",
|
||||
field: "updated_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: 'url',
|
||||
field: 'href',
|
||||
title: "url",
|
||||
field: "href",
|
||||
},{
|
||||
title: '类型',
|
||||
field: 'type',
|
||||
title: "类型",
|
||||
field: "type",
|
||||
width: 80,
|
||||
templet: function (d) {
|
||||
let field = 'type';
|
||||
let value = apiResults['type'][d['type']] || d['type'];
|
||||
let css = {'目录':'layui-bg-blue', '菜单': 'layui-bg-green', '权限': 'layui-bg-orange'}[value];
|
||||
let field = "type";
|
||||
let value = apiResults["type"][d["type"]] || d["type"];
|
||||
let css = {"目录":"layui-bg-blue", "菜单": "layui-bg-green", "权限": "layui-bg-orange"}[value];
|
||||
return '<span class="layui-badge '+css+'">'+util.escape(value)+'</span>';
|
||||
}
|
||||
},{
|
||||
title: '排序',
|
||||
field: 'weight',
|
||||
title: "排序",
|
||||
field: "weight",
|
||||
width: 80,
|
||||
},{
|
||||
title: "操作",
|
||||
@ -154,37 +154,37 @@
|
||||
function render()
|
||||
{
|
||||
treeTable.render({
|
||||
elem: '#data-table',
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
treeColIndex: 1,
|
||||
treeSpid: 0,
|
||||
treeIdName: 'id',
|
||||
treePidName: 'pid',
|
||||
treeIdName: "id",
|
||||
treePidName: "pid",
|
||||
treeDefaultClose: true,
|
||||
cols: [cols],
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
toolbar: '#table-toolbar',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"]
|
||||
});
|
||||
}
|
||||
|
||||
// 获取下拉菜单及树形组件数据
|
||||
let apis = [];
|
||||
let apiResults = {};
|
||||
apiResults['pid'] = [];
|
||||
apis.push(['pid', '/app/admin/admin-rule/select?format=tree&type=0,1']);
|
||||
apiResults['type'] = ["目录","菜单","权限"];
|
||||
apiResults["pid"] = [];
|
||||
apis.push(["pid", "/app/admin/admin-rule/select?format=tree&type=0,1"]);
|
||||
apiResults["type"] = ["目录","菜单","权限"];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
$.ajax({
|
||||
url: url,
|
||||
dateType: 'json',
|
||||
dateType: "json",
|
||||
success: function (res) {
|
||||
function travel(items) {
|
||||
for (let k in items) {
|
||||
@ -209,21 +209,21 @@
|
||||
}
|
||||
|
||||
// 删除或编辑行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 添加 批量删除 刷新事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
@ -232,9 +232,9 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'520px', common.isModile()?'100%':'520px'],
|
||||
area: [common.isModile()?"100%":"520px", common.isModile()?"100%":"520px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@ -244,10 +244,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'520px', common.isModile()?'100%':'520px'],
|
||||
content: UPDATE_URL + '?' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"520px", common.isModile()?"100%":"520px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -260,33 +260,33 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids, obj) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
return obj ? obj.del() : refreshTable();
|
||||
});
|
||||
}
|
||||
@ -296,7 +296,7 @@
|
||||
|
||||
// 刷新表格
|
||||
window.refreshTable = function(param) {
|
||||
treeTable.reload('#data-table');
|
||||
treeTable.reload("#data-table");
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -87,30 +87,30 @@
|
||||
const INSERT_URL = "/app/admin/admin-rule/insert";
|
||||
|
||||
// 图标选择
|
||||
layui.use(['iconPicker'], function() {
|
||||
layui.use(["iconPicker"], function() {
|
||||
layui.iconPicker.render({
|
||||
elem: '#icon',
|
||||
type: 'fontClass',
|
||||
elem: "#icon",
|
||||
type: "fontClass",
|
||||
page: false,
|
||||
});
|
||||
});
|
||||
|
||||
// 上级菜单
|
||||
layui.use(['jquery', 'xmSelect'], function() {
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
layui.$.ajax({
|
||||
url: '/app/admin/admin-rule/select?format=tree&type=0,1',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/admin-rule/select?format=tree&type=0,1",
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
let value = layui.$('#pid').attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
let value = layui.$("#pid").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: '#pid',
|
||||
name: 'pid',
|
||||
el: "#pid",
|
||||
name: "pid",
|
||||
initValue: initValue,
|
||||
tips: '无',
|
||||
tips: "无",
|
||||
toolbar: {show: true, list: ["CLEAR"]},
|
||||
data: e.data,
|
||||
value: '0',
|
||||
value: "0",
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
@ -121,15 +121,15 @@
|
||||
});
|
||||
|
||||
// 菜单类型下拉列表
|
||||
layui.use(['jquery', 'xmSelect'], function() {
|
||||
let value = layui.$('#type').attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
let value = layui.$("#type").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: '#type',
|
||||
name: 'type',
|
||||
el: "#type",
|
||||
name: "type",
|
||||
initValue: initValue,
|
||||
data: [{"value":"0","name":"目录"},{"value":"1","name":"菜单"},{"value":"2","name":"权限"}],
|
||||
value: '1',
|
||||
value: "1",
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
@ -137,18 +137,18 @@
|
||||
});
|
||||
|
||||
// 表单提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_URL,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -83,55 +83,55 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
let PRIMARY_KEY = 'id';
|
||||
let PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/admin-rule/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/admin-rule/update";
|
||||
|
||||
// 获取行数据
|
||||
layui.use(['form', 'util'], function () {
|
||||
layui.use(["form", "util"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
|
||||
// 赋值表单
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === 'password') {
|
||||
obj.attr('placeholder', '不更新密码请留空');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.html(layui.util.escape(value));
|
||||
} else {
|
||||
obj.attr('value', value);
|
||||
obj.attr("value", value);
|
||||
}
|
||||
});
|
||||
|
||||
// 图标选择
|
||||
layui.use(['iconPicker'], function() {
|
||||
layui.use(["iconPicker"], function() {
|
||||
layui.iconPicker.render({
|
||||
elem: '#icon',
|
||||
type: 'fontClass',
|
||||
elem: "#icon",
|
||||
type: "fontClass",
|
||||
page: false,
|
||||
});
|
||||
});
|
||||
|
||||
// 获取上级菜单
|
||||
layui.use(['jquery', 'xmSelect'], function() {
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
layui.$.ajax({
|
||||
url: '/app/admin/admin-rule/select?format=tree&type=0,1',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/admin-rule/select?format=tree&type=0,1",
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
let value = layui.$('#pid').attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
let value = layui.$("#pid").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: '#pid',
|
||||
name: 'pid',
|
||||
el: "#pid",
|
||||
name: "pid",
|
||||
initValue: initValue,
|
||||
tips: '无',
|
||||
tips: "无",
|
||||
toolbar: {show: true, list: ["CLEAR"]},
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
@ -144,12 +144,12 @@
|
||||
});
|
||||
|
||||
// 菜单类型下拉选择
|
||||
layui.use(['jquery', 'xmSelect'], function() {
|
||||
let value = layui.$('#type').attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
let value = layui.$("#type").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: '#type',
|
||||
name: 'type',
|
||||
el: "#type",
|
||||
name: "type",
|
||||
initValue: initValue,
|
||||
data: [{"value":"0","name":"目录"},{"value":"1","name":"菜单"},{"value":"2","name":"权限"}],
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
@ -164,19 +164,19 @@
|
||||
});
|
||||
|
||||
// 提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -99,8 +99,8 @@
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = 'id';
|
||||
const CONTROLLER = 'plugin\\admin\\app\\controller\\AdminController';
|
||||
const PRIMARY_KEY = "id";
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\AdminController";
|
||||
const SELECT_API = "/app/admin/admin/select";
|
||||
const UPDATE_API = "/app/admin/admin/update";
|
||||
const DELETE_API = "/app/admin/admin/delete";
|
||||
@ -116,7 +116,7 @@
|
||||
})
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -205,9 +205,9 @@
|
||||
|
||||
// 获取表格中下拉或树形组件数据
|
||||
let apis = [];
|
||||
apis.push(['roles', '/app/admin/admin-role/select?format=select']);
|
||||
apis.push(["roles", "/app/admin/admin-role/select?format=select"]);
|
||||
let apiResults = {};
|
||||
apiResults['roles'] = [];
|
||||
apiResults["roles"] = [];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
@ -238,45 +238,45 @@
|
||||
}
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -288,9 +288,9 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@ -300,10 +300,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
content: UPDATE_URL + '?' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -316,33 +316,33 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -350,8 +350,8 @@
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -97,7 +97,7 @@
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on('click', function() {
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
@ -112,10 +112,10 @@
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
url: '/app/admin/upload/avatar',
|
||||
value: '/app/admin/avatar.png',
|
||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||
field: '__file__',
|
||||
url: "/app/admin/upload/avatar",
|
||||
value: "/app/admin/avatar.png",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
@ -144,18 +144,18 @@
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -90,30 +90,30 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/admin/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/admin/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(['form', 'util'], function () {
|
||||
layui.use(["form", "util"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === 'password') {
|
||||
obj.attr('placeholder', '不更新密码请留空');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.val(layui.util.escape(value));
|
||||
} else {
|
||||
obj.attr('value', value);
|
||||
obj.attr("value", value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on('click', function() {
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
@ -136,9 +136,9 @@
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
url: '/app/admin/upload/avatar',
|
||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||
field: '__file__',
|
||||
url: "/app/admin/upload/avatar",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
@ -172,19 +172,19 @@
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -185,37 +185,37 @@
|
||||
<script>
|
||||
|
||||
// 基础设置
|
||||
layui.use(['upload', 'layer', 'popup'], function() {
|
||||
layui.use(["upload", "layer", "popup"], function() {
|
||||
let $ = layui.$;
|
||||
let form = layui.form;
|
||||
|
||||
// image
|
||||
let input = $('#image').prev();
|
||||
input.prev().attr('src', input.val());
|
||||
let input = $("#image").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.upload.render({
|
||||
elem: '#image',
|
||||
url: '/app/admin/upload/avatar',
|
||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||
elem: "#image",
|
||||
url: "/app/admin/upload/avatar",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
done: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
this.item.prev().val(res.data.url).prev().attr('src', res.data.url);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
}
|
||||
});
|
||||
|
||||
// 提交
|
||||
form.on('submit(saveBaseInfo)', function(data){
|
||||
form.on("submit(saveBaseInfo)", function(data){
|
||||
$.ajax({
|
||||
url: '/app/admin/config/update',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: "/app/admin/config/update",
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
data: {logo: data.field},
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功');
|
||||
return layui.popup.success("操作成功");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
@ -224,21 +224,21 @@
|
||||
|
||||
|
||||
// 菜单设置
|
||||
layui.use(['upload', 'layer', 'popup'], function() {
|
||||
layui.use(["upload", "layer", "popup"], function() {
|
||||
let $ = layui.$;
|
||||
let form = layui.form;
|
||||
// 提交
|
||||
form.on('submit(saveMenuInfo)', function(data){
|
||||
form.on("submit(saveMenuInfo)", function(data){
|
||||
$.ajax({
|
||||
url: '/app/admin/config/update',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: "/app/admin/config/update",
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
data: {menu: data.field},
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功');
|
||||
return layui.popup.success("操作成功");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
@ -246,11 +246,11 @@
|
||||
});
|
||||
|
||||
// 标签设置
|
||||
layui.use(['upload', 'layer', 'popup'], function() {
|
||||
layui.use(["upload", "layer", "popup"], function() {
|
||||
let $ = layui.$;
|
||||
let form = layui.form;
|
||||
// 提交
|
||||
form.on('submit(saveTabInfo)', function(data){
|
||||
form.on("submit(saveTabInfo)", function(data){
|
||||
let field = data.field;
|
||||
field.index = {
|
||||
id: field.id,
|
||||
@ -259,38 +259,38 @@
|
||||
};
|
||||
delete data.field;
|
||||
$.ajax({
|
||||
url: '/app/admin/config/update',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: "/app/admin/config/update",
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
data: {tab: field},
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功');
|
||||
return layui.popup.success("操作成功");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
layui.use(['form'], function () {
|
||||
layui.use(["form"], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: '/app/admin/config/get',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/config/get",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
form.val('baseInfo', res.logo);
|
||||
$('#image').prev().val(res.logo.image).prev().attr('src', res.logo.image);
|
||||
form.val('menuInfo', res.menu);
|
||||
form.val("baseInfo", res.logo);
|
||||
$("#image").prev().val(res.logo.image).prev().attr("src", res.logo.image);
|
||||
form.val("menuInfo", res.menu);
|
||||
let tab = res.tab;
|
||||
let index = tab.index;
|
||||
delete tab.index;
|
||||
tab.id = index.id;
|
||||
tab.title = index.title;
|
||||
tab.href= index.href;
|
||||
form.val('tabInfo', res.tab);
|
||||
form.val("tabInfo", res.tab);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -107,6 +107,6 @@
|
||||
<script src="/app/admin/component/layui/layui.js"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use('design');
|
||||
layui.use("design");
|
||||
</script>
|
||||
</html>
|
||||
|
@ -67,7 +67,7 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const CONTROLLER = 'plugin\\admin\\app\\controller\\DictController';
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\DictController";
|
||||
const SELECT_API = "/app/admin/dict/select";
|
||||
const UPDATE_API = "/app/admin/dict/update";
|
||||
const DELETE_API = "/app/admin/dict/delete";
|
||||
@ -75,7 +75,7 @@
|
||||
const UPDATE_URL = "/app/admin/dict/update";
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -134,45 +134,45 @@
|
||||
render();
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -184,61 +184,61 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'500px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"500px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
|
||||
// 表格编辑数据
|
||||
let edit = function(obj) {
|
||||
let value = obj.data['name'];
|
||||
let value = obj.data["name"];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'500px'],
|
||||
content: UPDATE_URL + '?name=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"500px"],
|
||||
content: UPDATE_URL + "?name=" + value
|
||||
});
|
||||
}
|
||||
|
||||
// 删除一行
|
||||
let remove = function(obj) {
|
||||
return doRemove(obj.data['name']);
|
||||
return doRemove(obj.data["name"]);
|
||||
}
|
||||
|
||||
// 删除多行
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, 'name');
|
||||
let checkIds = common.checkField(obj, "name");
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data['name'] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
data["name"] = ids;
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -246,8 +246,8 @@
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -94,99 +94,99 @@
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
|
||||
const INSERT_API = '/app/admin/dict/insert';
|
||||
const INSERT_API = "/app/admin/dict/insert";
|
||||
|
||||
// 字段设置
|
||||
layui.use(['table', 'common', 'popup'], function () {
|
||||
layui.use(["table", "common", "popup"], function () {
|
||||
|
||||
let table = layui.table;
|
||||
let common = layui.common;
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
type: "checkbox",
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
field: 'value',
|
||||
templet: '#col-value'
|
||||
title: "值",
|
||||
field: "value",
|
||||
templet: "#col-value"
|
||||
},
|
||||
{
|
||||
title: '标题',
|
||||
field: 'name',
|
||||
templet: '#col-name',
|
||||
title: "标题",
|
||||
field: "name",
|
||||
templet: "#col-name",
|
||||
}
|
||||
];
|
||||
|
||||
window._field_id = 0;
|
||||
let data = [{
|
||||
_field_id: _field_id++,
|
||||
value : '',
|
||||
name: '',
|
||||
value : "",
|
||||
name: "",
|
||||
}];
|
||||
|
||||
table.render({
|
||||
elem: '#column-table',
|
||||
elem: "#column-table",
|
||||
cols: [cols],
|
||||
data: data,
|
||||
cellMinWidth: 40,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
toolbar: '#column-toolbar',
|
||||
toolbar: "#column-toolbar",
|
||||
defaultToolbar: [],
|
||||
});
|
||||
|
||||
table.on('toolbar(column-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(column-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
syncTableData();
|
||||
let options = table.getData('column-table');
|
||||
let options = table.getData("column-table");
|
||||
options.push({
|
||||
_field_id: _field_id++,
|
||||
value : '',
|
||||
name: '',
|
||||
value : "",
|
||||
name: "",
|
||||
});
|
||||
table.reloadData('column-table', {data:options});
|
||||
table.reloadData("column-table", {data:options});
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj,'_field_id');
|
||||
if (checkIds === "") return layui.popup.warning('未选中数据');
|
||||
let data = table.getData('column-table');
|
||||
var checkIds = common.checkField(obj,"_field_id");
|
||||
if (checkIds === "") return layui.popup.warning("未选中数据");
|
||||
let data = table.getData("column-table");
|
||||
let newData = [];
|
||||
let deleteIds = checkIds.split(',');
|
||||
let deleteIds = checkIds.split(",");
|
||||
layui.each(data, function (index, item) {
|
||||
if (deleteIds.indexOf(item._field_id + '') === -1) {
|
||||
if (deleteIds.indexOf(item._field_id + "") === -1) {
|
||||
newData.push(item);
|
||||
}
|
||||
});
|
||||
table.reloadData('column-table', {data: newData})
|
||||
table.reloadData("column-table", {data: newData})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function () {
|
||||
let data = layui.form.val('create-dict-form');
|
||||
layui.form.on("submit(save)", function () {
|
||||
let data = layui.form.val("create-dict-form");
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
@ -197,24 +197,24 @@
|
||||
});
|
||||
|
||||
window.syncTableData = function () {
|
||||
let tableData = layui.form.val('create-dict-form');
|
||||
let tableData = layui.form.val("create-dict-form");
|
||||
let columnTableData = [];
|
||||
let len = Object.keys(tableData).length;
|
||||
let id = 0;
|
||||
window._key_id = 0;
|
||||
while (id < len) {
|
||||
// column data
|
||||
if (typeof tableData['value[' + id + '][_field_id]'] !== 'undefined') {
|
||||
if (typeof tableData["value[" + id + "][_field_id]"] !== "undefined") {
|
||||
columnTableData.push({
|
||||
_field_id: tableData['value[' + id + '][_field_id]'],
|
||||
name : tableData['value[' + id + '][name]'],
|
||||
value: tableData['value[' + id + '][value]'],
|
||||
_field_id: tableData["value[" + id + "][_field_id]"],
|
||||
name : tableData["value[" + id + "][name]"],
|
||||
value: tableData["value[" + id + "][value]"],
|
||||
});
|
||||
}
|
||||
_key_id++;
|
||||
id++;
|
||||
}
|
||||
layui.table.reloadData('column-table', {data: columnTableData});
|
||||
layui.table.reloadData("column-table", {data: columnTableData});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -95,29 +95,29 @@
|
||||
<script>
|
||||
|
||||
const DICT_NAME = layui.url().search.name;
|
||||
const UPDATE_API = '/app/admin/dict/update';
|
||||
const SELECT_API = '/app/admin/dict/get/' + DICT_NAME;
|
||||
const UPDATE_API = "/app/admin/dict/update";
|
||||
const SELECT_API = "/app/admin/dict/get/" + DICT_NAME;
|
||||
|
||||
// 字段设置
|
||||
layui.use(['table', 'common', 'popup'], function () {
|
||||
layui.use(["table", "common", "popup"], function () {
|
||||
|
||||
let table = layui.table;
|
||||
let common = layui.common;
|
||||
let $ = layui.$;
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
type: "checkbox",
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
field: 'value',
|
||||
templet: '#col-value'
|
||||
title: "值",
|
||||
field: "value",
|
||||
templet: "#col-value"
|
||||
},
|
||||
{
|
||||
title: '标题',
|
||||
field: 'name',
|
||||
templet: '#col-name',
|
||||
title: "标题",
|
||||
field: "name",
|
||||
templet: "#col-name",
|
||||
}
|
||||
];
|
||||
|
||||
@ -127,78 +127,78 @@
|
||||
let data = [];
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (res) {
|
||||
data = res.data;
|
||||
layui.each(data, function (k, v) {
|
||||
data[k]['_field_id'] = _field_id++;
|
||||
data[k]["_field_id"] = _field_id++;
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
table.render({
|
||||
elem: '#column-table',
|
||||
elem: "#column-table",
|
||||
cols: [cols],
|
||||
data: data,
|
||||
cellMinWidth: 40,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
toolbar: '#column-toolbar',
|
||||
toolbar: "#column-toolbar",
|
||||
defaultToolbar: [],
|
||||
});
|
||||
|
||||
table.on('toolbar(column-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(column-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
syncTableData();
|
||||
let options = table.getData('column-table');
|
||||
let options = table.getData("column-table");
|
||||
options.push({
|
||||
_field_id: _field_id++,
|
||||
value : '',
|
||||
name: '',
|
||||
value : "",
|
||||
name: "",
|
||||
});
|
||||
table.reloadData('column-table', {data:options});
|
||||
table.reloadData("column-table", {data:options});
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj,'_field_id');
|
||||
if (checkIds === "") return layui.popup.warning('未选中数据');
|
||||
let data = table.getData('column-table');
|
||||
var checkIds = common.checkField(obj,"_field_id");
|
||||
if (checkIds === "") return layui.popup.warning("未选中数据");
|
||||
let data = table.getData("column-table");
|
||||
let newData = [];
|
||||
let deleteIds = checkIds.split(',');
|
||||
let deleteIds = checkIds.split(",");
|
||||
layui.each(data, function (index, item) {
|
||||
if (deleteIds.indexOf(item._field_id + '') === -1) {
|
||||
if (deleteIds.indexOf(item._field_id + "") === -1) {
|
||||
newData.push(item);
|
||||
}
|
||||
});
|
||||
table.reloadData('column-table', {data: newData})
|
||||
table.reloadData("column-table", {data: newData})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function () {
|
||||
let data = layui.form.val('create-dict-form');
|
||||
layui.form.on("submit(save)", function () {
|
||||
let data = layui.form.val("create-dict-form");
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
@ -209,24 +209,24 @@
|
||||
});
|
||||
|
||||
window.syncTableData = function () {
|
||||
let tableData = layui.form.val('create-dict-form');
|
||||
let tableData = layui.form.val("create-dict-form");
|
||||
let columnTableData = [];
|
||||
let len = Object.keys(tableData).length;
|
||||
let id = 0;
|
||||
window._key_id = 0;
|
||||
while (id < len) {
|
||||
// column data
|
||||
if (typeof tableData['value[' + id + '][_field_id]'] !== 'undefined') {
|
||||
if (typeof tableData["value[" + id + "][_field_id]"] !== "undefined") {
|
||||
columnTableData.push({
|
||||
_field_id: tableData['value[' + id + '][_field_id]'],
|
||||
name : tableData['value[' + id + '][name]'],
|
||||
value: tableData['value[' + id + '][value]'],
|
||||
_field_id: tableData["value[" + id + "][_field_id]"],
|
||||
name : tableData["value[" + id + "][name]"],
|
||||
value: tableData["value[" + id + "][value]"],
|
||||
});
|
||||
}
|
||||
_key_id++;
|
||||
id++;
|
||||
}
|
||||
layui.table.reloadData('column-table', {data: columnTableData});
|
||||
layui.table.reloadData("column-table", {data: columnTableData});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -97,7 +97,7 @@
|
||||
<script src="component/pear/pear.js"></script>
|
||||
<!-- 框 架 初 始 化 -->
|
||||
<script>
|
||||
layui.use(['admin','jquery','popup','drawer'], function() {
|
||||
layui.use(["admin","jquery","popup","drawer"], function() {
|
||||
var $ = layui.$;
|
||||
var admin = layui.admin;
|
||||
var popup = layui.popup;
|
||||
@ -110,8 +110,8 @@
|
||||
// 登出逻辑
|
||||
admin.logout(function(){
|
||||
$.ajax({
|
||||
url: '/app/admin/account/logout',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/account/logout",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return popup.error(res.msg);
|
||||
|
@ -118,7 +118,7 @@
|
||||
<script src="/app/admin/component/layui/layui.js"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'step','code','element', 'popup'], function() {
|
||||
layui.use(["form", "step","code","element", "popup"], function() {
|
||||
var $ = layui.$,
|
||||
form = layui.form,
|
||||
step = layui.step;
|
||||
@ -126,33 +126,33 @@
|
||||
layui.code();
|
||||
|
||||
step.render({
|
||||
elem: '#stepForm',
|
||||
filter: 'stepForm',
|
||||
width: '100%',
|
||||
stepWidth: '70%',
|
||||
height: '500px',
|
||||
elem: "#stepForm",
|
||||
filter: "stepForm",
|
||||
width: "100%",
|
||||
stepWidth: "70%",
|
||||
height: "500px",
|
||||
stepItems: [{
|
||||
title: '填写数据库信息'
|
||||
title: "填写数据库信息"
|
||||
}, {
|
||||
title: '填写管理员账户'
|
||||
title: "填写管理员账户"
|
||||
}, {
|
||||
title: '完成'
|
||||
title: "完成"
|
||||
}]
|
||||
});
|
||||
|
||||
form.on('submit(formStep)', function(data) {
|
||||
form.on("submit(formStep)", function(data) {
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/install/step1',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/install/step1",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
layui.popup.success('操作成功', function () {
|
||||
step.next('#stepForm');
|
||||
layui.popup.success("操作成功", function () {
|
||||
step.next("#stepForm");
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
@ -162,19 +162,19 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
form.on('submit(formStep2)', function(data) {
|
||||
form.on("submit(formStep2)", function(data) {
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/install/step2',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/install/step2",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
//layui.popup.success('安装成功');
|
||||
step.next('#stepForm');
|
||||
//layui.popup.success("安装成功");
|
||||
step.next("#stepForm");
|
||||
layer.close(loading);
|
||||
},
|
||||
complete: function () {
|
||||
@ -184,17 +184,17 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.pre').click(function() {
|
||||
step.pre('#stepForm');
|
||||
$(".pre").click(function() {
|
||||
step.pre("#stepForm");
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.next').click(function() {
|
||||
step.next('#stepForm');
|
||||
$(".next").click(function() {
|
||||
step.next("#stepForm");
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.finish').click(function() {
|
||||
$(".finish").click(function() {
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
|
@ -32,22 +32,22 @@
|
||||
<script src="/app/admin/component/layui/layui.js"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'button', 'popup', 'layer'], function() {
|
||||
layui.use(["form", "button", "popup", "layer"], function() {
|
||||
var $ = layui.$, layer = layui.layer, form = layui.form;
|
||||
function switchCaptcha() {
|
||||
$('.codeImage').attr("src", "/app/admin/plugin/captcha?v=" + new Date().getTime());
|
||||
$(".codeImage").attr("src", "/app/admin/plugin/captcha?v=" + new Date().getTime());
|
||||
}
|
||||
switchCaptcha();
|
||||
form.on('submit(login)', function (data) {
|
||||
form.on("submit(login)", function (data) {
|
||||
layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/plugin/login',
|
||||
url: "/app/admin/plugin/login",
|
||||
type: "POST",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
layer.closeAll('loading');
|
||||
layer.closeAll("loading");
|
||||
if (!res.code) {
|
||||
layui.popup.success('登录成功', function () {
|
||||
layui.popup.success("登录成功", function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
})
|
||||
} else {
|
||||
@ -59,7 +59,7 @@
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('.codeImage').on('click', function () {
|
||||
$(".codeImage").on("click", function () {
|
||||
switchCaptcha();
|
||||
});
|
||||
})
|
||||
|
@ -25,7 +25,7 @@
|
||||
升级
|
||||
</button>
|
||||
{{# } }}
|
||||
{{# if(d.name !== 'admin'){ }}
|
||||
{{# if(d.name !== "admin"){ }}
|
||||
<button class="pear-btn pear-btn-xs pear-btn-danger" onclick="uninstall('{{ d.name }}','{{ d.installed }}')">
|
||||
卸载
|
||||
</button>
|
||||
@ -41,7 +41,7 @@
|
||||
const AUTH_URL = "/app/admin/plugin/login";
|
||||
const SCHEMA_API = "/app/admin/plugin/schema";
|
||||
|
||||
layui.use(['table', 'form','common', 'popup'], function() {
|
||||
layui.use(["table", "form","common", "popup"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -49,29 +49,29 @@
|
||||
|
||||
$.ajax({
|
||||
url: SCHEMA_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
let cols = e.data;
|
||||
layui.each(cols, function (k, v) {
|
||||
if (v.field === 'installed') {
|
||||
cols[k].templet = '#install';
|
||||
if (v.field === "installed") {
|
||||
cols[k].templet = "#install";
|
||||
}
|
||||
})
|
||||
function render()
|
||||
{
|
||||
table.render({
|
||||
elem: '#data-table',
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"]
|
||||
});
|
||||
}
|
||||
render();
|
||||
@ -81,9 +81,9 @@
|
||||
window.install = function(name, version) {
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/plugin/install',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/plugin/install",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {name, version},
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
@ -93,14 +93,14 @@
|
||||
if (res.data && res.data.code === 401) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '登录 workerman.net 官网',
|
||||
title: "登录 workerman.net 官网",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: AUTH_URL
|
||||
});
|
||||
return;
|
||||
}
|
||||
return layui.popup.success('安装成功', function () {
|
||||
return layui.popup.success("安装成功", function () {
|
||||
parent.location.reload();
|
||||
});
|
||||
},
|
||||
@ -111,22 +111,22 @@
|
||||
}
|
||||
|
||||
window.uninstall = function(name, version) {
|
||||
layer.confirm('确定卸载?', {
|
||||
layer.confirm("确定卸载?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/plugin/uninstall',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/plugin/uninstall",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {name, version},
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('卸载成功', function () {
|
||||
return layui.popup.success("卸载成功", function () {
|
||||
parent.location.reload();
|
||||
});
|
||||
},
|
||||
|
@ -97,7 +97,7 @@
|
||||
<script type="text/html" id="col-type">
|
||||
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary"], function (index, item) { }}
|
||||
<option value="{{ item }}" {{ d.type==item?'selected':''}}>{{ item }}</option>
|
||||
<option value="{{ item }}" {{ d.type==item?"selected":""}}>{{ item }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
</script>
|
||||
@ -217,287 +217,287 @@
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
|
||||
const CREATE_API = '/app/admin/table/create';
|
||||
const CREATE_API = "/app/admin/table/create";
|
||||
|
||||
// 字段设置
|
||||
layui.use(['table', 'common', 'popup'], function () {
|
||||
layui.use(["table", "common", "popup"], function () {
|
||||
|
||||
let table = layui.table;
|
||||
let common = layui.common;
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
type: "checkbox",
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '字段名称',
|
||||
field: 'field',
|
||||
templet: '#col-field',
|
||||
title: "字段名称",
|
||||
field: "field",
|
||||
templet: "#col-field",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '字段备注',
|
||||
field: 'comment',
|
||||
templet: '#col-comment',
|
||||
title: "字段备注",
|
||||
field: "comment",
|
||||
templet: "#col-comment",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '长度/值',
|
||||
field: 'length',
|
||||
templet: '#col-length',
|
||||
title: "长度/值",
|
||||
field: "length",
|
||||
templet: "#col-length",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '默认值',
|
||||
field: 'default',
|
||||
templet: '#col-default',
|
||||
title: "默认值",
|
||||
field: "default",
|
||||
templet: "#col-default",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '字段类型',
|
||||
field: 'type',
|
||||
templet: '#col-type',
|
||||
title: "字段类型",
|
||||
field: "type",
|
||||
templet: "#col-type",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '主键',
|
||||
field: 'primary_key',
|
||||
templet: '#col-primary_key',
|
||||
title: "主键",
|
||||
field: "primary_key",
|
||||
templet: "#col-primary_key",
|
||||
width: 50,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '自增',
|
||||
field: 'auto_increment',
|
||||
templet: '#col-auto_increment',
|
||||
title: "自增",
|
||||
field: "auto_increment",
|
||||
templet: "#col-auto_increment",
|
||||
width: 50,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '为空',
|
||||
field: 'nullable',
|
||||
templet: '#col-nullable',
|
||||
title: "为空",
|
||||
field: "nullable",
|
||||
templet: "#col-nullable",
|
||||
width: 50,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
type: 'space'
|
||||
type: "space"
|
||||
}
|
||||
];
|
||||
|
||||
window._field_id = 0;
|
||||
let data = [{
|
||||
_field_id: _field_id++,
|
||||
field : 'id',
|
||||
comment: '主键',
|
||||
field : "id",
|
||||
comment: "主键",
|
||||
length: 11,
|
||||
default: '',
|
||||
type: 'integer',
|
||||
default: "",
|
||||
type: "integer",
|
||||
primary_key: true,
|
||||
auto_increment: true,
|
||||
nullable: false,
|
||||
},{
|
||||
_field_id: _field_id++,
|
||||
field : 'created_at',
|
||||
comment: '创建时间',
|
||||
length: '',
|
||||
default: '',
|
||||
type: 'dateTime',
|
||||
field : "created_at",
|
||||
comment: "创建时间",
|
||||
length: "",
|
||||
default: "",
|
||||
type: "dateTime",
|
||||
primary_key: false,
|
||||
auto_increment: false,
|
||||
nullable: true,
|
||||
},{
|
||||
_field_id: _field_id++,
|
||||
field : 'updated_at',
|
||||
comment: '更新时间',
|
||||
length: '',
|
||||
default: '',
|
||||
type: 'dateTime',
|
||||
field : "updated_at",
|
||||
comment: "更新时间",
|
||||
length: "",
|
||||
default: "",
|
||||
type: "dateTime",
|
||||
primary_key: false,
|
||||
auto_increment: false,
|
||||
nullable: true,
|
||||
},{
|
||||
_field_id: _field_id++,
|
||||
field : '',
|
||||
comment: '',
|
||||
length: '',
|
||||
default: '',
|
||||
type: 'integer',
|
||||
field : "",
|
||||
comment: "",
|
||||
length: "",
|
||||
default: "",
|
||||
type: "integer",
|
||||
primary_key: false,
|
||||
auto_increment: false,
|
||||
nullable: true,
|
||||
}];
|
||||
|
||||
table.render({
|
||||
elem: '#column-table',
|
||||
elem: "#column-table",
|
||||
cols: [cols],
|
||||
data: data,
|
||||
cellMinWidth: 40,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
toolbar: '#column-toolbar',
|
||||
toolbar: "#column-toolbar",
|
||||
defaultToolbar: [],
|
||||
});
|
||||
|
||||
table.on('toolbar(column-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(column-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
syncTableData();
|
||||
let options = table.getData('column-table');
|
||||
let options = table.getData("column-table");
|
||||
options.push({
|
||||
_field_id: _field_id++,
|
||||
field : '',
|
||||
comment: '',
|
||||
length: '',
|
||||
default: '',
|
||||
type: 'integer',
|
||||
field : "",
|
||||
comment: "",
|
||||
length: "",
|
||||
default: "",
|
||||
type: "integer",
|
||||
primary_key: false,
|
||||
auto_increment: false,
|
||||
nullable: true,
|
||||
});
|
||||
table.reloadData('column-table', {data:options});
|
||||
table.reloadData("column-table", {data:options});
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj,'_field_id');
|
||||
if (checkIds === "") return layui.popup.warning('未选中数据');
|
||||
let data = table.getData('column-table');
|
||||
var checkIds = common.checkField(obj,"_field_id");
|
||||
if (checkIds === "") return layui.popup.warning("未选中数据");
|
||||
let data = table.getData("column-table");
|
||||
let newData = [];
|
||||
let deleteIds = checkIds.split(',');
|
||||
let deleteIds = checkIds.split(",");
|
||||
layui.each(data, function (index, item) {
|
||||
if (deleteIds.indexOf(item._field_id + '') === -1) {
|
||||
if (deleteIds.indexOf(item._field_id + "") === -1) {
|
||||
newData.push(item);
|
||||
}
|
||||
});
|
||||
table.reloadData('column-table', {data: newData})
|
||||
table.reloadData("column-table", {data: newData})
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 表单设置
|
||||
layui.use(['table', 'common', 'element'], function () {
|
||||
layui.use(["table", "common", "element"], function () {
|
||||
let table = layui.table;
|
||||
|
||||
layui.element.on('tab(create-table-tab)', function(){
|
||||
layui.element.on("tab(create-table-tab)", function(){
|
||||
syncTableData();
|
||||
});
|
||||
|
||||
let cols = [
|
||||
{
|
||||
title: '字段名称',
|
||||
field: 'field',
|
||||
templet: '#form-field',
|
||||
title: "字段名称",
|
||||
field: "field",
|
||||
templet: "#form-field",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '字段备注',
|
||||
field: 'comment',
|
||||
templet: '#form-comment',
|
||||
title: "字段备注",
|
||||
field: "comment",
|
||||
templet: "#form-comment",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '控件类型',
|
||||
field: 'control',
|
||||
templet: '#form-control',
|
||||
title: "控件类型",
|
||||
field: "control",
|
||||
templet: "#form-control",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '控件参数',
|
||||
field: 'control_args',
|
||||
templet: '#form-control_args',
|
||||
title: "控件参数",
|
||||
field: "control_args",
|
||||
templet: "#form-control_args",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '表单显示',
|
||||
field: 'form_show',
|
||||
templet: '#form-form_show',
|
||||
title: "表单显示",
|
||||
field: "form_show",
|
||||
templet: "#form-form_show",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '列表显示',
|
||||
field: 'list_show',
|
||||
templet: '#form-list_show',
|
||||
title: "列表显示",
|
||||
field: "list_show",
|
||||
templet: "#form-list_show",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '支持排序',
|
||||
field: 'enable_sort',
|
||||
templet: '#form-enable_sort',
|
||||
title: "支持排序",
|
||||
field: "enable_sort",
|
||||
templet: "#form-enable_sort",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '支持查询',
|
||||
field: 'searchable',
|
||||
templet: '#form-searchable',
|
||||
title: "支持查询",
|
||||
field: "searchable",
|
||||
templet: "#form-searchable",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '查询类型',
|
||||
field: 'search_type',
|
||||
templet: '#form-search_type',
|
||||
title: "查询类型",
|
||||
field: "search_type",
|
||||
templet: "#form-search_type",
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
type: 'space'
|
||||
type: "space"
|
||||
}
|
||||
];
|
||||
|
||||
let _id = 0;
|
||||
let data = [{
|
||||
_field_id: _id++,
|
||||
field : 'id',
|
||||
comment: '主键',
|
||||
control: 'inputNumber',
|
||||
control_args: '',
|
||||
field : "id",
|
||||
comment: "主键",
|
||||
control: "inputNumber",
|
||||
control_args: "",
|
||||
form_show: false,
|
||||
list_show: true,
|
||||
enable_sort: true,
|
||||
searchable: true,
|
||||
search_type: 'normal',
|
||||
search_type: "normal",
|
||||
},{
|
||||
_field_id: _id++,
|
||||
field : 'created_at',
|
||||
comment: '创建时间',
|
||||
control: 'dateTimePicker',
|
||||
control_args: '',
|
||||
field : "created_at",
|
||||
comment: "创建时间",
|
||||
control: "dateTimePicker",
|
||||
control_args: "",
|
||||
form_show: false,
|
||||
list_show: true,
|
||||
enable_sort: true,
|
||||
searchable: true,
|
||||
search_type: 'normal',
|
||||
search_type: "normal",
|
||||
},{
|
||||
_field_id: _id++,
|
||||
field : 'updated_at',
|
||||
comment: '更新时间',
|
||||
control: 'dateTimePicker',
|
||||
control_args: '',
|
||||
field : "updated_at",
|
||||
comment: "更新时间",
|
||||
control: "dateTimePicker",
|
||||
control_args: "",
|
||||
form_show: false,
|
||||
list_show: true,
|
||||
enable_sort: false,
|
||||
searchable: false,
|
||||
search_type: 'normal',
|
||||
search_type: "normal",
|
||||
}];
|
||||
|
||||
table.render({
|
||||
elem: '#form-table',
|
||||
elem: "#form-table",
|
||||
cols: [cols],
|
||||
data: data,
|
||||
cellMinWidth: 40,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
defaultToolbar: [],
|
||||
@ -506,97 +506,97 @@
|
||||
});
|
||||
|
||||
// 索引设置
|
||||
layui.use(['table', 'common', 'xmSelect', 'popup'], function () {
|
||||
layui.use(["table", "common", "xmSelect", "popup"], function () {
|
||||
let table = layui.table;
|
||||
let common = layui.common;
|
||||
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
type: "checkbox",
|
||||
width: 52,
|
||||
},
|
||||
{
|
||||
title: '索引名称',
|
||||
field: 'name',
|
||||
templet: '#key-name',
|
||||
title: "索引名称",
|
||||
field: "name",
|
||||
templet: "#key-name",
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '索引字段',
|
||||
field: 'columns',
|
||||
templet: '#key-columns',
|
||||
title: "索引字段",
|
||||
field: "columns",
|
||||
templet: "#key-columns",
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '索引类型',
|
||||
field: 'type',
|
||||
templet: '#key-type',
|
||||
title: "索引类型",
|
||||
field: "type",
|
||||
templet: "#key-type",
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
type: 'space'
|
||||
type: "space"
|
||||
}
|
||||
];
|
||||
|
||||
window._key_id = 0;
|
||||
let data = [{
|
||||
_key_id: _key_id++,
|
||||
name : '',
|
||||
columns: '',
|
||||
type: 'normal'
|
||||
name : "",
|
||||
columns: "",
|
||||
type: "normal"
|
||||
}];
|
||||
|
||||
table.render({
|
||||
elem: '#key-table',
|
||||
elem: "#key-table",
|
||||
cols: [cols],
|
||||
data: data,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
toolbar: '#column-toolbar',
|
||||
toolbar: "#column-toolbar",
|
||||
defaultToolbar: [],
|
||||
});
|
||||
|
||||
table.on('toolbar(key-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(key-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
syncTableData();
|
||||
let options = table.getData('key-table');
|
||||
let options = table.getData("key-table");
|
||||
options.push({
|
||||
_key_id: _key_id++,
|
||||
name : '',
|
||||
columns: '',
|
||||
type: 'normal'
|
||||
name : "",
|
||||
columns: "",
|
||||
type: "normal"
|
||||
});
|
||||
table.reloadData('key-table', {data:options});
|
||||
table.reloadData("key-table", {data:options});
|
||||
keyColumnMultiSelectRender();
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj,'_key_id');
|
||||
if (checkIds === "") return layui.popup.warning('未选中数据');
|
||||
let data = table.getData('key-table');
|
||||
var checkIds = common.checkField(obj,"_key_id");
|
||||
if (checkIds === "") return layui.popup.warning("未选中数据");
|
||||
let data = table.getData("key-table");
|
||||
let newData = [];
|
||||
let deleteIds = checkIds.split(',');
|
||||
let deleteIds = checkIds.split(",");
|
||||
layui.each(data, function (index, item) {
|
||||
if (deleteIds.indexOf(item._key_id + '') === -1) {
|
||||
if (deleteIds.indexOf(item._key_id + "") === -1) {
|
||||
newData.push(item);
|
||||
}
|
||||
});
|
||||
table.reloadData('key-table', {data: newData});
|
||||
table.reloadData("key-table", {data: newData});
|
||||
keyColumnMultiSelectRender();
|
||||
}
|
||||
|
||||
window.syncTableData = function () {
|
||||
|
||||
let tableData = layui.form.val('create-table-form');
|
||||
let tableData = layui.form.val("create-table-form");
|
||||
let formTableDataOld = [];
|
||||
let columnTableData = [];
|
||||
let formTableData = [];
|
||||
@ -607,41 +607,41 @@
|
||||
window._key_id = 0;
|
||||
while (id < len) {
|
||||
// column data
|
||||
if (typeof tableData['columns[' + id + '][_field_id]'] !== 'undefined') {
|
||||
if (typeof tableData["columns[" + id + "][_field_id]"] !== "undefined") {
|
||||
columnTableData.push({
|
||||
_field_id: tableData['columns[' + id + '][_field_id]'],
|
||||
field : tableData['columns[' + id + '][field]'],
|
||||
comment: tableData['columns[' + id + '][comment]'],
|
||||
length: tableData['columns[' + id + '][length]'],
|
||||
default: tableData['columns[' + id + '][default]'],
|
||||
type: tableData['columns[' + id + '][type]'],
|
||||
primary_key: tableData['columns[' + id + '][primary_key]'] === 'on',
|
||||
auto_increment: tableData['columns[' + id + '][auto_increment]'] === 'on',
|
||||
nullable: tableData['columns[' + id + '][nullable]'] === 'on',
|
||||
_field_id: tableData["columns[" + id + "][_field_id]"],
|
||||
field : tableData["columns[" + id + "][field]"],
|
||||
comment: tableData["columns[" + id + "][comment]"],
|
||||
length: tableData["columns[" + id + "][length]"],
|
||||
default: tableData["columns[" + id + "][default]"],
|
||||
type: tableData["columns[" + id + "][type]"],
|
||||
primary_key: tableData["columns[" + id + "][primary_key]"] === "on",
|
||||
auto_increment: tableData["columns[" + id + "][auto_increment]"] === "on",
|
||||
nullable: tableData["columns[" + id + "][nullable]"] === "on",
|
||||
});
|
||||
}
|
||||
// old form data
|
||||
if (typeof tableData['forms[' + id + '][_field_id]'] !== 'undefined') {
|
||||
if (typeof tableData["forms[" + id + "][_field_id]"] !== "undefined") {
|
||||
formTableDataOld.push({
|
||||
_field_id: tableData['forms[' + id + '][_field_id]'],
|
||||
field : tableData['columns[' + id + '][field]'], // column
|
||||
comment: tableData['columns[' + id + '][comment]'], //column
|
||||
control: tableData['forms[' + id + '][control]'],
|
||||
control_args: tableData['forms[' + id + '][control_args]'],
|
||||
form_show: tableData['forms[' + id + '][form_show]'] === 'on',
|
||||
list_show: tableData['forms[' + id + '][list_show]'] === 'on',
|
||||
enable_sort: tableData['forms[' + id + '][enable_sort]'] === 'on',
|
||||
searchable: tableData['forms[' + id + '][searchable]'],
|
||||
search_type: tableData['forms[' + id + '][search_type]'],
|
||||
_field_id: tableData["forms[" + id + "][_field_id]"],
|
||||
field : tableData["columns[" + id + "][field]"], // column
|
||||
comment: tableData["columns[" + id + "][comment]"], //column
|
||||
control: tableData["forms[" + id + "][control]"],
|
||||
control_args: tableData["forms[" + id + "][control_args]"],
|
||||
form_show: tableData["forms[" + id + "][form_show]"] === "on",
|
||||
list_show: tableData["forms[" + id + "][list_show]"] === "on",
|
||||
enable_sort: tableData["forms[" + id + "][enable_sort]"] === "on",
|
||||
searchable: tableData["forms[" + id + "][searchable]"],
|
||||
search_type: tableData["forms[" + id + "][search_type]"],
|
||||
});
|
||||
}
|
||||
// key data
|
||||
if (typeof tableData['keys[' + _key_id + '][name]'] !== 'undefined') {
|
||||
if (typeof tableData["keys[" + _key_id + "][name]"] !== "undefined") {
|
||||
keyTableData.push({
|
||||
_key_id: _key_id,
|
||||
name: tableData['keys[' + _key_id + '][name]'],
|
||||
columns: tableData['keys[' + _key_id + '][columns]'],
|
||||
type: tableData['keys[' + _key_id + '][type]'],
|
||||
name: tableData["keys[" + _key_id + "][name]"],
|
||||
columns: tableData["keys[" + _key_id + "][columns]"],
|
||||
type: tableData["keys[" + _key_id + "][type]"],
|
||||
});
|
||||
}
|
||||
_key_id++;
|
||||
@ -663,30 +663,30 @@
|
||||
_field_id: _field_id,
|
||||
field : item.field, // column
|
||||
comment: item.comment, // column
|
||||
control: item.type.toLocaleString().indexOf('int') !== -1 ? 'inputNumber' : 'input',
|
||||
control_args: '',
|
||||
control: item.type.toLocaleString().indexOf("int") !== -1 ? "inputNumber" : "input",
|
||||
control_args: "",
|
||||
form_show: true,
|
||||
list_show: true,
|
||||
enable_sort: false,
|
||||
searchable: false,
|
||||
search_type: 'normal',
|
||||
search_type: "normal",
|
||||
});
|
||||
} else {
|
||||
formTableData.push(formTableOldDataMap[_field_id]);
|
||||
}
|
||||
});
|
||||
|
||||
layui.table.reloadData('column-table', {data: columnTableData});
|
||||
layui.table.reloadData('form-table', {data: formTableData});
|
||||
layui.table.reloadData('key-table', {data: keyTableData});
|
||||
layui.table.reloadData("column-table", {data: columnTableData});
|
||||
layui.table.reloadData("form-table", {data: formTableData});
|
||||
layui.table.reloadData("key-table", {data: keyTableData});
|
||||
keyColumnMultiSelectRender();
|
||||
}
|
||||
|
||||
window.keyColumnMultiSelectRender = function () {
|
||||
layui.use(['jquery', 'xmSelect', 'table'], function () {
|
||||
layui.use(["jquery", "xmSelect", "table"], function () {
|
||||
let $ = layui.$;
|
||||
let table = layui.table;
|
||||
let columnData = table.getData('column-table');
|
||||
let columnData = table.getData("column-table");
|
||||
let data = [];
|
||||
layui.each(columnData, function (i, item) {
|
||||
if (item.field) {
|
||||
@ -695,10 +695,10 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
layui.each($('.key-columns-div'), function (_, dom) {
|
||||
let name = $(dom).attr('name');
|
||||
let value = $(dom).attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
layui.each($(".key-columns-div"), function (_, dom) {
|
||||
let name = $(dom).attr("name");
|
||||
let value = $(dom).attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: dom,
|
||||
name: name,
|
||||
@ -713,21 +713,21 @@
|
||||
keyColumnMultiSelectRender();
|
||||
});
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function () {
|
||||
layui.form.on("submit(save)", function () {
|
||||
syncTableData();
|
||||
let data = layui.form.val('create-table-form');
|
||||
let data = layui.form.val("create-table-form");
|
||||
layui.$.ajax({
|
||||
url: CREATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -77,18 +77,18 @@
|
||||
|
||||
const CRUD_API = "/app/admin/table/crud";
|
||||
|
||||
layui.use(['jquery', 'xmSelect'], function() {
|
||||
layui.use(["jquery", "xmSelect"], function() {
|
||||
layui.$.ajax({
|
||||
url: '/app/admin/admin-rule/select?format=tree&type=0,1',
|
||||
dataType: 'json',
|
||||
url: "/app/admin/admin-rule/select?format=tree&type=0,1",
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
let value = layui.$('#pid').attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
let value = layui.$("#pid").attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: '#pid',
|
||||
name: 'pid',
|
||||
el: "#pid",
|
||||
name: "pid",
|
||||
initValue: initValue,
|
||||
tips: '无',
|
||||
tips: "无",
|
||||
data: e.data,
|
||||
toolbar: {show: true, list: ["CLEAR"]},
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
@ -100,27 +100,27 @@
|
||||
});
|
||||
});
|
||||
|
||||
layui.use(['iconPicker'], function() {
|
||||
layui.use(["iconPicker"], function() {
|
||||
layui.iconPicker.render({
|
||||
elem: '#icon',
|
||||
type: 'fontClass',
|
||||
elem: "#icon",
|
||||
type: "fontClass",
|
||||
page: false
|
||||
});
|
||||
});
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: CRUD_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -44,7 +44,7 @@
|
||||
const MODIFY_URL = "/app/admin/table/modify";
|
||||
const CRUD_URL = "/app/admin/table/crud";
|
||||
|
||||
layui.use(['table', 'form', 'common', 'popup'], function() {
|
||||
layui.use(["table", "form", "common", "popup"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -52,104 +52,100 @@
|
||||
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox'
|
||||
type: "checkbox"
|
||||
}, {
|
||||
title: '表名',
|
||||
field: 'TABLE_NAME',
|
||||
title: "表名",
|
||||
field: "TABLE_NAME",
|
||||
templet: function (d) {
|
||||
return '<a class="tab-link" src="' + VIEW_URL + '?table=' + d.TABLE_NAME + '">' + d.TABLE_NAME + '</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
field: 'TABLE_COMMENT',
|
||||
title: "备注",
|
||||
field: "TABLE_COMMENT",
|
||||
},
|
||||
{
|
||||
title: '记录数',
|
||||
field: 'TABLE_ROWS',
|
||||
title: "记录数",
|
||||
field: "TABLE_ROWS",
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '引擎',
|
||||
field: 'ENGINE',
|
||||
title: "引擎",
|
||||
field: "ENGINE",
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '字符集',
|
||||
field: 'TABLE_COLLATION',
|
||||
title: "字符集",
|
||||
field: "TABLE_COLLATION",
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
field: 'CREATE_TIME',
|
||||
title: "创建时间",
|
||||
field: "CREATE_TIME",
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
toolbar: '#table-bar',
|
||||
align: 'center',
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
align: "center",
|
||||
width: 200
|
||||
}
|
||||
];
|
||||
|
||||
table.render({
|
||||
elem: '#data-table',
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
toolbar: '#table-toolbar',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"]
|
||||
});
|
||||
|
||||
$(document).on('click', '.tab-link', function () {
|
||||
$(document).on("click", ".tab-link", function () {
|
||||
let obj = $(this);
|
||||
let table = obj.html();
|
||||
let url = obj.attr('src');
|
||||
let url = obj.attr("src");
|
||||
parent.layui.admin.addTab(table , table + "表", url);
|
||||
})
|
||||
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
} else if (obj.event === 'crud') {
|
||||
} else if (obj.event === "crud") {
|
||||
crud(obj);
|
||||
}
|
||||
});
|
||||
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
form.on('switch(user-enable)', function(obj) {
|
||||
layer.tips(this.value + ' ' + this.name + ':' + obj.elem.checked, obj.othis);
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '创建表格',
|
||||
title: "创建表格",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?'100%':'98%', common.isModile()?'100%':'95%'],
|
||||
area: [common.isModile()?"100%":"98%", common.isModile()?"100%":"95%"],
|
||||
content: CREATE_URL
|
||||
});
|
||||
}
|
||||
@ -158,11 +154,11 @@
|
||||
let table = obj.data.TABLE_NAME;
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改表格',
|
||||
title: "修改表格",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?'100%':'98%', common.isModile()?'100%':'95%'],
|
||||
content: MODIFY_URL + '?table=' + table
|
||||
area: [common.isModile()?"100%":"98%", common.isModile()?"100%":"95%"],
|
||||
content: MODIFY_URL + "?table=" + table
|
||||
});
|
||||
}
|
||||
|
||||
@ -170,11 +166,11 @@
|
||||
let table = obj.data.TABLE_NAME;
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '一键菜单',
|
||||
title: "一键菜单",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'500px'],
|
||||
content: CRUD_URL + '?table=' + table
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"500px"],
|
||||
content: CRUD_URL + "?table=" + table
|
||||
});
|
||||
}
|
||||
|
||||
@ -183,40 +179,40 @@
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var tables = common.checkField(obj, 'TABLE_NAME');
|
||||
var tables = common.checkField(obj, "TABLE_NAME");
|
||||
if (tables === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(tables.split(','));
|
||||
doRemove(tables.split(","));
|
||||
}
|
||||
|
||||
let doRemove = function (tables) {
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DROP_API,
|
||||
data: {tables: tables},
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function (res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -229,20 +225,20 @@
|
||||
return {};
|
||||
}
|
||||
let props = {};
|
||||
let split = control_args.split(';');
|
||||
let split = control_args.split(";");
|
||||
for (let item of split) {
|
||||
let pos = item.indexOf(':');
|
||||
let pos = item.indexOf(":");
|
||||
if (pos === -1) continue;
|
||||
let name = item.substring(0, pos).trim();
|
||||
let values = item.substring(pos + 1).trim();
|
||||
|
||||
// values = a:v,c:d
|
||||
pos = values.indexOf(':');
|
||||
pos = values.indexOf(":");
|
||||
if (pos !== -1) {
|
||||
let options = values.split(',');
|
||||
let options = values.split(",");
|
||||
values = {};
|
||||
for (const option of options) {
|
||||
let [value, name] = option.split(':');
|
||||
let [value, name] = option.split(":");
|
||||
values[value] = name;
|
||||
}
|
||||
}
|
||||
|
@ -38,19 +38,19 @@
|
||||
|
||||
<?=$form->js(3)?>
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -221,15 +221,15 @@
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
|
||||
const MODIFY_API = '/app/admin/table/modify';
|
||||
const SCHEMA_API = '/app/admin/table/schema';
|
||||
const TABLE_NAME = '<?=htmlspecialchars($table)?>';
|
||||
const MODIFY_API = "/app/admin/table/modify";
|
||||
const SCHEMA_API = "/app/admin/table/schema";
|
||||
const TABLE_NAME = "<?=htmlspecialchars($table)?>";
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
layui.use(["jquery"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SCHEMA_API + '?table=' + TABLE_NAME,
|
||||
dataType: 'json',
|
||||
url: SCHEMA_API + "?table=" + TABLE_NAME,
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
// 表信息
|
||||
$('input[name="table"]').val(res.data.table.name);
|
||||
@ -244,16 +244,16 @@
|
||||
layui.each(columnsData, function (index, item) {
|
||||
columnsData[index]._field_id = _field_id;
|
||||
columnsData[index].old_field = item.field;
|
||||
columnsData[index].default = item.default === '' ? "''" : item.default;
|
||||
columnsData[index].default = item.default === "" ? "''" : item.default;
|
||||
formsData[index]._field_id = _field_id;
|
||||
_field_id++;
|
||||
});
|
||||
|
||||
if (keysData.length === 0) {
|
||||
keysData.push({
|
||||
name : '',
|
||||
columns: '',
|
||||
type: 'normal'
|
||||
name : "",
|
||||
columns: "",
|
||||
type: "normal"
|
||||
});
|
||||
}
|
||||
window._key_id = 0;
|
||||
@ -263,205 +263,205 @@
|
||||
});
|
||||
|
||||
// 字段设置
|
||||
layui.use(['table', 'common', 'popup'], function () {
|
||||
layui.use(["table", "common", "popup"], function () {
|
||||
|
||||
let table = layui.table;
|
||||
let common = layui.common;
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
type: "checkbox",
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '字段名称',
|
||||
field: 'field',
|
||||
templet: '#col-field',
|
||||
title: "字段名称",
|
||||
field: "field",
|
||||
templet: "#col-field",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '字段备注',
|
||||
field: 'comment',
|
||||
templet: '#col-comment',
|
||||
title: "字段备注",
|
||||
field: "comment",
|
||||
templet: "#col-comment",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '长度/值',
|
||||
field: 'length',
|
||||
templet: '#col-length',
|
||||
title: "长度/值",
|
||||
field: "length",
|
||||
templet: "#col-length",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '默认值',
|
||||
field: 'default',
|
||||
templet: '#col-default',
|
||||
title: "默认值",
|
||||
field: "default",
|
||||
templet: "#col-default",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '字段类型',
|
||||
field: 'type',
|
||||
templet: '#col-type',
|
||||
title: "字段类型",
|
||||
field: "type",
|
||||
templet: "#col-type",
|
||||
width: 182
|
||||
},
|
||||
{
|
||||
title: '主键',
|
||||
field: 'primary_key',
|
||||
templet: '#col-primary_key',
|
||||
title: "主键",
|
||||
field: "primary_key",
|
||||
templet: "#col-primary_key",
|
||||
width: 50,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '自增',
|
||||
field: 'auto_increment',
|
||||
templet: '#col-auto_increment',
|
||||
title: "自增",
|
||||
field: "auto_increment",
|
||||
templet: "#col-auto_increment",
|
||||
width: 50,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '为空',
|
||||
field: 'nullable',
|
||||
templet: '#col-nullable',
|
||||
title: "为空",
|
||||
field: "nullable",
|
||||
templet: "#col-nullable",
|
||||
width: 50,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
type: 'space'
|
||||
type: "space"
|
||||
}
|
||||
];
|
||||
|
||||
table.render({
|
||||
elem: '#column-table',
|
||||
elem: "#column-table",
|
||||
cols: [cols],
|
||||
data: columnsData,
|
||||
cellMinWidth: 10,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
toolbar: '#column-toolbar',
|
||||
toolbar: "#column-toolbar",
|
||||
defaultToolbar: [],
|
||||
});
|
||||
|
||||
table.on('toolbar(column-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(column-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
syncTableData();
|
||||
let options = table.getData('column-table');
|
||||
let options = table.getData("column-table");
|
||||
options.push({
|
||||
_field_id: _field_id++,
|
||||
field : '',
|
||||
comment: '',
|
||||
length: '',
|
||||
default: '',
|
||||
type: 'integer',
|
||||
field : "",
|
||||
comment: "",
|
||||
length: "",
|
||||
default: "",
|
||||
type: "integer",
|
||||
primary_key: false,
|
||||
auto_increment: false,
|
||||
nullable: true,
|
||||
});
|
||||
table.reloadData('column-table', {data:options});
|
||||
table.reloadData("column-table", {data:options});
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj,'_field_id');
|
||||
if (checkIds === "") return layui.popup.warning('未选中数据');
|
||||
let data = table.getData('column-table');
|
||||
var checkIds = common.checkField(obj,"_field_id");
|
||||
if (checkIds === "") return layui.popup.warning("未选中数据");
|
||||
let data = table.getData("column-table");
|
||||
let newData = [];
|
||||
let deleteIds = checkIds.split(',');
|
||||
let deleteIds = checkIds.split(",");
|
||||
layui.each(data, function (index, item) {
|
||||
if (deleteIds.indexOf(item._field_id + '') === -1) {
|
||||
if (deleteIds.indexOf(item._field_id + "") === -1) {
|
||||
newData.push(item);
|
||||
}
|
||||
});
|
||||
table.reloadData('column-table', {data: newData})
|
||||
table.reloadData("column-table", {data: newData})
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 表单设置
|
||||
layui.use(['table', 'common', 'element'], function () {
|
||||
layui.use(["table", "common", "element"], function () {
|
||||
let table = layui.table;
|
||||
|
||||
layui.element.on('tab(create-table-tab)', function(){
|
||||
layui.element.on("tab(create-table-tab)", function(){
|
||||
syncTableData();
|
||||
});
|
||||
|
||||
let cols = [
|
||||
{
|
||||
title: '字段名称',
|
||||
field: 'field',
|
||||
templet: '#form-field',
|
||||
title: "字段名称",
|
||||
field: "field",
|
||||
templet: "#form-field",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '字段备注',
|
||||
field: 'comment',
|
||||
templet: '#form-comment',
|
||||
title: "字段备注",
|
||||
field: "comment",
|
||||
templet: "#form-comment",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '控件类型',
|
||||
field: 'control',
|
||||
templet: '#form-control',
|
||||
title: "控件类型",
|
||||
field: "control",
|
||||
templet: "#form-control",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '控件参数',
|
||||
field: 'control_args',
|
||||
templet: '#form-control_args',
|
||||
title: "控件参数",
|
||||
field: "control_args",
|
||||
templet: "#form-control_args",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '表单显示',
|
||||
field: 'form_show',
|
||||
templet: '#form-form_show',
|
||||
title: "表单显示",
|
||||
field: "form_show",
|
||||
templet: "#form-form_show",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '列表显示',
|
||||
field: 'list_show',
|
||||
templet: '#form-list_show',
|
||||
title: "列表显示",
|
||||
field: "list_show",
|
||||
templet: "#form-list_show",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '支持排序',
|
||||
field: 'enable_sort',
|
||||
templet: '#form-enable_sort',
|
||||
title: "支持排序",
|
||||
field: "enable_sort",
|
||||
templet: "#form-enable_sort",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '支持查询',
|
||||
field: 'searchable',
|
||||
templet: '#form-searchable',
|
||||
title: "支持查询",
|
||||
field: "searchable",
|
||||
templet: "#form-searchable",
|
||||
width: 67,
|
||||
align: 'center',
|
||||
align: "center",
|
||||
},
|
||||
{
|
||||
title: '查询类型',
|
||||
field: 'search_type',
|
||||
templet: '#form-search_type',
|
||||
title: "查询类型",
|
||||
field: "search_type",
|
||||
templet: "#form-search_type",
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
type: 'space'
|
||||
type: "space"
|
||||
}
|
||||
];
|
||||
|
||||
table.render({
|
||||
elem: '#form-table',
|
||||
elem: "#form-table",
|
||||
cols: [cols],
|
||||
data: formsData,
|
||||
cellMinWidth: 40,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
defaultToolbar: [],
|
||||
@ -470,88 +470,88 @@
|
||||
});
|
||||
|
||||
// 索引设置
|
||||
layui.use(['table', 'common', 'xmSelect', 'popup'], function () {
|
||||
layui.use(["table", "common", "xmSelect", "popup"], function () {
|
||||
let table = layui.table;
|
||||
let common = layui.common;
|
||||
|
||||
let cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
type: "checkbox",
|
||||
width: 52,
|
||||
},
|
||||
{
|
||||
title: '索引名称',
|
||||
field: 'name',
|
||||
templet: '#key-name',
|
||||
title: "索引名称",
|
||||
field: "name",
|
||||
templet: "#key-name",
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '索引字段',
|
||||
field: 'columns',
|
||||
templet: '#key-columns',
|
||||
title: "索引字段",
|
||||
field: "columns",
|
||||
templet: "#key-columns",
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '索引类型',
|
||||
field: 'type',
|
||||
templet: '#key-type',
|
||||
title: "索引类型",
|
||||
field: "type",
|
||||
templet: "#key-type",
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
type: 'space'
|
||||
type: "space"
|
||||
}
|
||||
];
|
||||
|
||||
table.render({
|
||||
elem: '#key-table',
|
||||
elem: "#key-table",
|
||||
cols: [cols],
|
||||
data: keysData,
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
limit: 10000,
|
||||
page: false,
|
||||
toolbar: '#column-toolbar',
|
||||
toolbar: "#column-toolbar",
|
||||
defaultToolbar: [],
|
||||
});
|
||||
|
||||
table.on('toolbar(key-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(key-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
let add = function() {
|
||||
syncTableData();
|
||||
let options = table.getData('key-table');
|
||||
let options = table.getData("key-table");
|
||||
options.push({
|
||||
_key_id: _key_id++,
|
||||
name : '',
|
||||
columns: '',
|
||||
type: 'normal'
|
||||
name : "",
|
||||
columns: "",
|
||||
type: "normal"
|
||||
});
|
||||
table.reloadData('key-table', {data:options});
|
||||
table.reloadData("key-table", {data:options});
|
||||
keyColumnMultiSelectRender();
|
||||
}
|
||||
|
||||
let batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj,'_key_id');
|
||||
if (checkIds === "") return layui.popup.warning('未选中数据');
|
||||
let data = table.getData('key-table');
|
||||
var checkIds = common.checkField(obj,"_key_id");
|
||||
if (checkIds === "") return layui.popup.warning("未选中数据");
|
||||
let data = table.getData("key-table");
|
||||
let newData = [];
|
||||
let deleteIds = checkIds.split(',');
|
||||
let deleteIds = checkIds.split(",");
|
||||
layui.each(data, function (index, item) {
|
||||
if (deleteIds.indexOf(item._key_id + '') === -1) {
|
||||
if (deleteIds.indexOf(item._key_id + "") === -1) {
|
||||
newData.push(item);
|
||||
}
|
||||
});
|
||||
table.reloadData('key-table', {data: newData});
|
||||
table.reloadData("key-table", {data: newData});
|
||||
keyColumnMultiSelectRender();
|
||||
}
|
||||
|
||||
window.syncTableData = function () {
|
||||
let tableData = layui.form.val('create-table-form');
|
||||
let tableData = layui.form.val("create-table-form");
|
||||
let formTableDataOld = [];
|
||||
let columnTableData = [];
|
||||
let formTableData = [];
|
||||
@ -562,42 +562,42 @@
|
||||
window._key_id = 0;
|
||||
while (id < len) {
|
||||
// column data
|
||||
if (typeof tableData['columns[' + id + '][_field_id]'] !== 'undefined') {
|
||||
if (typeof tableData["columns[" + id + "][_field_id]"] !== "undefined") {
|
||||
columnTableData.push({
|
||||
_field_id: tableData['columns[' + id + '][_field_id]'],
|
||||
field : tableData['columns[' + id + '][field]'],
|
||||
old_field : tableData['columns[' + id + '][old_field]'],
|
||||
comment: tableData['columns[' + id + '][comment]'],
|
||||
length: tableData['columns[' + id + '][length]'],
|
||||
default: tableData['columns[' + id + '][default]'],
|
||||
type: tableData['columns[' + id + '][type]'],
|
||||
primary_key: tableData['columns[' + id + '][primary_key]'] === 'on',
|
||||
auto_increment: tableData['columns[' + id + '][auto_increment]'] === 'on',
|
||||
nullable: tableData['columns[' + id + '][nullable]'] === 'on',
|
||||
_field_id: tableData["columns[" + id + "][_field_id]"],
|
||||
field : tableData["columns[" + id + "][field]"],
|
||||
old_field : tableData["columns[" + id + "][old_field]"],
|
||||
comment: tableData["columns[" + id + "][comment]"],
|
||||
length: tableData["columns[" + id + "][length]"],
|
||||
default: tableData["columns[" + id + "][default]"],
|
||||
type: tableData["columns[" + id + "][type]"],
|
||||
primary_key: tableData["columns[" + id + "][primary_key]"] === "on",
|
||||
auto_increment: tableData["columns[" + id + "][auto_increment]"] === "on",
|
||||
nullable: tableData["columns[" + id + "][nullable]"] === "on",
|
||||
});
|
||||
}
|
||||
// old form data
|
||||
if (typeof tableData['forms[' + id + '][_field_id]'] !== 'undefined') {
|
||||
if (typeof tableData["forms[" + id + "][_field_id]"] !== "undefined") {
|
||||
formTableDataOld.push({
|
||||
_field_id: tableData['forms[' + id + '][_field_id]'],
|
||||
field : tableData['columns[' + id + '][field]'], // column
|
||||
comment: tableData['columns[' + id + '][comment]'], //column
|
||||
control: tableData['forms[' + id + '][control]'],
|
||||
control_args: tableData['forms[' + id + '][control_args]'],
|
||||
form_show: tableData['forms[' + id + '][form_show]'] === 'on',
|
||||
list_show: tableData['forms[' + id + '][list_show]'] === 'on',
|
||||
enable_sort: tableData['forms[' + id + '][enable_sort]'] === 'on',
|
||||
searchable: tableData['forms[' + id + '][searchable]'],
|
||||
search_type: tableData['forms[' + id + '][search_type]'],
|
||||
_field_id: tableData["forms[" + id + "][_field_id]"],
|
||||
field : tableData["columns[" + id + "][field]"], // column
|
||||
comment: tableData["columns[" + id + "][comment]"], //column
|
||||
control: tableData["forms[" + id + "][control]"],
|
||||
control_args: tableData["forms[" + id + "][control_args]"],
|
||||
form_show: tableData["forms[" + id + "][form_show]"] === "on",
|
||||
list_show: tableData["forms[" + id + "][list_show]"] === "on",
|
||||
enable_sort: tableData["forms[" + id + "][enable_sort]"] === "on",
|
||||
searchable: tableData["forms[" + id + "][searchable]"],
|
||||
search_type: tableData["forms[" + id + "][search_type]"],
|
||||
});
|
||||
}
|
||||
// key data
|
||||
if (typeof tableData['keys[' + _key_id + '][name]'] !== 'undefined') {
|
||||
if (typeof tableData["keys[" + _key_id + "][name]"] !== "undefined") {
|
||||
keyTableData.push({
|
||||
_key_id: _key_id,
|
||||
name: tableData['keys[' + _key_id + '][name]'],
|
||||
columns: tableData['keys[' + _key_id + '][columns]'],
|
||||
type: tableData['keys[' + _key_id + '][type]'],
|
||||
name: tableData["keys[" + _key_id + "][name]"],
|
||||
columns: tableData["keys[" + _key_id + "][columns]"],
|
||||
type: tableData["keys[" + _key_id + "][type]"],
|
||||
});
|
||||
}
|
||||
_key_id++;
|
||||
@ -619,30 +619,30 @@
|
||||
_field_id: _field_id,
|
||||
field : item.field, // column
|
||||
comment: item.comment, // column
|
||||
control: item.type.toLocaleString().indexOf('int') !== -1 ? 'inputNumber' : 'input',
|
||||
control_args: '',
|
||||
control: item.type.toLocaleString().indexOf("int") !== -1 ? "inputNumber" : "input",
|
||||
control_args: "",
|
||||
form_show: true,
|
||||
list_show: true,
|
||||
enable_sort: false,
|
||||
searchable: false,
|
||||
search_type: 'normal',
|
||||
search_type: "normal",
|
||||
});
|
||||
} else {
|
||||
formTableData.push(formTableOldDataMap[_field_id]);
|
||||
}
|
||||
});
|
||||
|
||||
layui.table.reloadData('column-table', {data: columnTableData});
|
||||
layui.table.reloadData('form-table', {data: formTableData});
|
||||
layui.table.reloadData('key-table', {data: keyTableData});
|
||||
layui.table.reloadData("column-table", {data: columnTableData});
|
||||
layui.table.reloadData("form-table", {data: formTableData});
|
||||
layui.table.reloadData("key-table", {data: keyTableData});
|
||||
keyColumnMultiSelectRender();
|
||||
}
|
||||
|
||||
window.keyColumnMultiSelectRender = function () {
|
||||
layui.use(['jquery', 'xmSelect', 'table'], function () {
|
||||
layui.use(["jquery", "xmSelect", "table"], function () {
|
||||
let $ = layui.$;
|
||||
let table = layui.table;
|
||||
let columnData = table.getData('column-table');
|
||||
let columnData = table.getData("column-table");
|
||||
let data = [];
|
||||
layui.each(columnData, function (i, item) {
|
||||
if (item.field) {
|
||||
@ -651,10 +651,10 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
layui.each($('.key-columns-div'), function (_, dom) {
|
||||
let name = $(dom).attr('name');
|
||||
let value = $(dom).attr('value');
|
||||
let initValue = value ? value.split(',') : [];
|
||||
layui.each($(".key-columns-div"), function (_, dom) {
|
||||
let name = $(dom).attr("name");
|
||||
let value = $(dom).attr("value");
|
||||
let initValue = value ? value.split(",") : [];
|
||||
layui.xmSelect.render({
|
||||
el: dom,
|
||||
name: name,
|
||||
@ -675,21 +675,21 @@
|
||||
|
||||
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function () {
|
||||
layui.form.on("submit(save)", function () {
|
||||
syncTableData();
|
||||
let data = layui.form.val('create-table-form');
|
||||
let data = layui.form.val("create-table-form");
|
||||
layui.$.ajax({
|
||||
url: MODIFY_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -37,28 +37,28 @@
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script>
|
||||
|
||||
let PRIMARY_KEY = 'id';
|
||||
let PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/table/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/table/update";
|
||||
|
||||
layui.use(['form', 'util'], function () {
|
||||
layui.use(["form", "util"], function () {
|
||||
let $ = layui.$;
|
||||
let util = layui.util;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === 'password') {
|
||||
obj.attr('placeholder', '不更新密码请留空');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.html(util.escape(value));
|
||||
} else {
|
||||
obj.attr('value', value);
|
||||
obj.attr("value", value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -68,19 +68,19 @@
|
||||
});
|
||||
});
|
||||
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.use(["form", "popup"], function () {
|
||||
//提交事件
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -68,7 +68,7 @@
|
||||
|
||||
<?=$form->js(3)?>
|
||||
|
||||
layui.use(['table', 'form','common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form","common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -79,11 +79,11 @@
|
||||
let apiResults = {};
|
||||
$.ajax({
|
||||
url: SCHEMA_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
let forms = e.data.forms;
|
||||
let cols = [{
|
||||
type: 'checkbox'
|
||||
type: "checkbox"
|
||||
}];
|
||||
for (let i in forms) {
|
||||
let item = forms[i];
|
||||
@ -97,13 +97,13 @@
|
||||
|
||||
let control = item.control.toLowerCase();
|
||||
// switch 可以直接编辑
|
||||
if (control === 'switch') {
|
||||
if (control === "switch") {
|
||||
let props = getProps(item.control_args);
|
||||
let layText = props['lay-text'] || '';
|
||||
let layText = props["lay-text"] || "";
|
||||
schema.templet = function (d) {
|
||||
form.on('switch('+field+')', function (data) {
|
||||
form.on("switch("+field+")", function (data) {
|
||||
if (!PRIMARY_KEY) {
|
||||
return layui.popup.warning('该表没有主键,无法完成此操作');
|
||||
return layui.popup.warning("该表没有主键,无法完成此操作");
|
||||
}
|
||||
let load = layer.load();
|
||||
let postData = { table: TABLE_NAME };
|
||||
@ -114,25 +114,25 @@
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功');
|
||||
return layui.popup.success("操作成功");
|
||||
})
|
||||
});
|
||||
let checked = d[field] === 1 ? 'checked' : '';
|
||||
let checked = d[field] === 1 ? "checked" : "";
|
||||
return '<input type="checkbox" value="'+util.escape(d[PRIMARY_KEY])+'" lay-filter="'+util.escape(field)+'" lay-skin="switch" lay-text="'+util.escape(layText)+'" '+checked+'/>';
|
||||
}
|
||||
} else if (control === 'iconpicker') {
|
||||
} else if (control === "iconpicker") {
|
||||
schema.templet = function (d) {
|
||||
return '<i class="layui-icon ' + util.escape(d[field]) + '"></i>';
|
||||
};
|
||||
} else if (control === 'upload') {
|
||||
} else if (control === "upload") {
|
||||
schema.templet = function (d) {
|
||||
return '<a href="' + encodeURI(d[field]) + '" target="_blank">' + util.escape(d[field]) + '</a>';
|
||||
};
|
||||
} else if (control === 'uploadimage') {
|
||||
} else if (control === "uploadimage") {
|
||||
schema.templet = function (d) {
|
||||
return '<img src="'+encodeURI(d[field])+'" style="max-width:32px;max-height:32px;" />';
|
||||
};
|
||||
} else if (['select', 'selectmulti', 'treeselect', 'treeselectmulti'].indexOf(control) !== -1) {
|
||||
} else if (["select", "selectmulti", "treeselect", "treeselectmulti"].indexOf(control) !== -1) {
|
||||
let props = getProps(item.control_args);
|
||||
apiResults[field] = [];
|
||||
if (props.url) {
|
||||
@ -141,39 +141,39 @@
|
||||
apiResults[field] = props.data;
|
||||
}
|
||||
schema.templet = function (d) {
|
||||
if (typeof d[field] == "undefined") return '';
|
||||
if (typeof d[field] == "undefined") return "";
|
||||
let items = [];
|
||||
layui.each((d[field] + '').split(','), function (k , v) {
|
||||
layui.each((d[field] + "").split(","), function (k , v) {
|
||||
items.push(apiResults[field][v] || v);
|
||||
});
|
||||
return util.escape(items.join(','));
|
||||
return util.escape(items.join(","));
|
||||
}
|
||||
}
|
||||
cols.push(schema);
|
||||
}
|
||||
cols.push({
|
||||
title: '操作',
|
||||
toolbar: '#table-bar',
|
||||
align: 'center',
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
align: "center",
|
||||
width: 130
|
||||
});
|
||||
|
||||
function render()
|
||||
{
|
||||
table.render({
|
||||
elem: '#data-table',
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: 'line',
|
||||
size: 'lg',
|
||||
toolbar: '#table-toolbar',
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"]
|
||||
});
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@
|
||||
let [field, url] = item;
|
||||
$.ajax({
|
||||
url: url,
|
||||
dateType: 'json',
|
||||
dateType: "json",
|
||||
success: function (res) {
|
||||
function travel(items) {
|
||||
for (let k in items) {
|
||||
@ -210,40 +210,40 @@
|
||||
}
|
||||
});
|
||||
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
window.remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
window.edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
window.add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
window.refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
window.batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -254,24 +254,24 @@
|
||||
window.add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
|
||||
window.edit = function(obj) {
|
||||
if (!PRIMARY_KEY) {
|
||||
return layui.popup.warning('该表没有主键,无法完成此操作');
|
||||
return layui.popup.warning("该表没有主键,无法完成此操作");
|
||||
}
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
content: UPDATE_URL + '&' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "&" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -282,45 +282,45 @@
|
||||
window.batchRemove = function(obj) {
|
||||
var checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
window.doRemove(checkIds.split(','));
|
||||
window.doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
window.doRemove = function (ids) {
|
||||
if (!PRIMARY_KEY) {
|
||||
return layui.popup.warning('该表没有主键,无法完成此操作');
|
||||
return layui.popup.warning("该表没有主键,无法完成此操作");
|
||||
}
|
||||
let data = {
|
||||
table: TABLE_NAME
|
||||
};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
window.refreshTable = function() {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -333,20 +333,20 @@
|
||||
return {};
|
||||
}
|
||||
let props = {};
|
||||
let split = control_args.split(';');
|
||||
let split = control_args.split(";");
|
||||
for (let item of split) {
|
||||
let pos = item.indexOf(':');
|
||||
let pos = item.indexOf(":");
|
||||
if (pos === -1) continue;
|
||||
let name = item.substring(0, pos).trim();
|
||||
let values = item.substring(pos + 1).trim();
|
||||
|
||||
// values = a:v,c:d
|
||||
pos = values.indexOf(':');
|
||||
pos = values.indexOf(":");
|
||||
if (pos !== -1) {
|
||||
let options = values.split(',');
|
||||
let options = values.split(",");
|
||||
values = {};
|
||||
for (const option of options) {
|
||||
let [value, name] = option.split(':');
|
||||
let [value, name] = option.split(":");
|
||||
values[value] = name;
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const PRIMARY_KEY = "id";
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\UploadController";
|
||||
const SELECT_API = "/app/admin/upload/select";
|
||||
const UPDATE_API = "/app/admin/upload/update";
|
||||
@ -107,7 +107,7 @@
|
||||
const UPDATE_URL = "/app/admin/upload/update";
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -119,7 +119,7 @@
|
||||
layui.laydate.render({
|
||||
elem: "#created_at",
|
||||
range: ["#created_at-date-start", "#created_at-date-end"],
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -137,11 +137,11 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
on: function(data){
|
||||
let value = data.arr[0] ? data.arr[0].value : '';
|
||||
table.reload('data-table', {
|
||||
let value = data.arr[0] ? data.arr[0].value : "";
|
||||
table.reload("data-table", {
|
||||
where: {category: value}
|
||||
})
|
||||
},
|
||||
@ -166,7 +166,7 @@
|
||||
title: "文件",
|
||||
field: "url",
|
||||
templet: function (d) {
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].indexOf(d.ext.toLowerCase()) !== -1) {
|
||||
if (["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg"].indexOf(d.ext.toLowerCase()) !== -1) {
|
||||
return '<img src="' + encodeURI(d['url']) + '" style="max-width:32px;max-height:32px;" />';
|
||||
}
|
||||
return '<a href="' + encodeURI(d['url']) + '" target="_blank">' + util.escape(d['url']) + '</a>';
|
||||
@ -236,7 +236,7 @@
|
||||
// 查询指定后缀
|
||||
let searchExt = layui.url().search.ext;
|
||||
if (searchExt) {
|
||||
layui.$('.top-search-from input[name="ext"]').val(searchExt);
|
||||
layui.$(".top-search-from input[name="ext"]").val(searchExt);
|
||||
}
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
@ -254,16 +254,16 @@
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
layer.photos({photos: "div[lay-id="data-table"]", anim: 5});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取表格中下拉或树形组件数据
|
||||
let apis = [];
|
||||
apis.push(['category', '/app/admin/dict/get/upload']);
|
||||
apis.push(["category", "/app/admin/dict/get/upload"]);
|
||||
let apiResults = {};
|
||||
apiResults['category'] = [];
|
||||
apiResults["category"] = [];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
@ -294,47 +294,47 @@
|
||||
}
|
||||
|
||||
// 编辑删除或选择行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
} else if (obj.event === 'select') {
|
||||
} else if (obj.event === "select") {
|
||||
select(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -346,9 +346,9 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'380px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"380px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@ -358,10 +358,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'380px'],
|
||||
content: UPDATE_URL + '?' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"380px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -374,33 +374,33 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -416,14 +416,14 @@
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
|
||||
// 格式化文件大小
|
||||
let formatSize = function(value) {
|
||||
if(null == value || '' === value){
|
||||
if(null == value || "" === value){
|
||||
return "0 Bytes";
|
||||
}
|
||||
let unitArr = ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];
|
||||
|
@ -99,7 +99,7 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const PRIMARY_KEY = "id";
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\UploadController";
|
||||
const SELECT_API = "/app/admin/upload/select";
|
||||
const UPDATE_API = "/app/admin/upload/update";
|
||||
@ -112,7 +112,7 @@
|
||||
layui.laydate.render({
|
||||
elem: "#created_at",
|
||||
range: ["#created_at-date-start", "#created_at-date-end"],
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -130,8 +130,8 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
@ -151,15 +151,15 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -182,7 +182,7 @@
|
||||
title: "文件",
|
||||
field: "url",
|
||||
templet: function (d) {
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].indexOf(d.ext.toLowerCase()) !== -1) {
|
||||
if (["jpg", "jpeg", "png", "gif", "bmp", "webp", "svg"].indexOf(d.ext.toLowerCase()) !== -1) {
|
||||
return '<img src="' + encodeURI(d['url']) + '" style="max-width:32px;max-height:32px;" />';
|
||||
}
|
||||
return '<a href="' + encodeURI(d['url']) + '" target="_blank">' + util.escape(d['url']) + '</a>';
|
||||
@ -271,11 +271,11 @@
|
||||
|
||||
// 获取表格中下拉或树形组件数据
|
||||
let apis = [];
|
||||
apis.push(['admin_id', '/app/admin/admin/select?format=select']);
|
||||
apis.push(['category', '/app/admin/dict/get/upload']);
|
||||
apis.push(["admin_id", "/app/admin/admin/select?format=select"]);
|
||||
apis.push(["category", "/app/admin/dict/get/upload"]);
|
||||
let apiResults = {};
|
||||
apiResults['admin_id'] = [];
|
||||
apiResults['category'] = [];
|
||||
apiResults["admin_id"] = [];
|
||||
apiResults["category"] = [];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
@ -306,45 +306,45 @@
|
||||
}
|
||||
|
||||
// 编辑删除或选择行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -356,9 +356,9 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'380px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"380px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@ -368,10 +368,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'380px'],
|
||||
content: UPDATE_URL + '?' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"380px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -384,33 +384,33 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -418,14 +418,14 @@
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
|
||||
// 格式化文件大小
|
||||
let formatSize = function(value) {
|
||||
if(null == value || '' === value){
|
||||
if(null == value || "" === value){
|
||||
return "0 Bytes";
|
||||
}
|
||||
let unitArr = ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];
|
||||
|
@ -41,17 +41,17 @@
|
||||
<script>
|
||||
|
||||
// 字段 文件 url
|
||||
layui.use(['upload', 'layer', 'popup', 'util'], function() {
|
||||
let input = layui.$('#url').prev();
|
||||
layui.use(["upload", "layer", "popup", "util"], function() {
|
||||
let input = layui.$("#url").prev();
|
||||
input.prev().html(layui.util.escape(input.val()));
|
||||
layui.upload.render({
|
||||
elem: "#url",
|
||||
accept: 'file',
|
||||
accept: "file",
|
||||
data: {category: function () {
|
||||
return layui.$('input[name="category"]').val();
|
||||
}},
|
||||
url: '/app/admin/upload/insert',
|
||||
field: '__file__',
|
||||
url: "/app/admin/upload/insert",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code) return layui.popup.failure(res.msg);
|
||||
parent.refreshTable();
|
||||
@ -74,8 +74,8 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
@ -41,34 +41,34 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/upload/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/upload/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(['form', 'util'], function () {
|
||||
layui.use(["form", "util"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
obj.attr('value', value);
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
obj.attr("value", value);
|
||||
});
|
||||
|
||||
// 字段 文件 url
|
||||
layui.use(['upload', 'layer', 'popup', 'util'], function() {
|
||||
let input = layui.$('#url').prev();
|
||||
layui.use(["upload", "layer", "popup", "util"], function() {
|
||||
let input = layui.$("#url").prev();
|
||||
input.prev().html(layui.util.escape(input.val()));
|
||||
layui.upload.render({
|
||||
elem: "#url",
|
||||
url: '/app/admin/upload/update',
|
||||
accept: 'file',
|
||||
field: '__file__',
|
||||
url: "/app/admin/upload/update",
|
||||
accept: "file",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code) return layui.popup.failure(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().html(layui.util.escape(res.data.url));
|
||||
@ -90,8 +90,8 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
@ -102,19 +102,19 @@
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -170,8 +170,8 @@
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = 'id';
|
||||
const CONTROLLER = 'plugin\\admin\\app\\controller\\UserController';
|
||||
const PRIMARY_KEY = "id";
|
||||
const CONTROLLER = "plugin\\admin\\app\\controller\\UserController";
|
||||
const SELECT_API = "/app/admin/user/select";
|
||||
const UPDATE_API = "/app/admin/user/update";
|
||||
const DELETE_API = "/app/admin/user/delete";
|
||||
@ -192,8 +192,8 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
@ -212,7 +212,7 @@
|
||||
layui.laydate.render({
|
||||
elem: "#last_time",
|
||||
range: ["#last_time-date-start", "#last_time-date-end"],
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -221,12 +221,12 @@
|
||||
layui.laydate.render({
|
||||
elem: "#join_time",
|
||||
range: ["#join_time-date-start", "#join_time-date-end"],
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
// 表格渲染
|
||||
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
@ -377,9 +377,9 @@
|
||||
|
||||
// 获取表格中下拉或树形组件数据
|
||||
let apis = [];
|
||||
apis.push(['sex', '/app/admin/dict/get/sex']);
|
||||
apis.push(["sex", "/app/admin/dict/get/sex"]);
|
||||
let apiResults = {};
|
||||
apiResults['sex'] = [];
|
||||
apiResults["sex"] = [];
|
||||
let count = apis.length;
|
||||
layui.each(apis, function (k, item) {
|
||||
let [field, url] = item;
|
||||
@ -410,45 +410,45 @@
|
||||
}
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on('tool(data-table)', function(obj) {
|
||||
if (obj.event === 'remove') {
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on('toolbar(data-table)', function(obj) {
|
||||
if (obj.event === 'add') {
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === 'refresh') {
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on('submit(table-query)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on('submit(table-reset)', function(data) {
|
||||
table.reload('data-table', {
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on('sort(data-table)', function(obj){
|
||||
table.reload('data-table', {
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: 'fixed',
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
@ -460,9 +460,9 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@ -472,10 +472,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
area: [common.isModile()?'100%':'500px', common.isModile()?'100%':'450px'],
|
||||
content: UPDATE_URL + '?' + PRIMARY_KEY + '=' + value
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
@ -488,33 +488,33 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning('未选中数据');
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(','));
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm('确定删除?', {
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', refreshTable);
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -522,8 +522,8 @@
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function(param) {
|
||||
table.reloadData('data-table', {
|
||||
scrollPos: 'fixed'
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed"
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -170,10 +170,10 @@
|
||||
name: "sex",
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
value: '1',
|
||||
value: "1",
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
@ -183,7 +183,7 @@
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on('click', function() {
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
@ -198,9 +198,9 @@
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
url: '/app/admin/upload/avatar',
|
||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||
field: '__file__',
|
||||
url: "/app/admin/upload/avatar",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
@ -219,7 +219,7 @@
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#last_time",
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -227,7 +227,7 @@
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#join_time",
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -241,18 +241,18 @@
|
||||
})
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
@ -154,30 +154,30 @@
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = 'id';
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/user/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/user/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(['form', 'util'], function () {
|
||||
layui.use(["form", "util"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: 'json',
|
||||
dataType: "json",
|
||||
success: function (e) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(e.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === 'password') {
|
||||
obj.attr('placeholder', '不更新密码请留空');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.val(layui.util.escape(value));
|
||||
} else {
|
||||
obj.attr('value', value);
|
||||
obj.attr("value", value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -195,8 +195,8 @@
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
clickClose: true,
|
||||
radio: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
@ -206,7 +206,7 @@
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on('click', function() {
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
@ -221,9 +221,9 @@
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
url: '/app/admin/upload/avatar',
|
||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||
field: '__file__',
|
||||
url: "/app/admin/upload/avatar",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
@ -242,7 +242,7 @@
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#last_time",
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -250,7 +250,7 @@
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#join_time",
|
||||
type: 'datetime',
|
||||
type: "datetime",
|
||||
});
|
||||
})
|
||||
|
||||
@ -262,26 +262,25 @@
|
||||
layui.$('input[name="status"]').val(this.checked ? 1 : 0);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(['form', 'popup'], function () {
|
||||
layui.form.on('submit(save)', function (data) {
|
||||
layui.use(["form", "popup"], function () {
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: 'POST',
|
||||
dateType: 'json',
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success('操作成功', function () {
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user