截流自动化的商城平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

lists.html 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="layui-card-body">
  16. <!--添加按钮-->
  17. <div style="padding-bottom: 10px;">
  18. <button class="layui-btn layui-btn-sm layuiadmin-btn-unit {$view_theme_color}" data-type="add">新增商品单位</button>
  19. </div>
  20. <!--表格-->
  21. <table id="unit-lists" lay-filter="unit-lists"></table>
  22. <script type="text/html" id="unit-operation">
  23. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  24. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  25. </script>
  26. </div>
  27. </div>
  28. </div>
  29. <script>
  30. layui.use(['table'], function(){
  31. var form = layui.form
  32. ,table = layui.table;
  33. //事件
  34. var active = {
  35. add: function(){
  36. layer.open({
  37. type: 2
  38. ,title: '新增商品单位'
  39. ,content: '{:url("goods.unit/add")}'
  40. ,area: ['60%', '60%']
  41. ,btn: ['确定', '取消']
  42. ,yes: function(index, layero){
  43. var iframeWindow = window['layui-layer-iframe'+ index]
  44. ,submitID = 'unit-submit'
  45. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  46. //监听提交
  47. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  48. var field = data.field;
  49. like.ajax({
  50. url:'{:url("goods.unit/add")}',
  51. data:field,
  52. type:"post",
  53. success:function(res)
  54. {
  55. if(res.code == 1) {
  56. layui.layer.msg(res.msg, {
  57. offset: '15px'
  58. , icon: 1
  59. , time: 1000
  60. });
  61. layer.close(index);
  62. table.reload('unit-lists');
  63. }
  64. }
  65. });
  66. });
  67. submit.trigger('click');
  68. }
  69. });
  70. }
  71. };
  72. $('.layui-btn.layuiadmin-btn-unit').on('click', function(){
  73. var type = $(this).data('type');
  74. active[type] ? active[type].call(this) : '';
  75. });
  76. like.tableLists('#unit-lists', '{:url("goods.unit/lists")}', [
  77. {field: 'id', width: 60, title: 'ID', sort: true}
  78. ,{field: 'name', title: '单位名称', align:"center"}
  79. ,{field: 'sort', title: '排序', align:"center", sort:true}
  80. ,{title: '操作', align: 'center', fixed: 'right', toolbar: '#unit-operation'}
  81. ]);
  82. //监听工具条
  83. table.on('tool(unit-lists)', function(obj){
  84. if(obj.event === 'del'){
  85. var id = obj.data.id;
  86. var unitName = "<span style='color: red;'>"+obj.data.name+"</span>";
  87. layer.confirm('确定删除商品单位: '+unitName, function(index){
  88. like.ajax({
  89. url:'{:url("goods.unit/del")}',
  90. data:{'id':id},
  91. type:"post",
  92. success:function(res)
  93. {
  94. if(res.code == 1) {
  95. obj.del();
  96. layui.layer.msg(res.msg, {
  97. offset: '15px'
  98. , icon: 1
  99. , time: 1000
  100. });
  101. layer.close(index);
  102. }
  103. }
  104. });
  105. });
  106. }else if(obj.event === 'edit'){
  107. var id = obj.data.id;
  108. layer.open({
  109. type: 2
  110. ,title: '编辑编辑商品单位'
  111. ,content: '{:url("goods.unit/edit")}?unit_id='+id
  112. ,area: ['60%', '60%']
  113. ,btn: ['确定', '取消']
  114. ,yes: function(index, layero){
  115. var iframeWindow = window['layui-layer-iframe'+ index]
  116. ,submitID = 'unit-submit-edit'
  117. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  118. //监听提交
  119. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  120. var field = data.field;
  121. like.ajax({
  122. url:'{:url("goods.unit/edit")}',
  123. data:field,
  124. type:"post",
  125. success:function(res)
  126. {
  127. if(res.code == 1) {
  128. layui.layer.msg(res.msg, {
  129. offset: '15px'
  130. , icon: 1
  131. , time: 1000
  132. });
  133. layer.close(index);
  134. table.reload('unit-lists');
  135. }
  136. }
  137. });
  138. });
  139. submit.trigger('click');
  140. }
  141. })
  142. }
  143. });
  144. });
  145. </script>