截流自动化的商城平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

lists.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. {layout name="layout1" /}
  2. <!-- 样式 -->
  3. <style>
  4. .layui-table-cell {
  5. height: auto;
  6. }
  7. </style>
  8. <div class="wrapper">
  9. <div class="layui-card">
  10. <!--操作提示-->
  11. <div class="layui-card-body">
  12. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  13. <div class="layui-colla-item">
  14. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  15. <div class="layui-colla-content layui-show">
  16. <p>*添加积分商城商品。</p>
  17. <p>*兑换类型为"红包"时,无需物流配送,付完款直接是已完成状态。</p>
  18. <p>*兑换类型为"商品"时,可以做发货操作。</p>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="layui-card-body">
  24. <!--添加按钮-->
  25. <div style="padding-bottom: 10px;">
  26. <button class="layui-btn layui-btn-sm {$view_theme_color} layEvent" lay-event="add">添加积分商品</button>
  27. </div>
  28. <!--搜索条件-->
  29. <div class="layui-form">
  30. <div class="layui-form-item">
  31. <div class="layui-inline">
  32. <label class="layui-form-label">礼品名称:</label>
  33. <div class="layui-input-block">
  34. <input type="text" name="name" id="name" placeholder="请输入礼品名称"
  35. autocomplete="off" class="layui-input">
  36. </div>
  37. </div>
  38. <div class="layui-inline">
  39. <label class="layui-form-label">兑换类型</label>
  40. <div class="layui-input-block">
  41. <select name="type" id="search_type">
  42. <option value="">全部</option>
  43. <option value="1">商品</option>
  44. <option value="2">红包</option>
  45. </select>
  46. </div>
  47. </div>
  48. <div class="layui-inline">
  49. <label class="layui-form-label">商品状态</label>
  50. <div class="layui-input-block">
  51. <select name="status" id="search_status">
  52. <option value="">全部</option>
  53. <option value="1">上架</option>
  54. <option value="0">下架</option>
  55. </select>
  56. </div>
  57. </div>
  58. <div class="layui-inline">
  59. <button class="layui-btn layui-btn-sm layuiadmin-btn-goods_brand {$view_theme_color}" lay-submit lay-filter="like-search">
  60. <i class="layui-icon layuiadmin-button-btn"></i>查询
  61. </button>
  62. </div>
  63. <div class="layui-inline">
  64. <button class="layui-btn layui-btn-sm layui-btn-primary layuiadmin-btn-goods_brand " lay-submit lay-filter="like-clear-search">清空查询</button>
  65. </div>
  66. </div>
  67. </div>
  68. <!--表格-->
  69. <table id="like-table-lists" lay-filter="like-table-lists"></table>
  70. <script type="text/html" id="statusTpl">
  71. <input type="checkbox" lay-filter="switch-status" data-id={{d.id}} lay-skin="switch"
  72. lay-text="上架|下架" {{# if(d.status){ }} checked {{# } }} />
  73. </script>
  74. <script type="text/html" id="goodsBrand-operation">
  75. <a class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  76. <a class="layui-btn layui-btn-danger layui-btn-sm layEvent" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  77. </script>
  78. <script type="text/html" id="nameTpl">
  79. <div style="text-align: left">
  80. <img src="{{d.image}}" style="height:80px;width: 80px" class="image-show">
  81. <div class="layui-input-inline" style="text-align:left;width: 240px">
  82. <p>{{d.name}}</p>
  83. </div>
  84. </div>
  85. </script>
  86. <script type="text/html" id="stockTpl">
  87. {{# if(d.stock == '0'){ }}
  88. <span style="color: red">{{d.stock}}</span>
  89. {{# } else { }}
  90. <span>{{d.stock}}</span>
  91. {{# } }}
  92. </script>
  93. </div>
  94. </div>
  95. </div>
  96. <script>
  97. layui.use(['table'], function(){
  98. var form = layui.form
  99. ,table = layui.table;
  100. //监听搜索
  101. form.on('submit(like-search)', function(data){
  102. var field = data.field;
  103. //执行重载
  104. table.reload('like-table-lists', {
  105. where: field,
  106. page: {curr: 1},
  107. });
  108. });
  109. //清空查询
  110. form.on('submit(like-clear-search)', function () {
  111. $('#name').val("");
  112. $('#search_type').val("");
  113. $('#search_status').val("");
  114. form.render('select');
  115. //刷新列表
  116. table.reload('like-table-lists', {
  117. where: [],
  118. page: {curr: 1},
  119. });
  120. });
  121. //切换状态
  122. form.on('switch(switch-status)',function (obj) {
  123. var id = obj.elem.attributes['data-id'].nodeValue;
  124. var status = this.checked ? 1 : 0;
  125. like.ajax({
  126. url:'{:url("integral.IntegralGoods/switchStatus")}',
  127. data:{id:id,status:status},
  128. type:'post',
  129. success:function (res) {
  130. if(res.code == 1) {
  131. layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
  132. }
  133. }
  134. });
  135. });
  136. $(document).on('click', '.image-show', function () {
  137. var src = $(this).attr('src');
  138. like.showImg(src,400);
  139. });
  140. //事件
  141. var active = {
  142. add: function(){
  143. layer.open({
  144. type: 2
  145. ,title: '添加商品'
  146. ,content: '{:url("integral.IntegralGoods/add")}'
  147. ,area: ['90%', '90%']
  148. ,btn: ['确定', '取消']
  149. ,yes: function(index, layero) {
  150. var iframeWindow = window['layui-layer-iframe'+ index]
  151. ,submitID = 'addSubmit'
  152. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  153. //监听提交
  154. iframeWindow.layui.form.on('submit('+ submitID +')', function(data) {
  155. var field = data.field;
  156. like.ajax({
  157. url:'{:url("integral.IntegralGoods/add")}',
  158. data:field,
  159. type:"post",
  160. success:function(res)
  161. {
  162. if(res.code == 1) {
  163. layui.layer.msg(res.msg, {
  164. offset: '15px'
  165. , icon: 1
  166. , time: 1000
  167. });
  168. layer.close(index);
  169. table.reload('like-table-lists');
  170. }
  171. }
  172. });
  173. });
  174. submit.trigger('click');
  175. }
  176. });
  177. },
  178. edit: function (obj) {
  179. var id = obj.data.id;
  180. layer.open({
  181. type: 2
  182. ,title: '编辑商品'
  183. ,content: '{:url("integral.IntegralGoods/edit")}?id='+id
  184. ,area: ['90%', '90%']
  185. ,btn: ['确定', '取消']
  186. ,yes: function(index, layero){
  187. var iframeWindow = window['layui-layer-iframe'+ index]
  188. ,submitID = 'addSubmit'
  189. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  190. //监听提交
  191. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  192. var field = data.field;
  193. like.ajax({
  194. url:'{:url("integral.IntegralGoods/edit")}',
  195. data:field,
  196. type:"post",
  197. success:function(res)
  198. {
  199. if(res.code == 1) {
  200. layui.layer.msg(res.msg, {
  201. offset: '15px'
  202. , icon: 1
  203. , time: 1000
  204. });
  205. layer.close(index);
  206. table.reload('like-table-lists');
  207. }
  208. }
  209. });
  210. });
  211. submit.trigger('click');
  212. }
  213. })
  214. },
  215. del: function (obj) {
  216. var unitName = "<span style='color: red;'>"+obj.data.name+"</span>";
  217. layer.confirm('确定删除商品品牌: '+unitName, function(index) {
  218. like.ajax({
  219. url:'{:url("integral.IntegralGoods/del")}',
  220. data:{'id':obj.data.id},
  221. type:"post",
  222. success:function(res)
  223. {
  224. if(res.code == 1) {
  225. obj.del();
  226. layui.layer.msg(res.msg, {
  227. offset: '15px'
  228. , icon: 1
  229. , time: 1000
  230. });
  231. layer.close(index);
  232. }
  233. }
  234. });
  235. });
  236. }
  237. };
  238. like.eventClick(active);
  239. //列表
  240. like.tableLists('#like-table-lists', '{:url("integral.IntegralGoods/lists")}', [
  241. {field: 'id', width: 60, title: 'ID', sort: true}
  242. ,{field: 'name', title: '商品名称', width: 260, align:"center", templet: "#nameTpl"}
  243. ,{field: 'type', title: '兑换类型', align:"center", templet: "#image"}
  244. ,{field: 'stock', title: '库存', align:"center", templet: "#stockTpl"}
  245. ,{field: 'need', title: '兑换积分', align:"center"}
  246. ,{field: 'sort', title: '排序', align:"center"}
  247. ,{field: 'status', title: '商品状态', align:"center", templet:'#statusTpl'}
  248. ,{title: '操作', align: 'center', width: 260, fixed: 'right', toolbar: '#goodsBrand-operation'}
  249. ]);
  250. });
  251. </script>