index.php 12 KB

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