123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- {extend name="common/base"/}
- <!-- 主体 -->
- {block name="body"}
- <div class="p-3">
- <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){ }}layui-icon-ok{{# } else { }}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',
- url: "/admin/conf/index",
- page: true, //开启分页
- limit: 20,
- cols: [
- [{
- field: 'id',
- width: 80,
- title: 'ID编号',
- align: 'center'
- }, {
- field: 'title',
- width: 200,
- title: '配置名称'
- }, {
- field: 'name',
- title: '配置标识(新增的模板文件名称需与标识名称一致)'
- }, {
- 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("/admin/conf/add");
- return;
- }
- });
-
- //监听行工具事件
- table.on('tool(conf)', function (obj) {
- var data = obj.data;
- if (obj.event === 'add') {
- tool.side('/admin/conf/add?id=' + data.id);
- return;
- }
- if (obj.event === 'edit') {
- tool.side('/admin/conf/edit?id=' + data.id);
- return;
- }
- if (obj.event === 'del') {
- 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("/admin/conf/delete", { id: obj.data.id }, callback);
- });
- }
- });
- //监听搜索提交
- form.on('submit(webform)', function (data) {
- if (data.field.keywords) {
- tableIns.reload({
- where: { keywords: data.field.keywords }, page: { curr: 1 }
- });
- } else {
- location.reload();
- }
- return false;
- });
- }
- </script>
- {/block}
- <!-- /脚本 -->
|