'wip(semantic):调整模板api接口'
This commit is contained in:
@@ -39,15 +39,15 @@
|
||||
|
||||
|
||||
{#表格工具栏,需要在表格中绑定,且需要自定义事件#}
|
||||
<script type="text/html" id="toolbaes">
|
||||
<script type="text/html" id="toolbar">
|
||||
{% if authorize("admin:dept:edit") %}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add_toggle">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="toolbar-add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if authorize("admin:dept:remove") %}
|
||||
<button class="pear-btn pear-btn-md" lay-event="batch_remove">
|
||||
<button class="pear-btn pear-btn-md" lay-event="toolbar-remove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
@@ -88,6 +88,19 @@
|
||||
let popup = layui.popup
|
||||
|
||||
let MODULE_PATH = '/dept/'
|
||||
const get_columns = () => [
|
||||
[
|
||||
{ type: 'checkbox' },
|
||||
{ field: 'deptName', minWidth: 200, title: '部门名称' },
|
||||
{ field: 'leader', title: '负责人' },
|
||||
{ field: 'phone', title: '联系方式' },
|
||||
{ field: 'email', title: '邮箱' },
|
||||
{ field: 'address', title: '详细地址' },
|
||||
{ field: 'status', title: '状态', templet: '#dept-status' },
|
||||
{ field: 'sort', title: '排序', width: 100 },
|
||||
{ title: '操作', templet: '#tool', width: 120, align: 'center' },
|
||||
],
|
||||
]
|
||||
|
||||
{#定义表格渲染函数#}
|
||||
window.render = function () {
|
||||
@@ -100,23 +113,11 @@
|
||||
skin: 'line',
|
||||
method: 'post', /**/
|
||||
treeDefaultClose: false,
|
||||
toolbar: '#toolbaes', /*表格的工具栏*/
|
||||
toolbar: '#toolbar', /*表格的工具栏*/
|
||||
elem: '#tables', /*表格挂载的对象*/
|
||||
url: DEPARTMENT_API.DEPARTMENTS(), /*数据来源接口*/
|
||||
page: false,
|
||||
cols: [
|
||||
[
|
||||
{ type: 'checkbox' },
|
||||
{ field: 'deptName', minWidth: 200, title: '部门名称' },
|
||||
{ field: 'leader', title: '负责人' },
|
||||
{ field: 'phone', title: '联系方式' },
|
||||
{ field: 'email', title: '邮箱' },
|
||||
{ field: 'address', title: '详细地址' },
|
||||
{ field: 'status', title: '状态', templet: '#dept-status' },
|
||||
{ field: 'sort', title: '排序', width: 100 },
|
||||
{ title: '操作', templet: '#tool', width: 120, align: 'center' }
|
||||
]
|
||||
]/*表格渲染的数据*/
|
||||
cols: get_columns(),/*表格渲染的数据*/
|
||||
})
|
||||
}
|
||||
|
||||
@@ -167,12 +168,12 @@
|
||||
/*表格的工具栏*/
|
||||
table.on('toolbar(tables)', function (obj) {
|
||||
{#console.log(obj)#}
|
||||
if (obj.event === 'add_toggle') {
|
||||
window.add_toggle()
|
||||
if (obj.event === 'toolbar-add') {
|
||||
window.toolbar_add()
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refresh()
|
||||
} else if (obj.event === 'batch_remove') {
|
||||
{#window.batch_remove(obj)#}
|
||||
} else if (obj.event === 'toolbar-remove') {
|
||||
{#window.toolbar_remove(obj)#}
|
||||
layer.msg('禁止批量删除')
|
||||
return false
|
||||
{#console.log(table.checkStatus(obj.config.id).data)#}
|
||||
@@ -197,21 +198,21 @@
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg)
|
||||
popup.success(result.message)
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
popup.failure(result.message)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
window.add_toggle = function () {
|
||||
window.toolbar_add = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['450px', '500px'], /*新增窗口的大小*/
|
||||
content: '/dept/add' /*新增窗口从那里来*/
|
||||
content: '/dept/add', /*新增窗口从那里来*/
|
||||
})
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['450px', '500px'],
|
||||
content: MODULE_PATH + 'edit?deptId=' + obj.data['deptId'] /*编辑修改窗口从那里来*/
|
||||
content: MODULE_PATH + 'edit?deptId=' + obj.data['deptId'], /*编辑修改窗口从那里来*/
|
||||
})
|
||||
|
||||
}
|
||||
@@ -238,13 +239,13 @@
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
popup.success(result.message, function () {
|
||||
obj.del()
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
popup.failure(result.message)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -111,12 +111,12 @@
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
layer.msg(result.message, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))
|
||||
parent.render()
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
layer.msg(result.message, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -111,12 +111,12 @@
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
layer.msg(result.message, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.render()
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
layer.msg(result.message, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user