index.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. {/block}
  4. {block name="content"}
  5. <div class="layui-fluid" style="background: #fff;margin-top: -10px;">
  6. <div class="layui-row layui-col-space15">
  7. <div class="layui-col-md12">
  8. <div class="layui-card">
  9. <div class="layui-card-body">
  10. <div class="layui-btn-container">
  11. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('addChannel')}',{h:480,w:720})">
  12. 添加渠道
  13. </button>
  14. </div>
  15. <table class="layui-hide" id="List" lay-filter="List"></table>
  16. <script type="text/html" id="act">
  17. <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
  18. 编辑
  19. </button>
  20. <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='del'>
  21. 删除
  22. </button>
  23. </script>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  30. {/block}
  31. {block name="script"}
  32. <script>
  33. layList.tableList('List', "{:Url('channelList')}", function() {
  34. return [{
  35. field: 'id',
  36. title: 'ID',
  37. sort: true,
  38. event: 'id',
  39. width: '20%'
  40. },
  41. {
  42. field: 'name',
  43. title: '渠道名称',
  44. width: '30%'
  45. },
  46. {
  47. field: 'code',
  48. title: '渠道代码',
  49. width: '30%'
  50. },
  51. {
  52. field: 'right',
  53. title: '操作',
  54. align: 'center',
  55. toolbar: '#act',
  56. width: '20%'
  57. },
  58. ];
  59. });
  60. //点击事件绑定
  61. layList.tool(function(event, data, obj) {
  62. switch (event) {
  63. case 'del':
  64. var url = layList.U({
  65. c: 'user.user_channel',
  66. a: 'delete',
  67. q: {
  68. id: data.id
  69. }
  70. });
  71. var code = {
  72. title: "操作提示",
  73. text: "确定删除该渠道?",
  74. type: 'info',
  75. confirm: '是的,删除'
  76. };
  77. $eb.$swal('delete', function() {
  78. $eb.axios.get(url).then(function(res) {
  79. if (res.status == 200 && res.data.code == 200) {
  80. $eb.$swal('success', res.data.msg);
  81. obj.del();
  82. location.reload();
  83. } else
  84. return Promise.reject(res.data.msg || '删除失败')
  85. }).catch(function(err) {
  86. $eb.$swal('error', err);
  87. });
  88. }, code)
  89. break;
  90. case 'open_image':
  91. $eb.openImage(data.image);
  92. break;
  93. case 'edit':
  94. $eb.createModalFrame(data.name + '-编辑', layList.U({
  95. a: 'addChannel',
  96. q: {
  97. id: data.id
  98. }
  99. }), {
  100. h: 480,
  101. w: 720
  102. });
  103. break;
  104. }
  105. })
  106. </script>
  107. {/block}