index.html 2.8 KB

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