index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid" style="background: #fff;margin-top: -10px;">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-body">
  8. <form class="layui-form layui-form-pane" action="">
  9. <div class="layui-form-item">
  10. {eq name="type" value="0"}
  11. <div class="layui-inline">
  12. <label class="layui-form-label">门店:</label>
  13. <div class="layui-input-inline">
  14. <select name="store_id" lay-verify="store">
  15. <option value="0">全部</option>
  16. {volist name="store" id="v"}
  17. <option value="{$v.id}">{$v.name}</option>
  18. {/volist}
  19. </select>
  20. </div>
  21. </div>
  22. <div class="layui-inline">
  23. <label class="layui-form-label">类型:</label>
  24. <div class="layui-input-inline">
  25. <select name="is_warn" lay-verify="is_warn">
  26. <option value="0">库存</option>
  27. <option value="1">警告</option>
  28. </select>
  29. </div>
  30. </div>
  31. {/eq}
  32. <div class="layui-inline">
  33. <label class="layui-form-label">商品名称</label>
  34. <div class="layui-input-block">
  35. <input type="text" name="key" class="layui-input" placeholder="请输入商品名称,关键字,编号">
  36. </div>
  37. </div>
  38. <div class="layui-inline">
  39. <div class="layui-input-inline">
  40. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search"
  41. lay-filter="search">
  42. <i class="layui-icon layui-icon-search"></i>搜索
  43. </button>
  44. </div>
  45. </div>
  46. </div>
  47. </form>
  48. </div>
  49. </div>
  50. </div>
  51. <!--商品列表-->
  52. <div class="layui-col-md12">
  53. <div class="layui-card">
  54. <div class="layui-card-body">
  55. <div class="alert alert-info" role="alert">
  56. 列表[虚拟销量],[库存],[排序]可进行快速修改,双击或者单击进入编辑模式,失去焦点可进行自动保存
  57. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
  58. aria-hidden="true">&times;</span></button>
  59. </div>
  60. <div class="layui-btn-container" lay-submit="addKc" lay-filter="addKc">
  61. <button class="layui-btn layui-btn-sm">增减库存</button>
  62. </div>
  63. <table class="layui-hide" id="List" lay-filter="List"></table>
  64. <!--图片-->
  65. <script type="text/html" id="image">
  66. <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
  67. </script>
  68. <!--商品名称-->
  69. <script type="text/html" id="store_name">
  70. <h4>{{d.store_name}}</h4>
  71. <p>价格:<font color="red">{{d.price}}</font></p>
  72. </script>
  73. <!--操作-->
  74. <script type="text/html" id="act">
  75. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
  76. class="caret"></span></button>
  77. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  78. <li>
  79. <a href="javascript:void(0);" lay-event='edit'>
  80. <i class="fa fa-trash"></i> 入库记录
  81. </a>
  82. </li>
  83. </ul>
  84. </script>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  91. <script>
  92. //实例化form
  93. layList.form.render();
  94. //加载列表
  95. layList.tableList('List', "{:Url('product_ist')}", function () {
  96. var join = new Array();
  97. join = [
  98. {field: 'id', title: 'ID', sort: true, event: 'id', width: '6%'},
  99. {field: 'store', title: '门店', width: '10%'},
  100. {field: 'image', title: '商品图片', templet: '#image', width: '10%'},
  101. {field: 'store_name', title: '商品名称', templet: '#store_name'},
  102. {field: 'in_stock', title: '库存', width: '8%'},
  103. {field: 'repair_sales', title: '待补货', width: '8%'},
  104. {field: 'store_sales', title: '销量', width: '8%'},
  105. {field: 'status', title: '状态', templet: "#checkboxstatus", width: '8%'},
  106. {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
  107. ];
  108. return join;
  109. })
  110. //excel下载
  111. layList.search('export', function (where) {
  112. where.excel = 1;
  113. location.href = layList.U({c: 'store.store_product', a: 'product_ist', q: where});
  114. })
  115. //点击弹窗增加库存
  116. layList.search('addKc', function (where) {
  117. layer.prompt({title: '请输入条形码', formType: 0}, function (pass, index) {
  118. layer.close(index);
  119. $eb.axios.post('{:Url("store.Placeorder/getBarCode")}' + (pass ? '?bar_code=' + pass : '')).then(function (res) {
  120. const data = res.data.data;
  121. layer.open({
  122. content: '确认是否为商品' + `${data.store_name}[${data.suk}]¥${data.price}`
  123. , btn: ['确定', '取消'],
  124. yes: function (index) {
  125. layer.close(index);
  126. $eb.createModalFrame('增减库存 - '+data.store_name,layList.U({a: 'edit_stock', q: {bar_code: pass}}),{h:550,w:720})
  127. // layer.prompt({title: '请输入数量', formType: 0}, function (text, index) {
  128. // layer.close(index);
  129. // layList.baseGet(layList.Url({
  130. // c: 'company.goods',
  131. // a: 'save',
  132. // p: {bar_code: pass, in_stock: text}
  133. // }), function (res) {
  134. // layList.msg(res.msg, function () {
  135. // //layList.reload();
  136. // });
  137. // });
  138. // });
  139. }
  140. });
  141. }).catch(function (err) {
  142. console.log(err);
  143. })
  144. });
  145. })
  146. //下拉框
  147. $(document).click(function (e) {
  148. $('.layui-nav-child').hide();
  149. })
  150. function dropdown(that) {
  151. var oEvent = arguments.callee.caller.arguments[0] || event;
  152. oEvent.stopPropagation();
  153. var offset = $(that).offset();
  154. var top = offset.top - $(window).scrollTop();
  155. var index = $(that).parents('tr').data('index');
  156. $('.layui-nav-child').each(function (key) {
  157. if (key != index) {
  158. $(this).hide();
  159. }
  160. })
  161. if ($(document).height() < top + $(that).next('ul').height()) {
  162. $(that).next('ul').css({
  163. 'padding': 10,
  164. 'top': -($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
  165. 'min-width': 'inherit',
  166. 'position': 'absolute'
  167. }).toggle();
  168. } else {
  169. $(that).next('ul').css({
  170. 'padding': 10,
  171. 'top': $(that).parent('td').height() / 2 + $(that).height(),
  172. 'min-width': 'inherit',
  173. 'position': 'absolute'
  174. }).toggle();
  175. }
  176. }
  177. //快速编辑
  178. layList.edit(function (obj) {
  179. var id = obj.data.id, value = obj.value;
  180. switch (obj.field) {
  181. case 'price':
  182. action.set_product('price', id, value);
  183. break;
  184. case 'stock':
  185. action.set_product('stock', id, value);
  186. break;
  187. case 'sort':
  188. action.set_product('sort', id, value);
  189. break;
  190. case 'ficti':
  191. action.set_product('ficti', id, value);
  192. break;
  193. }
  194. });
  195. //上下加商品
  196. layList.switch('is_show', function (odj, value) {
  197. if (odj.elem.checked == true) {
  198. layList.baseGet(layList.Url({
  199. c: 'store.store_product',
  200. a: 'set_show',
  201. p: {is_show: 1, id: value}
  202. }), function (res) {
  203. layList.msg(res.msg, function () {
  204. layList.reload();
  205. });
  206. });
  207. } else {
  208. layList.baseGet(layList.Url({
  209. c: 'store.store_product',
  210. a: 'set_show',
  211. p: {is_show: 0, id: value}
  212. }), function (res) {
  213. layList.msg(res.msg, function () {
  214. layList.reload();
  215. });
  216. });
  217. }
  218. });
  219. //点击事件绑定
  220. layList.tool(function (event, data, obj) {
  221. switch (event) {
  222. case 'delstor':
  223. var url = layList.U({c: 'store.store_product', a: 'delete', q: {id: data.id}});
  224. if (data.is_del) var code = {title: "操作提示", text: "确定恢复商品操作吗?", type: 'info', confirm: '是的,恢复该商品'};
  225. else var code = {title: "操作提示", text: "确定将该商品移入回收站吗?", type: 'info', confirm: '是的,移入回收站'};
  226. $eb.$swal('delete', function () {
  227. $eb.axios.get(url).then(function (res) {
  228. if (res.status == 200 && res.data.code == 200) {
  229. $eb.$swal('success', res.data.msg);
  230. obj.del();
  231. location.reload();
  232. } else
  233. return Promise.reject(res.data.msg || '删除失败')
  234. }).catch(function (err) {
  235. $eb.$swal('error', err);
  236. });
  237. }, code)
  238. break;
  239. case 'open_image':
  240. $eb.openImage(data.image);
  241. break;
  242. case 'edit':
  243. $eb.createModalFrame(data.store_name, layList.U({
  244. a: 'bill_view',
  245. q: {product_id: data.product_id, store_id: data.store_id}
  246. }), {h: 600, w: 1000})
  247. break;
  248. case 'attr':
  249. $eb.createModalFrame(data.store_name + '-属性', layList.U({a: 'attr', q: {id: data.id}}), {
  250. h: 600,
  251. w: 800
  252. })
  253. break;
  254. }
  255. })
  256. //排序
  257. layList.sort(function (obj) {
  258. var type = obj.type;
  259. switch (obj.field) {
  260. case 'id':
  261. layList.reload({order: layList.order(type, 'id')}, true, null, obj);
  262. break;
  263. case 'sales':
  264. layList.reload({order: layList.order(type, 'sales')}, true, null, obj);
  265. break;
  266. }
  267. });
  268. //查询
  269. layList.search('search', function (where) {
  270. layList.reload(where, true);
  271. });
  272. //自定义方法
  273. var action = {
  274. set_product: function (field, id, value) {
  275. layList.baseGet(layList.Url({
  276. c: 'store.store_product',
  277. a: 'set_product',
  278. q: {field: field, id: id, value: value}
  279. }), function (res) {
  280. layList.msg(res.msg);
  281. });
  282. },
  283. show: function () {
  284. var ids = layList.getCheckData().getIds('id');
  285. if (ids.length) {
  286. layList.basePost(layList.Url({
  287. c: 'store.store_product',
  288. a: 'product_show'
  289. }), {ids: ids}, function (res) {
  290. layList.msg(res.msg);
  291. layList.reload();
  292. });
  293. } else {
  294. layList.msg('请选择要上架的商品');
  295. }
  296. }
  297. };
  298. //多选事件绑定
  299. $('.layui-btn-container').find('button').each(function () {
  300. var type = $(this).data('type');
  301. $(this).on('click', function () {
  302. action[type] && action[type]();
  303. })
  304. });
  305. </script>
  306. {/block}