|  |  | 
 |  |  |     <legend>搜索栏</legend> | 
 |  |  |     <div id="search-box" class="layui-form layui-card-header"> | 
 |  |  |         <div class="layui-inline"> | 
 |  |  |             <label class="layui-form-label">物料编码:</label> | 
 |  |  |             <div class="layui-input-inline"> | 
 |  |  |                 <input class="layui-input" type="text" name="mat_no" placeholder="请输入" autocomplete="off"> | 
 |  |  |                 <input class="layui-input" type="text" name="mat_no" placeholder="商品编号" autocomplete="off"> | 
 |  |  |             </div> | 
 |  |  |         </div> | 
 |  |  |  | 
 |  |  |         <!-- 日期范围 --> | 
 |  |  |         <div class="layui-inline" style="width: 300px"> | 
 |  |  |             <div class="layui-input-inline"> | 
 |  |  |                 <input class="layui-input layui-laydate-range" name="modi_time" type="text" placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px"> | 
 |  |  |             </div> | 
 |  |  |         </div> | 
 |  |  |         <div class="layui-inline"> | 
 |  |  |             <div class="layui-input-inline"> | 
 |  |  |                 <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off"> | 
 |  |  |             </div> | 
 |  |  |         </div> | 
 |  |  |         <!-- 待添加 --> | 
 |  |  |         <div id="data-search-btn" class="layui-btn-container layui-form-item" style="display: inline-block"> | 
 |  |  |             <button id="search" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">搜索</button> | 
 |  |  | 
 |  |  |     </div> | 
 |  |  | </script> | 
 |  |  |  | 
 |  |  |  | 
 |  |  | <div class="layui-form"> | 
 |  |  |     <table class="layui-hide" id="matCode" lay-filter="matCode"></table> | 
 |  |  | </div> | 
 |  |  | 
 |  |  | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> | 
 |  |  | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> | 
 |  |  | <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script> | 
 |  |  | <script type="text/javascript" src="../../static/js/pakStore/pakStore.js" charset="utf-8"></script> | 
 |  |  |  | 
 |  |  | </body> | 
 |  |  | <script> | 
 |  |  |     var matCodeData = []; | 
 |  |  |     function getCol() { | 
 |  |  |         var cols = [ | 
 |  |  |             {type: 'checkbox', fixed: 'left'} | 
 |  |  |         ]; | 
 |  |  |         cols.push.apply(cols, matCols); | 
 |  |  |         cols.push( | 
 |  |  |             {field: 'modiUser$', align: 'center',title: '修改人员', hide: true}, | 
 |  |  |             {field: 'modiTime$', align: 'center',title: '修改时间'} | 
 |  |  |         ) | 
 |  |  |         return cols; | 
 |  |  |     } | 
 |  |  |     var pageCurr; | 
 |  |  |     layui.use(['table','laydate', 'form'], function() { | 
 |  |  |         var table = layui.table; | 
 |  |  |         var $ = layui.jquery; | 
 |  |  |         var layer = layui.layer; | 
 |  |  |         var layDate = layui.laydate; | 
 |  |  |         var form = layui.form; | 
 |  |  |         // 物料查询数据表 | 
 |  |  |         matQueryTable = table.render({ | 
 |  |  | 
 |  |  |             headers: {token: localStorage.getItem('token')}, | 
 |  |  |             url: baseUrl + '/matCode/list/auth', | 
 |  |  |             page: true, | 
 |  |  |             limit: 10, | 
 |  |  |             limits: [10, 30,50,100], | 
 |  |  |             limit: 7, | 
 |  |  |             limits: [7, 10, 30,50,100], | 
 |  |  |             even: true, | 
 |  |  |             cellMinWidth: 50, | 
 |  |  |             toolbar: '#toolbar', | 
 |  |  |             cols: [[ | 
 |  |  |                 {type: 'checkbox', fixed: 'left'}, | 
 |  |  |                 {field: 'matNo', align: 'center', title: '物料编码'}, | 
 |  |  |                 {field: 'barcode', align: 'center', title: '条码'}, | 
 |  |  |                 {field: 'matName', align: 'center', title: '物料名称'}, | 
 |  |  |                 {field: 'str1', align: 'center', title: '物料单位'}, | 
 |  |  |                 {field: 'str2', align: 'center', title: '物料规格'}, | 
 |  |  |                 {field: 'count', title: '数量', align: 'center', edit:'text', width: 100} | 
 |  |  |             ]], | 
 |  |  |             cols: [getCol()], | 
 |  |  |             request: { | 
 |  |  |                 pageName: 'curr', | 
 |  |  |                 pageSize: 'limit' | 
 |  |  | 
 |  |  |                 if (res.code === 403) { | 
 |  |  |                     top.location.href = baseUrl + "/"; | 
 |  |  |                 } | 
 |  |  |                 setMatCodeData(res.data); | 
 |  |  |                 $('td[data-field=count] div').html("1"); | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         // 页面修改 | 
 |  |  |         table.on('edit(matCode)', function (obj) { | 
 |  |  |             updateMatCodeData(obj.data.matNo, Number(obj.value)); | 
 |  |  |         }); | 
 |  |  |  | 
 |  |  |         // 监听排序事件 | 
 |  |  |         table.on('sort(matCode)', function (obj) { | 
 |  |  |             var searchData = {}; | 
 |  |  |             $.each($('#search-box [name]').serializeArray(), function() { | 
 |  |  |                 searchData[this.name] = this.value; | 
 |  |  |             }); | 
 |  |  |             searchData['orderByField'] = obj.field; | 
 |  |  |             searchData['orderByType'] = obj.type; | 
 |  |  |             tableIns.reload({ | 
 |  |  |                 where: searchData, | 
 |  |  |                 page: { | 
 |  |  |                     curr: 1 | 
 |  |  |                 }, | 
 |  |  |                 done: function (res, curr, count) { | 
 |  |  |                     if (res.code === 403) { | 
 |  |  |                         top.location.href = baseUrl+"/"; | 
 |  |  |                     } | 
 |  |  |                     pageCurr=curr; | 
 |  |  |                     limit(); | 
 |  |  |                 } | 
 |  |  |             }); | 
 |  |  |         }); | 
 |  |  |  | 
 |  |  |         // 监听头工具栏事件 | 
 |  |  |         table.on('toolbar(matCode)', function (obj) { | 
 |  |  |             var checkStatus = table.checkStatus(obj.config.id); | 
 |  |  |             var data = checkStatus.data; | 
 |  |  |             switch(obj.event) { | 
 |  |  |                 case 'confirm': | 
 |  |  |                     console.log(checkStatus); | 
 |  |  |                     if (data.length === 0){ | 
 |  |  |                         layer.msg("请选择数据"); | 
 |  |  |                         return; | 
 |  |  |                     } | 
 |  |  |                     parent.addTableData(data); | 
 |  |  |                     break; | 
 |  |  |             } | 
 |  |  |         }); | 
 |  |  | 
 |  |  |             clearFormVal($('#search-box')); | 
 |  |  |             tableReload(); | 
 |  |  |         }); | 
 |  |  |  | 
 |  |  |         layDate.render({ | 
 |  |  |             elem: '.layui-laydate-range' | 
 |  |  |             ,type: 'datetime' | 
 |  |  |             ,range: true | 
 |  |  |         }); | 
 |  |  |     }) | 
 |  |  |  | 
 |  |  |     function setMatCodeData(data, matNo, count) { | 
 |  |  |         matCodeData = data; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     function updateMatCodeData(matNo, count) { | 
 |  |  |         for (var i=0;i<matCodeData.length;i++){ | 
 |  |  |             if (matCodeData[i][matNo] === matNo){ | 
 |  |  |                 matCodeData[i][count] = count; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         console.log(matCodeData); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     function tableReload(child) { | 
 |  |  |         var searchData = {}; | 
 |  |  | 
 |  |  |                 if (res.code === 403) { | 
 |  |  |                     top.location.href = baseUrl+"/"; | 
 |  |  |                 } | 
 |  |  |                 setMatCodeData(res.data); | 
 |  |  |                 $('td[data-field=count] div').html("1"); | 
 |  |  |                 pageCurr=curr; | 
 |  |  |                 if (res.data.length === 0 && count !== 0) { | 
 |  |  |                     tableIns.reload({ |