index.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {extend name="../../base/view/common/base" /}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <div class="p-page">
  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){ }}green layui-icon-ok{{# } else { }}red 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. defaultToolbar: false,
  28. url: "/home/conf/index",
  29. cellMinWidth: 80,
  30. page: false, //开启分页
  31. limit: 20,
  32. cols: [
  33. [{
  34. field: 'id',
  35. width: 80,
  36. title: 'ID编号',
  37. align: 'center'
  38. }, {
  39. field: 'title',
  40. width: 200,
  41. title: '配置名称'
  42. }, {
  43. field: 'name',
  44. title: '配置标识<span class="red">(新增的模板文件名称需与标识名称一致)</span>'
  45. }, {
  46. field: 'status',
  47. width: 80,
  48. title: '状态',
  49. templet: '#status',
  50. align: 'center'
  51. }, {
  52. width: 160,
  53. title: '操作',
  54. align: 'center',
  55. templet: function (d) {
  56. 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>';
  57. return html;
  58. }
  59. }]
  60. ]
  61. });
  62. //表头工具栏事件
  63. table.on('toolbar(conf)', function (obj) {
  64. if (obj.event === 'add') {
  65. tool.side("/home/conf/add");
  66. return;
  67. }
  68. });
  69. //监听行工具事件
  70. table.on('tool(conf)', function (obj) {
  71. var data = obj.data;
  72. if (obj.event === 'add') {
  73. tool.side('/home/conf/add?id=' + data.id);
  74. return;
  75. }
  76. if (obj.event === 'edit') {
  77. tool.side('/home/conf/edit?id=' + data.id);
  78. return;
  79. }
  80. if (obj.event === 'del') {
  81. if(obj.data.id == 1){
  82. layer.msg('系统配置不支持删除');
  83. return false;
  84. }
  85. layer.confirm('确定要删除吗?', {
  86. icon: 3,
  87. title: '提示'
  88. }, function (index) {
  89. let callback = function (e) {
  90. layer.msg(e.msg);
  91. if (e.code == 0) {
  92. obj.del();
  93. layer.close(index);
  94. }
  95. }
  96. tool.delete("/home/conf/delete", { id: obj.data.id }, callback);
  97. });
  98. }
  99. });
  100. }
  101. </script>
  102. {/block}
  103. <!-- /脚本 -->