index.php 14 KB

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