slide_info.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <div class="p-3">
  5. <table class="layui-hide" id="slide_info" lay-filter="slide_info"></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 add-menu">+ 添加轮播</button>
  13. <button class="layui-btn layui-btn-primary layui-btn-sm add-back">返回</button>
  14. </div>
  15. </script>
  16. <script type="text/html" id="barDemo">
  17. <div class="layui-btn-group"><button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button></a>
  18. </script>
  19. {/block}
  20. <!-- /主体 -->
  21. <!-- 脚本 -->
  22. {block name="script"}
  23. <script>
  24. var slide_id = '{$slide_id}';
  25. const moduleInit = ['tool'];
  26. function gouguInit() {
  27. var table = layui.table, tool = layui.tool;
  28. layui.pageTable = table.render({
  29. elem: '#slide_info',
  30. title: '轮播列表',
  31. toolbar: '#toolbarDemo',
  32. url: '/admin/slide/slide_info', //数据接口
  33. where: {
  34. id: slide_id
  35. },
  36. page: false, //开启分页
  37. cols: [
  38. [
  39. {
  40. field: 'id',
  41. title: 'ID号',
  42. align: 'center',
  43. width: 80
  44. }, {
  45. field: 'sort',
  46. title: '排序',
  47. align: 'center',
  48. width: 80
  49. }, {
  50. field: 'title',
  51. title: '标题',
  52. width: 300
  53. }, {
  54. field: 'img',
  55. title: '图片',
  56. width: 136,
  57. align: 'center',
  58. templet: function (d) {
  59. var html = '<img src="' + d.filepath + '" style="max-width: 100px;" />';
  60. return html;
  61. }
  62. }, {
  63. field: 'desc',
  64. title: '描述'
  65. }, {
  66. field: 'status',
  67. title: '状态',
  68. toolbar: '#status',
  69. align: 'center',
  70. width: 80
  71. }, {
  72. field: 'right',
  73. title: '操作',
  74. toolbar: '#barDemo',
  75. width: 100,
  76. align: 'center'
  77. }
  78. ]
  79. ]
  80. });
  81. //表头工具栏事件
  82. $('body').on('click', '.add-menu', function () {
  83. tool.side("/admin/slide/slide_info_add?sid=" + slide_id);
  84. return;
  85. });
  86. //监听返回
  87. $('body').on('click', '.add-back', function () {
  88. history.back(-1);
  89. return false;
  90. });
  91. //监听行工具事件
  92. table.on('tool(slide_info)', function (obj) {
  93. var data = obj.data;
  94. if (obj.event === 'edit') {
  95. tool.side('/admin/slide/slide_info_add?id=' + obj.data.id);
  96. return;
  97. }
  98. if (obj.event === 'del') {
  99. layer.confirm('确定删除该轮播数据吗?', {
  100. icon: 3,
  101. title: '提示'
  102. }, function (index) {
  103. let callback = function (e) {
  104. layer.msg(e.msg);
  105. if (e.code == 0) {
  106. obj.del();
  107. }
  108. }
  109. tool.delete("/admin/slide/slide_info_delete", { id: data.id }, callback);
  110. layer.close(index);
  111. });
  112. }
  113. });
  114. }
  115. </script>
  116. {/block}
  117. <!-- /脚本 -->