|  |  |  | 
|---|
|  |  |  | <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 initCountVal = 1; | 
|---|
|  |  |  | var matCodeData = []; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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({ | 
|---|
|  |  |  | 
|---|
|  |  |  | toolbar: '#toolbar', | 
|---|
|  |  |  | cols: [[ | 
|---|
|  |  |  | {type: 'checkbox', fixed: 'left'}, | 
|---|
|  |  |  | {field: 'matNo', align: 'center', title: '物料编码', sort: 'true'}, | 
|---|
|  |  |  | {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} | 
|---|
|  |  |  | {field: 'modiUser$', align: 'center',title: '修改人员', hide: true}, | 
|---|
|  |  |  | {field: 'modiTime$', align: 'center',title: '修改时间'} | 
|---|
|  |  |  | ]], | 
|---|
|  |  |  | request: { | 
|---|
|  |  |  | pageName: 'curr', | 
|---|
|  |  |  | 
|---|
|  |  |  | if (res.code === 403) { | 
|---|
|  |  |  | top.location.href = baseUrl + "/"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | $('td[data-field=count] div').html("1"); | 
|---|
|  |  |  | setMatCodeData(res.data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 页面修改 | 
|---|
|  |  |  | table.on('edit(matCode)', function (obj) { | 
|---|
|  |  |  | if (!isNaN(obj.value)) { | 
|---|
|  |  |  | updateMatCodeData(obj.data.matNo, Number(obj.value)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | layer.msg("请输入数字"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 监听排序事件 | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | matQueryTable.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': | 
|---|
|  |  |  | // 数据格式检查 | 
|---|
|  |  |  | for (var i=0;i<matCodeData.length;i++){ | 
|---|
|  |  |  | if (isNaN(matCodeData[i]["count"])) { | 
|---|
|  |  |  | layer.msg("数量错误"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.length === 0){ | 
|---|
|  |  |  | layer.msg("请选择数据"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | parent.layer.close(parent.matCodeLayerIdx); | 
|---|
|  |  |  | parent.addTableData(data); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 
|---|
|  |  |  | clearFormVal($('#search-box')); | 
|---|
|  |  |  | tableReload(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | layDate.render({ | 
|---|
|  |  |  | elem: '.layui-laydate-range' | 
|---|
|  |  |  | ,type: 'datetime' | 
|---|
|  |  |  | ,range: true | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function setMatCodeData(data) { | 
|---|
|  |  |  | matCodeData = data; | 
|---|
|  |  |  | for (var i=0;i<matCodeData.length;i++){ | 
|---|
|  |  |  | matCodeData[i]["count"] = initCountVal; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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+"/"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | $('td[data-field=count] div').html("1"); | 
|---|
|  |  |  | setMatCodeData(res.data); | 
|---|
|  |  |  | pageCurr=curr; | 
|---|
|  |  |  | if (res.data.length === 0 && count !== 0) { | 
|---|
|  |  |  | tableIns.reload({ | 
|---|