| | |
| | | |
| | | var initCountVal = 0; |
| | | var matCodeData = []; |
| | | |
| | | layui.use(['table','laydate', 'form'], function() { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | cellMinWidth: 50, |
| | | toolbar: '#toolbar', |
| | | cols: [[ |
| | | {type: 'checkbox'}, |
| | | {field: 'matNo', align: 'center', title: '物料编码', sort: 'true'}, |
| | | {fixed: 'left', title:'操作', align: 'center', toolbar: '#operate', width:80}, |
| | | {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} |
| | | {fixed: 'right', field: 'count', title: '数量', align: 'center', edit:'text', width: 100} |
| | | ]], |
| | | done: function (res, curr, count) { |
| | | $('td[data-field=count] div').html(initCountVal); |
| | | setMatCodeData(res.data); |
| | | } |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(chooseData)', 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('edit(chooseData)', function (obj) { |
| | | if (!isNaN(obj.value)) { |
| | | updateMatCodeData(obj.data.matNo, Number(obj.value)); |
| | | tableIns.reload({data: matCodeData,done:function (res) { |
| | | // 覆盖render方法的done |
| | | }}); |
| | | } else { |
| | | layer.msg("请输入数字"); |
| | | } |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | |
| | | break; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(chooseData)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 详情 |
| | | case 'remove': |
| | | for (var i = matCodeData.length - 1; i >= 0; i--) { |
| | | if (matCodeData[i].matNo === data.matNo) { |
| | | matCodeData.splice(i, 1); |
| | | } |
| | | } |
| | | tableIns.reload({data: matCodeData,done:function (res) { |
| | | // 覆盖render方法的done |
| | | }}); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 提取物料 |
| | | var matCodeLayerIdx; |
| | | function getMat() { |
| | | tableIns.reload({data: []}); |
| | | // tableIns.reload({data: []}); |
| | | matCodeLayerIdx = layer.open({ |
| | | type: 2, |
| | | title: '提取物料', |
| | |
| | | success: function(layero, index){ |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 启动入库 |
| | | function putMat() { |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | </body> |
| | | <script> |
| | | var initCountVal = 1; |
| | | var matCodeData = []; |
| | | |
| | | var pageCurr; |
| | | layui.use(['table','laydate', 'form'], function() { |
| | | var table = layui.table; |
| | |
| | | {field: 'matName', align: 'center', title: '物料名称'}, |
| | | {field: 'str1', align: 'center', title: '物料单位'}, |
| | | {field: 'str2', align: 'center', title: '物料规格'}, |
| | | {field: 'count', title: '数量', align: 'center', edit:'text', width: 100} |
| | | ]], |
| | | 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("请输入数字"); |
| | | } |
| | | }); |
| | | |
| | |
| | | var data = checkStatus.data; |
| | | switch(obj.event) { |
| | | case 'confirm': |
| | | // 数据格式检查 |
| | | for (var i=0;i<data.length;i++){ |
| | | if (isNaN(data[i]["count"])) { |
| | | layer.msg("数量错误"); |
| | | return; |
| | | } |
| | | } |
| | | parent.tableIns.reload({data: data}); |
| | | parent.matCodeData.push.apply(parent.matCodeData, data); |
| | | parent.tableIns.reload({data: parent.matCodeData}); |
| | | parent.layer.close(parent.matCodeLayerIdx); |
| | | break; |
| | | } |
| | |
| | | }); |
| | | }) |
| | | |
| | | 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 = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | |
| | | 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({ |
| | |
| | | .function-area { |
| | | padding: 20px 50px; |
| | | } |
| | | .mat-query { |
| | | .function-btn { |
| | | font-size: 16px; |
| | | padding: 1px 1px 1px 1px; |
| | | width: 100px; |
| | |
| | | transition: 0.4s; |
| | | cursor: pointer; |
| | | letter-spacing: 3px; |
| | | margin: 0 10px; |
| | | } |
| | | .mat-query:hover { |
| | | .function-btn:hover { |
| | | background-color: #2b425b; |
| | | color: #fff; |
| | | } |
| | |
| | | <body> |
| | | <!-- 功能区 --> |
| | | <div class="function-area"> |
| | | <button class="mat-query" onclick="getMat()">新增</button> |
| | | <button id="mat-query" class="function-btn" onclick="getMat()">新增</button> |
| | | |
| | | <!-- 站点选择框 group by -- 空库位 --> |
| | | |
| | | <button id="mat-put" class="function-btn" onclick="putMat()">启动入库</button> |
| | | </div> |
| | | |
| | | <hr> |
| | |
| | | <!-- 表格 --> |
| | | <div style="padding-bottom: 5px"> |
| | | |
| | | <!-- 头部 --> |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-normal" id="btn-comb" lay-event="comb" style="">组盘</button> |
| | | </div> |
| | | </script> |
| | | |
| | | <!-- 行 --> |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="remove">移除</a> |
| | | </script> |
| | | |
| | | <table class="layui-table" id="chooseData" lay-filter="chooseData"></table> |
| | | </div> |
| | | |