| | |
| | | |
| | | 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() { |
| | | |
| | | |
| | | } |