index.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="sitemap" lay-filter="sitemap"></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/sitemap/sitemap_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: '#sitemap',
  36. title: '网站地图分类列表',
  37. toolbar: '#toolbarDemo',
  38. url: '/admin/sitemap/index', //数据接口
  39. page: true, //开启分页
  40. limit: 20,
  41. cols: [
  42. [ //表头
  43. {
  44. field: 'id',
  45. title: 'ID号',
  46. align: 'center',
  47. width: 80
  48. }, {
  49. field: 'sort',
  50. title: '排序',
  51. align: 'center',
  52. width: 80
  53. }, {
  54. field: 'name',
  55. title: '网站地图分类名称'
  56. }, {
  57. field: 'right',
  58. title: '操作',
  59. toolbar: '#barDemo',
  60. align: 'center',
  61. width: 200
  62. }
  63. ]
  64. ]
  65. });
  66. //表头工具栏事件
  67. table.on('toolbar(sitemap)', function (obj) {
  68. if (obj.event === 'add') {
  69. tool.side("/admin/sitemap/add", "900px");
  70. return;
  71. }
  72. });
  73. //监听行工具事件
  74. table.on('tool(sitemap)', function (obj) {
  75. var data = obj.data;
  76. if (obj.event === 'edit') {
  77. tool.side('/admin/sitemap/add?id=' + obj.data.id, "900px");
  78. return;
  79. }
  80. if (obj.event === 'del') {
  81. layer.confirm('确定要删除该数据吗?', {
  82. icon: 3,
  83. title: '提示'
  84. }, function (index) {
  85. let callback = function (e) {
  86. layer.msg(e.msg);
  87. if (e.code == 0) {
  88. obj.del();
  89. }
  90. }
  91. tool.delete("/admin/sitemap/delete", { id: data.id }, callback);
  92. layer.close(index);
  93. });
  94. }
  95. });
  96. //监听搜索提交
  97. form.on('submit(webform)', function (data) {
  98. layui.pageTable.reload({
  99. where: {
  100. keywords: data.field.keywords
  101. },
  102. page: {
  103. curr: 1
  104. }
  105. });
  106. return false;
  107. });
  108. }
  109. </script>
  110. {/block}
  111. <!-- /脚本 -->