datalist.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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">
  7. <select name="cate_id">
  8. <option value="">请选择图集分类</option>
  9. {volist name=":set_recursion(get_gallery_cate())" id="v"}
  10. <option value="{$v.id}">{$v.title}</option>
  11. {/volist}
  12. </select>
  13. </div>
  14. <div class="layui-input-inline" style="width:300px;">
  15. <input type="text" name="keywords" placeholder="ID/标题/分类/摘要" class="layui-input" autocomplete="off" />
  16. </div>
  17. <div class="layui-input-inline">
  18. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
  19. </div>
  20. </form>
  21. <table class="layui-hide" id="gallery" lay-filter="gallery"></table>
  22. </div>
  23. <script type="text/html" id="status">
  24. <i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
  25. </script>
  26. <script type="text/html" id="is_home">
  27. <i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
  28. </script>
  29. <script type="text/html" id="toolbarDemo">
  30. <div class="layui-btn-container">
  31. <span class="layui-btn layui-btn-sm tab-a" data-title="添加图集" data-href="/admin/gallery/add">+ 添加图集</span>
  32. </div>
  33. </script>
  34. <script type="text/html" id="barDemo">
  35. <div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
  36. </script>
  37. {/block}
  38. <!-- /主体 -->
  39. <!-- 脚本 -->
  40. {block name="script"}
  41. <script>
  42. const moduleInit = ['tool'];
  43. function gouguInit() {
  44. var table = layui.table,tool = layui.tool, form = layui.form;
  45. layui.pageTable = table.render({
  46. elem: '#gallery',
  47. title: '图集列表',
  48. toolbar: '#toolbarDemo',
  49. url: '/admin/gallery/datalist', //数据接口
  50. page: true, //开启分页
  51. limit: 20,
  52. cols: [
  53. [ //表头
  54. {
  55. field: 'id',
  56. title: '编号',
  57. align: 'center',
  58. width: 80
  59. }, {
  60. field: 'cate_title',
  61. title: '分类',
  62. width: 200
  63. }, {
  64. field: 'title',
  65. title: '标题'
  66. },{
  67. field: 'count',
  68. title: '图片数',
  69. align: 'center',
  70. width: 80
  71. },{
  72. field: 'sort',
  73. title: '排序',
  74. align: 'center',
  75. width: 80
  76. }, {
  77. field: 'status',
  78. title: '状态',
  79. toolbar: '#status',
  80. align: 'center',
  81. width: 66
  82. }, {
  83. field: 'is_home',
  84. title: '首页显示',
  85. toolbar: '#is_home',
  86. align: 'center',
  87. width: 90
  88. },{
  89. field: 'admin_name',
  90. title: '创建人',
  91. align: 'center',
  92. width: 90
  93. },{
  94. field: 'create_time',
  95. title: '创建时间',
  96. align: 'center',
  97. width: 150
  98. }, {
  99. field: 'right',
  100. title: '操作',
  101. toolbar: '#barDemo',
  102. width: 150,
  103. align: 'center'
  104. }
  105. ]
  106. ]
  107. });
  108. //监听行工具事件
  109. table.on('tool(gallery)', function(obj) {
  110. var data = obj.data;
  111. if (obj.event === 'view') {
  112. tool.side('/admin/gallery/read?id='+obj.data.id);
  113. }
  114. else if (obj.event === 'edit') {
  115. tool.tabAdd('/admin/gallery/edit?id='+obj.data.id,'编辑图集'+obj.data.id);
  116. }
  117. else if (obj.event === 'del') {
  118. layer.confirm('确定要删除吗?', {
  119. icon: 3,
  120. title: '提示'
  121. }, function(index) {
  122. let callback = function (e) {
  123. layer.msg(e.msg);
  124. if (e.code == 0) {
  125. obj.del();
  126. }
  127. }
  128. tool.delete("/admin/gallery/del", { id: data.id }, callback);
  129. layer.close(index);
  130. });
  131. }
  132. });
  133. //监听搜索提交
  134. form.on('submit(webform)', function(data) {
  135. layui.pageTable.reload({
  136. where: {
  137. keywords: data.field.keywords,
  138. cate_id: data.field.cate_id
  139. },
  140. page: {
  141. curr: 1
  142. }
  143. });
  144. return false;
  145. });
  146. }
  147. </script>
  148. {/block}
  149. <!-- /脚本 -->