| | |
| | | ,area: ['1200px', '700px'] |
| | | ,shade: 0.5 |
| | | ,shadeClose: false |
| | | ,btn: ['立即出库', '稍后处理'] |
| | | ,btn: ['一键出库', '部分出库', '稍后处理'] |
| | | ,btnAlign: 'c' |
| | | ,moveType: 1 //拖拽模式,0或者1 |
| | | ,content: $('#pakoutPreviewBox').html() |
| | | ,success: function(layero, index){ |
| | | stoPreTabIdx = table.render({ |
| | | elem: '#stoPreTab', |
| | | id: 'stoPreTab', |
| | | data: res.data, |
| | | height: 520, |
| | | page: false, |
| | |
| | | {field: 'orderNo', title: '单据编号', merge: true, align: 'center'}, |
| | | {field: 'title', title: '商品', merge: true, align: 'center', width: 350}, |
| | | {field: 'batch', title: '序列码', align: 'center'}, |
| | | {field: 'anfme', title: '数量', align: 'center', width: 90, style: 'font-weight: bold'}, |
| | | {field: 'anfme', title: '需求数量', align: 'center', width: 90, style: 'font-weight: bold'}, |
| | | {field: 'anfme$', align: 'center', title: '出库数量', edit: 'text', style: 'font-weight: bold'}, |
| | | {field: 'locNo', title: '货位', align: 'center', width: 100, templet: '#locNoTpl'}, |
| | | {field: 'frozen$', title: '明细', align: 'center', width: 90, templet: '#locFrozen'}, |
| | | {field: 'frozenLoc$', title: '库位', align: 'center', width: 90, templet: '#locFrozenLoc'}, |
| | |
| | | done: function (res) { |
| | | tableMerge.render(this); |
| | | $('.layui-table-body.layui-table-main').css("overflow", "auto"); |
| | | tableCache = tableData = table.cache.stoPreTab; |
| | | // tableCache = tableData = table.cache.stoPreTab; |
| | | tableCache = table.cache['stoPreTab']; |
| | | tableCache.forEach(item => { |
| | | // console.log('anfme:', item.anfme, 'anfme$:', item.anfme$); |
| | | item.anfme$ = item.anfme$ ?? item.anfme; |
| | | }); |
| | | } |
| | | }); |
| | | // 修改出库站 |
| | |
| | | obj.othis.children().find("input").css("color", "blue"); |
| | | return false; |
| | | }); |
| | | table.on('edit(stoPreTab)', function(obj) { |
| | | let field = obj.field; |
| | | let value = obj.value; |
| | | let index = obj.tr.data('index'); |
| | | |
| | | // 只处理 anfme$ 字段的校验 |
| | | if (field === 'anfme$') { |
| | | let numValue = Number(value); |
| | | // 直接从tableCache获取最新数据 |
| | | let rowData = tableCache[index]; |
| | | let max = Number(rowData.anfme); // 获取最大可输入值(需求数量) |
| | | |
| | | if (isNaN(numValue)) { |
| | | layer.msg("请输入数字", {icon: 2}); |
| | | // 恢复为需求数量 |
| | | setCellValue(index, rowData.anfme); |
| | | return; |
| | | } |
| | | |
| | | if (numValue <= 0) { |
| | | layer.msg("出库数量必须大于0", {icon: 2}); |
| | | // 恢复为需求数量 |
| | | setCellValue(index, rowData.anfme); |
| | | return; |
| | | } |
| | | |
| | | if (numValue > max) { |
| | | layer.msg("不能大于 " + max, {icon: 2}); |
| | | // 恢复为需求数量 |
| | | setCellValue(index, rowData.anfme); |
| | | return; |
| | | } |
| | | |
| | | // 校验通过,直接更新 |
| | | // console.log('校验通过,设置值为:', numValue); |
| | | } |
| | | }); |
| | | |
| | | // 设置单元格值的函数(同时更新缓存和显示) |
| | | function setCellValue(index, newValue) { |
| | | // console.log('设置第' + index + '行的anfme$为:', newValue); |
| | | |
| | | // 1. 更新tableCache(这是最根本的数据源) |
| | | tableCache[index].anfme$ = newValue; |
| | | |
| | | // 2. 更新DOM显示 |
| | | let cell = $('div[lay-id=stoPreTab] tr[data-index="' + index + '"] td[data-field="anfme$"] input.layui-table-edit'); |
| | | if (cell.length > 0) { |
| | | cell.val(newValue); |
| | | } else { |
| | | // 如果不在编辑状态,更新显示文本 |
| | | cell = $('div[lay-id=stoPreTab] tr[data-index="' + index + '"] td[data-field="anfme$"] div.layui-table-cell'); |
| | | cell.text(newValue); |
| | | } |
| | | } |
| | | // 批量修改出库站 |
| | | form.on('submit(batchModifySta)', function () { |
| | | let stoPreTabData = layui.table.checkStatus('stoPreTab').data; |
| | |
| | | ,yes: function(index, layero){ |
| | | //按钮【立即出库】的回调 |
| | | pakout(tableCache, index); |
| | | } |
| | | ,btn2: function(index, layero){ |
| | | }, |
| | | btn2: function(index, layero){ |
| | | // 按钮【部分出库】的回调 - 不关闭界面 |
| | | return partialPakout(tableCache, index); // 调用部分出库函数 |
| | | }, |
| | | btn3: function(index, layero){ |
| | | //按钮【稍后处理】的回调 |
| | | layer.close(index) |
| | | //return false 开启该代码可禁止点击该按钮关闭 |
| | | layer.close(index); |
| | | } |
| | | }); |
| | | } else if (res.code === 403){ |
| | |
| | | } |
| | | |
| | | function pakout(tableCache, layerIndex) { |
| | | // let loadIndex = layer.load(2); |
| | | // 添加确认框 |
| | | layer.confirm('确定要一键出库全部物料吗?', { |
| | | icon: 3, |
| | | title: '确认一键出库', |
| | | btn: ['确定', '取消'] |
| | | }, function(confirmIndex) { |
| | | // 用户点击确定后执行出库操作 |
| | | layer.close(confirmIndex); |
| | | notice.msg('正在生成出库任务......', {icon: 4}); |
| | | $.ajax({ |
| | | url: baseUrl + "/out/pakout/auth", |
| | |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function partialPakout(tableCache, layerIndex) { |
| | | |
| | | let stoPreTabData = layui.table.checkStatus('stoPreTab').data; |
| | | if (stoPreTabData.length < 1) { |
| | | layer.msg("请选择部分出库数据", {icon: 7}); |
| | | return false; |
| | | } |
| | | |
| | | // 打印勾选的数据 |
| | | // console.log("勾选的数据:", JSON.stringify(stoPreTabData)); |
| | | |
| | | // 将勾选数据的 anfme$ 值赋给 anfme |
| | | stoPreTabData.forEach(item => { |
| | | // console.log('修改前 - anfme:', item.anfme, 'anfme$:', item.anfme$); |
| | | item.anfme = Number(item.anfme$); // 直接将勾选数据的 anfme$ 赋给 anfme |
| | | // console.log('修改后 - anfme:', item.anfme); |
| | | }); |
| | | |
| | | // console.log("提交的数据:", JSON.stringify(stoPreTabData)); |
| | | |
| | | // 使用与一键出库相同的接口提交 |
| | | notice.msg('正在生成出库任务......', {icon: 4}); |
| | | $.ajax({ |
| | | url: baseUrl + "/out/pakout/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | contentType: 'application/json;charset=UTF-8', |
| | | data: JSON.stringify(stoPreTabData), |
| | | method: 'POST', |
| | | success: function (res) { |
| | | notice.destroy(); |
| | | if (res.code === 200) { |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.reload({where: null}); |
| | | insTb2.reload({where: null, page: {curr: 1}}); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |