index.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <div class="p-3">
  5. <form class="layui-form gg-form-bar border-t border-x">
  6. <div class="layui-input-inline" style="width:300px;">
  7. <input type="text" name="keywords" placeholder="ID/标题/标识/备注" class="layui-input" />
  8. </div>
  9. <div class="layui-input-inline">
  10. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
  11. </div>
  12. </form>
  13. <table class="layui-hide" id="nav" lay-filter="nav"></table>
  14. </div>
  15. <script type="text/html" id="status">
  16. <i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
  17. </script>
  18. <script type="text/html" id="toolbarDemo">
  19. <div class="layui-btn-container">
  20. <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加导航组</button>
  21. </div>
  22. </script>
  23. <script type="text/html" id="barDemo">
  24. <div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-xs layui-btn-normal" href="/admin/nav/nav_info?id={{d.id}}">管理导航</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
  25. </script>
  26. {/block}
  27. <!-- /主体 -->
  28. <!-- 脚本 -->
  29. {block name="script"}
  30. <script>
  31. const moduleInit = ['tool'];
  32. function gouguInit() {
  33. var table = layui.table,tool = layui.tool, form = layui.form;
  34. layui.pageTable = table.render({
  35. elem: '#nav',
  36. toolbar: '#toolbarDemo',
  37. url: '/admin/nav/index', //数据接口
  38. page: true, //开启分页
  39. limit: 20,
  40. cols: [
  41. [ //表头
  42. {
  43. field: 'id',
  44. title: 'ID号',
  45. align: 'center',
  46. width: 90
  47. }, {
  48. field: 'title',
  49. title: '标题',
  50. width: 300
  51. }, {
  52. field: 'name',
  53. title: '标识',
  54. align: 'center',
  55. width: 150
  56. }, {
  57. field: 'desc',
  58. title: '备注',
  59. }, {
  60. field: 'status',
  61. title: '状态',
  62. toolbar: '#status',
  63. align: 'center',
  64. width: 80
  65. }, {
  66. field: 'right',
  67. title: '操作',
  68. toolbar: '#barDemo',
  69. width: 160,
  70. align: 'center'
  71. }
  72. ]
  73. ]
  74. });
  75. //表头工具栏事件
  76. table.on('toolbar(nav)', function (obj) {
  77. if (obj.event === 'add') {
  78. tool.side("/admin/nav/add");
  79. return;
  80. }
  81. });
  82. //监听行工具事件
  83. table.on('tool(nav)', function (obj) {
  84. var data = obj.data;
  85. if (obj.event === 'edit') {
  86. tool.side('/admin/nav/add?id=' + obj.data.id);
  87. return;
  88. }
  89. if (obj.event === 'del') {
  90. layer.confirm('真的删除该导航组吗?', {
  91. icon: 3,
  92. title: '提示'
  93. }, function (index) {
  94. let callback = function (e) {
  95. layer.msg(e.msg);
  96. if (e.code == 0) {
  97. obj.del();
  98. }
  99. }
  100. tool.delete("/admin/nav/delete", { id: data.id }, callback);
  101. layer.close(index);
  102. });
  103. }
  104. });
  105. //监听搜索提交
  106. form.on('submit(webform)', function (data) {
  107. layui.pageTable.reload({
  108. where: { keywords: data.field.keywords },
  109. page: { curr: 1 }
  110. });
  111. return false;
  112. });
  113. }
  114. </script>
  115. {/block}
  116. <!-- /脚本 -->