index.php 14 KB

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