截流自动化的商城平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

lists.html 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <!--操作提示-->
  5. <div class="layui-card-body">
  6. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  7. <div class="layui-colla-item">
  8. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  9. <div class="layui-colla-content layui-show">
  10. <p>*商品栏目能很方便的聚合商品荐列表。</p>
  11. <p>*商品栏目在首页、购物车、个人中心显示,可任意删除,请谨慎操作。</p>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="layui-card-body">
  17. <!--添加按钮-->
  18. <div style="padding-bottom: 10px;">
  19. <button class="layui-btn layui-btn-sm layuiadmin-btn-goodsColumn {$view_theme_color}" data-type="add">新增商品栏目</button>
  20. </div>
  21. <!--表格-->
  22. <table id="goodsColumn-lists" lay-filter="goodsColumn-lists"></table>
  23. <script type="text/html" id="statusTpl">
  24. <input type="checkbox" lay-filter="switch-status" data-id={{d.id}} data-field='status' lay-skin="switch"
  25. lay-text="显示|隐藏" {{# if(d.status){ }} checked {{# } }} />
  26. </script>
  27. <script type="text/html" id="goodsColumn-operation">
  28. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  29. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  30. </script>
  31. </div>
  32. </div>
  33. </div>
  34. <script>
  35. layui.use(['table'], function(){
  36. var form = layui.form
  37. ,table = layui.table;
  38. //事件
  39. var active = {
  40. add: function(){
  41. layer.open({
  42. type: 2
  43. ,title: '新增商品栏目'
  44. ,content: '{:url("goods.column/add")}'
  45. ,area: ['60%', '60%']
  46. ,btn: ['确定', '取消']
  47. ,yes: function(index, layero){
  48. var iframeWindow = window['layui-layer-iframe'+ index]
  49. ,submitID = 'goodsColumn-submit'
  50. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  51. //监听提交
  52. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  53. var field = data.field;
  54. like.ajax({
  55. url:'{:url("goods.column/add")}',
  56. data:field,
  57. type:"post",
  58. success:function(res)
  59. {
  60. if(res.code == 1) {
  61. layui.layer.msg(res.msg, {
  62. offset: '15px'
  63. , icon: 1
  64. , time: 1000
  65. });
  66. layer.close(index);
  67. table.reload('goodsColumn-lists');
  68. }
  69. }
  70. });
  71. });
  72. submit.trigger('click');
  73. }
  74. });
  75. }
  76. };
  77. $('.layui-btn.layuiadmin-btn-goodsColumn').on('click', function(){
  78. var type = $(this).data('type');
  79. active[type] ? active[type].call(this) : '';
  80. });
  81. like.tableLists('#goodsColumn-lists', '{:url("goods.column/lists")}', [
  82. {field: 'id', width: 60, title: 'ID', sort: true}
  83. ,{field: 'name', title: '栏目名称', align:"center"}
  84. ,{field: 'remark', title: '栏目简介', align:"center"}
  85. ,{field: 'status', title: '栏目状态', align:"center", templet:'#statusTpl'}
  86. ,{title: '操作', align: 'center', fixed: 'right', toolbar: '#goodsColumn-operation'}
  87. ]);
  88. form.on('switch(switch-status)',function (obj) {
  89. var id = obj.elem.attributes['data-id'].nodeValue;
  90. var status = 0;
  91. if(this.checked){
  92. status = 1;
  93. }
  94. like.ajax({
  95. url:'{:url("goods.column/switchStatus")}',
  96. data:{id:id,status:status},
  97. type:'post',
  98. success:function (res) {
  99. if(res.code == 1) {
  100. layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
  101. }
  102. }
  103. });
  104. });
  105. //监听工具条
  106. table.on('tool(goodsColumn-lists)', function(obj){
  107. if(obj.event === 'del'){
  108. var id = obj.data.id;
  109. var unitName = "<span style='color: red;'>"+obj.data.name+"</span>";
  110. layer.confirm('确定删除商品栏目: '+unitName, function(index){
  111. like.ajax({
  112. url:'{:url("goods.column/del")}',
  113. data:{'id':id},
  114. type:"post",
  115. success:function(res)
  116. {
  117. if(res.code == 1) {
  118. obj.del();
  119. layui.layer.msg(res.msg, {
  120. offset: '15px'
  121. , icon: 1
  122. , time: 1000
  123. });
  124. layer.close(index);
  125. }
  126. }
  127. });
  128. });
  129. }else if(obj.event === 'edit'){
  130. var id = obj.data.id;
  131. layer.open({
  132. type: 2
  133. ,title: '编辑商品栏目'
  134. ,content: '{:url("goods.column/edit")}?id='+id
  135. ,area: ['60%', '60%']
  136. ,btn: ['确定', '取消']
  137. ,yes: function(index, layero){
  138. var iframeWindow = window['layui-layer-iframe'+ index]
  139. ,submitID = 'goodsColumn-submit-edit'
  140. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  141. //监听提交
  142. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  143. var field = data.field;
  144. like.ajax({
  145. url:'{:url("goods.column/edit")}',
  146. data:field,
  147. type:"post",
  148. success:function(res)
  149. {
  150. if(res.code == 1) {
  151. layui.layer.msg(res.msg, {
  152. offset: '15px'
  153. , icon: 1
  154. , time: 1000
  155. });
  156. layer.close(index);
  157. table.reload('goodsColumn-lists');
  158. }
  159. }
  160. });
  161. });
  162. submit.trigger('click');
  163. }
  164. })
  165. }
  166. });
  167. });
  168. </script>