From d82432296d265c68c1ce4b4e7490482041c1c25e Mon Sep 17 00:00:00 2001 From: lijuncheng Date: Tue, 26 Nov 2024 14:33:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E8=B4=A7=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/deliver/coms/comScanDeliverPack.vue | 116 +++++++++++------- 1 file changed, 73 insertions(+), 43 deletions(-) diff --git a/src/pages/deliver/coms/comScanDeliverPack.vue b/src/pages/deliver/coms/comScanDeliverPack.vue index 0434fbb3..2684f598 100644 --- a/src/pages/deliver/coms/comScanDeliverPack.vue +++ b/src/pages/deliver/coms/comScanDeliverPack.vue @@ -493,21 +493,21 @@ that.fromLocationCode = balance.locationCode; let fromLocation = item.Locations.find(l => l.fromLocationCode == that.fromLocationCode); //扫描的库位在列表中存在 - if (fromLocation){ + if (fromLocation) { //不是在任务列表中的,是新加的库位 // if(fromLocation.isNewAdd){ - + // }else { // //在任务列表中。 - + // } - + let batch = fromLocation.Batchs.find(r => r.batch == lot); if (batch != undefined) { if (batch.Records == undefined) { batch.Records = []; } - + let record = batch.Records.find(r => r.packingNumber == packingCode); if (record == undefined) { //如果有推荐箱码 @@ -531,7 +531,7 @@ } else { that.addRecord(batch, label, balance, packageInfo) } - + } else { that.showErrorMessage('箱码【' + packingCode + '】已经扫描,请继续扫描下一箱', res => { @@ -539,20 +539,23 @@ } ) } - + } else { if (this.jobContent.allowModifyBatch == "TRUE") { this.showQuestionMessage('在【' + that.fromLocationCode + '】库位下,未查找到批次【' + lot + '】的发货明细,是否要继续发货?', res => { if (res) { - let batch = that.createBatchInfo(label, balance, packageInfo); + let batch = that.createBatchInfo(label, balance, packageInfo,fromLocation.qty); //新增加的批次赋值details - if (fromLocation.Batchs.length > 0) { - batch.detail = fromLocation.Batchs[0].detail; + if(batch){ + if (fromLocation.Batchs.length > 0) { + batch.detail = fromLocation.Batchs[0].detail; + } + fromLocation.Batchs.unshift(batch); + this.getfocus(); + that.$emit("afterScan"); } - fromLocation.Batchs.unshift(batch); - this.getfocus(); - that.$emit("afterScan"); + } }) } else { @@ -562,26 +565,29 @@ }); } } - - }else { + + } else { //扫描的不在任务列表中,询问是否可以添加, if (this.jobContent.allowModifyLocation == "TRUE") { this.showQuestionMessage("扫描物料[" + itemCode + "]的库位【" + that.fromLocationCode + "】与推荐的库位不一致,是否要继续发货?", res => { if (res) { - let locaion = that.createLocationInfo(label, balance, packageInfo); - item.Locations.push(locaion); - this.getfocus(); - that.$emit("afterScan"); + let locaion = that.createLocationInfo(label, balance, packageInfo, item.qty); + if(locaion){ + item.Locations.push(locaion); + this.getfocus(); + that.$emit("afterScan"); + } + } }) - + } else { this.showErrorMessage("扫描物料[" + itemCode + "]的库位【" + that.fromLocationCode + "】与推荐的库位不一致,不允许继续发货?") } } - + // if (fromLocation && !fromLocation.isNewAdd) { // let batch = fromLocation.Batchs.find(r => r.batch == lot); // if (batch != undefined) { @@ -734,7 +740,7 @@ }, //增加不是任务中的库位,实际扫描的明细 - createLocationInfo(label, balance, packageInfo) { + createLocationInfo(label, balance, packageInfo, itemCodeQty) { let location = { fromLocationCode: balance.locationCode, qty: balance.qty, @@ -743,15 +749,20 @@ isNewAdd: true, Batchs: [] } - let batch = this.createBatchInfo(label, balance, packageInfo); - batch.detail = balance; - batch.detail.fromLocationCode = balance.locationCode; - location.Batchs.push(batch); - return location; + let batch = this.createBatchInfo(label, balance, packageInfo, itemCodeQty); + if(batch){ + batch.detail = balance; + batch.detail.fromLocationCode = balance.locationCode; + location.Batchs.push(batch); + return location; + }else { + return null; + } + }, - createBatchInfo(data, balance, packageInfo) { + createBatchInfo(data, balance, packageInfo, itemCodeQty) { let batch = { isNewAdd: true, batch: data.batch, @@ -761,10 +772,30 @@ Records: [] } let record = this.creatRecord(data, balance, packageInfo); + if (!this.checkQty(batch, record,itemCodeQty)) { + return; + } + batch.Records.push(record); this.issueRecord.unshift(record) return batch; }, + //扫描的不是推荐的库存 + checkQty(batch,record,itemCodeQty){ + var isPassed=true + if (this.jobContent.allowBiggerQty == "FALSE") { + var tempHandleQty = 0 + batch.Records.forEach(res => { + tempHandleQty = calc.add(tempHandleQty, res.qty) + }) + var vailQty = calc.sub(itemCodeQty, tempHandleQty) + if (record.qty > vailQty) { + this.showErrorMessage("扫描标签数量[" + record.qty + "]大于剩余推荐数量[" + vailQty + "]") + isPassed=false + } + } + return isPassed; + }, creatRecord(label, balance, packageInfo) { balance.packQty = packageInfo.packQty @@ -814,7 +845,7 @@ "]的父包装已经扫描") } else { let record = this.creatRecord(label, balance, packageInfo); - if(!this.checkHandleQty(batch,record)){ + if (!this.checkHandleQty(batch, record)) { return; } batch.Records.push(record); @@ -839,7 +870,7 @@ if (res) { batch.Records = []; let record = this.creatRecord(label, balance, packageInfo); - if(!this.checkHandleQty(batch,record)){ + if (!this.checkHandleQty(batch, record)) { return; } batch.Records.push(record); @@ -852,7 +883,7 @@ console.log("扫描的是父包装,是否移除子包装") } else { let record = this.creatRecord(label, balance, packageInfo); - if(!this.checkHandleQty(batch,record)){ + if (!this.checkHandleQty(batch, record)) { return; } batch.Records.push(record); @@ -865,24 +896,23 @@ } }, - - checkHandleQty(batch,record){ - var isPassed=true; - if(this.jobContent.allowBiggerQty=="FALSE"){ - var tempHandleQty=0 + + checkHandleQty(batch, record) { + var isPassed = true; + if (this.jobContent.allowBiggerQty == "FALSE") { + var tempHandleQty = 0 batch.Records.forEach(res => { tempHandleQty = calc.add(tempHandleQty, res.qty) }) - var vailQty =calc.sub(batch.qty,tempHandleQty) - if( record.qty>vailQty){ - this.showErrorMessage("扫描标签数量["+record.qty+"]大于剩余推荐数量["+vailQty+"]") - isPassed=false; + var vailQty = calc.sub(batch.qty, tempHandleQty) + if (record.qty > vailQty) { + this.showErrorMessage("扫描标签数量[" + record.qty + "]大于剩余推荐数量[" + vailQty + "]") + isPassed = false; } } - + return isPassed - } - , + }, getfocus() { if (this.$refs.comscan != undefined) { this.$refs.comscan.getfocus();