1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
| {extend name="../../base/view/common/base" /}
| <!-- 主体 -->
| {block name="body"}
| <div class="p-page">
| <table class="layui-hide" id="conf" lay-filter="conf"></table>
| </div>
|
| <script type="text/html" id="status">
| <i class="layui-icon {{# if(d.status == 1){ }}green layui-icon-ok{{# } else { }}red layui-icon-close{{# } }}"></i>
| </script>
| <script type="text/html" id="toolbarDemo">
| <div class="layui-btn-container">
| <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加配置项</button>
| </div>
| </script>
| {/block}
| <!-- /主体 -->
|
| <!-- 脚本 -->
| {block name="script"}
| <script>
| const moduleInit = ['tool'];
| function gouguInit() {
| var table = layui.table, tool = layui.tool, form = layui.form;
| layui.pageTable = table.render({
| elem: '#conf',
| title: '配置列表',
| toolbar: '#toolbarDemo',
| defaultToolbar: false,
| url: "/home/conf/index",
| cellMinWidth: 80,
| page: false, //开启分页
| limit: 20,
| cols: [
| [{
| field: 'id',
| width: 80,
| title: 'ID编号',
| align: 'center'
| }, {
| field: 'title',
| width: 200,
| title: '配置名称'
| }, {
| field: 'name',
| title: '配置标识<span class="red">(新增的模板文件名称需与标识名称一致)</span>'
| }, {
| field: 'status',
| width: 80,
| title: '状态',
| templet: '#status',
| align: 'center'
| }, {
| width: 160,
| title: '操作',
| align: 'center',
| templet: function (d) {
| var html = '<div class="layui-btn-group"><button class="layui-btn layui-btn-xs" lay-event="add">修改</button><button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" >编辑配置</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button></div>';
| return html;
| }
| }]
| ]
| });
|
| //表头工具栏事件
| table.on('toolbar(conf)', function (obj) {
| if (obj.event === 'add') {
| tool.side("/home/conf/add");
| return;
| }
| });
|
| //监听行工具事件
| table.on('tool(conf)', function (obj) {
| var data = obj.data;
| if (obj.event === 'add') {
| tool.side('/home/conf/add?id=' + data.id);
| return;
| }
| if (obj.event === 'edit') {
| tool.side('/home/conf/edit?id=' + data.id);
| return;
| }
| if (obj.event === 'del') {
| if(obj.data.id == 1){
| layer.msg('系统配置不支持删除');
| return false;
| }
| layer.confirm('确定要删除吗?', {
| icon: 3,
| title: '提示'
| }, function (index) {
| let callback = function (e) {
| layer.msg(e.msg);
| if (e.code == 0) {
| obj.del();
| layer.close(index);
| }
| }
| tool.delete("/home/conf/delete", { id: obj.data.id }, callback);
| });
| }
| });
| }
| </script>
| {/block}
| <!-- /脚本 -->
|
|