var matData = []; var cstmrVal; var itemVal; function getCol() { var cols = [ {field: 'count', align: 'center',title: '出库数量', edit:'text', width: 130, style:'color: blue;font-weight: bold'} ]; arrRemove(matCols, 'field', 'anfme'); cols.push.apply(cols, matCols); cols.push( {field: 'stock', align: 'center',title: '库存余量', style: 'font-weight: bold'}, {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:65} ) return cols; } layui.config({ base: baseUrl + "/static/layui/lay/modules/" }).extend({ notice: 'notice/notice', }).use(['table','laydate', 'form', 'admin', 'notice', 'xmSelect'], function() { var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var form = layui.form; var notice = layui.notice; var layDate = layui.laydate; var admin = layui.admin; var xmSelect = layui.xmSelect; tableIns = table.render({ elem: '#chooseData', headers: {token: localStorage.getItem('token')}, data: [], limit: 100, even: true, toolbar: '#toolbar', cellMinWidth: 50, cols: [getCol()], done: function(res, curr, count) { limit(); } }); // 页面修改 table.on('edit(chooseData)', function (obj) { updateMatData(obj.data.locNo, obj.data.matnr, Number(obj.value)); }); // 监听头工具栏事件 table.on('toolbar(chooseData)', function (obj) { var data = matData; switch (obj.event) { case 'createDoc': if (data.length === 0){ notice.error({ title: '消息通知', message: '请添加物料' }); } else { var success = true; for (var i=0;i= 0; i--) { if (matData[i].matnr === data.matnr) { matData.splice(i, 1); } } tableIns.reload({data: matData,done:function (res) { limit(); }}); break; } }); // 开始生成拣货单 form.on('submit(confirm)', function (data) { var matDetls = []; matData.forEach(function(elem) { matDetls.push({ matnr: elem.matnr , count: elem.count }); }); var req = JSON.stringify({ docType: data.field.docType , orderNo: data.field.orderNo , orderTime: data.field.orderTime , item: itemVal.getValue()[0] ? itemVal.getValue()[0].name : null , cstmr: cstmrVal.getValue()[0] ? cstmrVal.getValue()[0].name : null , list: matDetls }) $.ajax({ url: baseUrl+"/work/order/init", headers: {'token': localStorage.getItem('token')}, data: req, contentType:'application/json;charset=UTF-8', method: 'POST', success: function (res) { if (res.code === 200){ notice.success({ title: '消息通知', message: res.msg }); top.layui.layer.close(top.popupRight); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { notice.error({ title: '消息通知', message: res.msg }); } } }); }) function updateMatData(locNo, matnr, count) { if (isNaN(count)) { notice.error({ title: '消息通知', message: '请输入数字' }); } else { if (count > 0) { for (var i=0;i