diff --git a/src/pages/putaway/job/putawayDetail.vue b/src/pages/putaway/job/putawayDetail.vue index 192f50cd..c07d41f9 100644 --- a/src/pages/putaway/job/putawayDetail.vue +++ b/src/pages/putaway/job/putawayDetail.vue @@ -16,14 +16,15 @@ - - + @@ -31,7 +32,8 @@ - + --> - + @@ -120,7 +122,7 @@ toLocationAreaTypeList: [], jobStatus: "", jobToLocationCode: "", - isCheckLocation: false, + isCheckLocation: true, scanMessage: "", managementType: '' //储存扫描后的管理精度 }; @@ -212,12 +214,6 @@ that.fromLocationCode = that.subList[0].fromLocationCode that.jobToLocationCode = that.subList[0].toLocationCode; that.toLocationAreaTypeList = getDirectoryItemArray(that.jobContent.toAreaTypes) - that.isCheckLocation = getSwitchInfoByCode("PurchasePutawayToLocationCodeValidate") - if (that.isCheckLocation) { - that.toLocationCode = "" - } else { - that.toLocationCode = that.jobToLocationCode; - } //获取管理模式,封装参数 var itemCodes = [] this.detailSource.forEach(item => { @@ -227,15 +223,25 @@ getManagementPrecisions(itemCodes, that.jobToLocationCode, res => { if (res.success) { this.managementList = res.list; - this.managementType = this.managementList.some(item => item.ManagementPrecision == - 'BY_BATCH') ? 'BY_BATCH' : '' + this.managementType = this.managementList.some(item => item + .ManagementPrecision == + 'BY_PACKAGING') ? 'BY_PACKAGING' : 'BY_BATCH' } }) + if (this.managementType == "BY_PACKAGING") { + that.isCheckLocation = getSwitchInfoByCode("PurchasePutawayToLocationCodeValidate") + if (that.isCheckLocation) { + that.toLocationCode = "" + } else { + that.toLocationCode = that.jobToLocationCode; + } + }else { + this.isCheckLocation=true; + } //外部进入详情,如果有扫描信息,模拟自动扫描 if (this.scanMessage) { this.openScanPopupSimulate(this.scanMessage) } - } else { that.showMessage('列表数据为0'); } @@ -277,10 +283,10 @@ updateData() { console.log("updateData") // this.calcHandleQty(); - if (this.managementType == 'BY_BATCH' || managementPrecision == 'BY_QUANTITY') { - calcHandleQty(this.detailSource); + if (this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY') { + calcHandleQty(this.detailSource); } else { - calcTreeHandleQty(this.detailSource) + calcTreeHandleQty(this.detailSource) } }, //模拟扫描功能 @@ -333,44 +339,13 @@ }, getScanResult(result, managementPrecision) { - this.managementType = managementPrecision - let array1 = []//记录推荐的库位 - let array2 = []//记录推荐的批次 - this.detailSource.forEach(item=>{ - item.subList.forEach(cur=>{ - array1.push(cur.fromLocationCode) - array2.push(cur.batch) - }) - }) - // 扫描的库位是否在 - const obj1 = array1.find(item=>item == result.fromLocationCode) - const obj2 = array2.find(item=>item == result.label.batch) - // this.jobContent.allowModifyLocation = 'FALSE' - // this.jobContent.allowModifyBatch = 'FALSE' - if(this.jobContent.allowModifyLocation == 'FALSE'){ - if(!obj1){ - this.showErrorMessage(`不可以扫描推荐库位【${array1.join(',')}】以外的库位`) - return - } - } - if(this.jobContent.allowModifyBatch == 'FALSE'){ - if(!obj2){ - this.showErrorMessage(`不可以扫描推荐批次【${array2.join(',')}】以外的批次`) - return - } - } - if(!obj1){ - this.recommendQty = 0 - }else{ - this.recommendQty = result.balance.qty - } - // - if (this.managementType == 'BY_BATCH' || managementPrecision == 'BY_QUANTITY') { - this.setDataBatch(result, managementPrecision) - } else { - this.setData(result, managementPrecision) - } - + this.managementType = managementPrecision; + if (this.managementType == 'BY_BATCH' || managementPrecision == 'BY_QUANTITY') { + this.setDataBatch(result, managementPrecision) + } else { + this.setData(result, managementPrecision) + } + }, resizeCollapse() { this.$nextTick(r => { @@ -380,54 +355,36 @@ }); }, // 按批次的时候校验 代码和按包装的代码基本一致,只不过是校验提示不一致 - setDataBatch(result, managementPrecision){ + setDataBatch(result, managementPrecision) { try { - var packingNumber = result.label.packingNumber; - var batch = result.label.batch; - var qty = result.label.qty; - var itemCode = result.label.itemCode; - var locationCode = result.fromLocationCode; - - if (!result.balance) { - this.showMessage("箱码【" + packingNumber + "】没有库存余额") - return; - } - - // var inventoryStatus = "OK"; - var detail = this.detailSource.find(r => r.itemCode == itemCode); - - if (detail == undefined) { - this.showErrorMessage("物料号【" + itemCode + "】不在列表中") - } else { - detail.scaned = true - + var packingNumber = result.label.packingNumber; + var batch = result.label.batch; + var qty = result.label.qty; + var itemCode = result.label.itemCode; + var locationCode = result.fromLocationCode; + + if (!result.balance) { + this.showMessage("箱码【" + packingNumber + "】没有库存余额") + return; + } + + // var inventoryStatus = "OK"; + var detail = this.detailSource.find(r => r.itemCode == itemCode); + + if (detail == undefined) { + this.showErrorMessage("物料号【" + itemCode + "】不在列表中") + } else { + detail.scaned = true + var itemDetail = detail.subList.find(r => { return r.batch == batch && r.fromLocationCode == result.fromLocationCode }) - + if (itemDetail == undefined) { - // let newItemDetail = {} - detail.subList.push({ - scaned:true, - fromLocationCode:result.fromLocationCode, - toLocationCode:this.toLocationCode, - batch:result.label.batch, - handleQty:result.label.qty, - qty:this.recommendQty, - inventoryStatus:result.balance.inventoryStatus, - toLocation:result.balance.toLocation, - balance:result.balance, - balanceQty:result.balance.qty, - packQty:result.package.packQty, - packUnit:result.package.packUnit, - uom:result.balance.uom, - }) - setTimeout(r => { - this.resizeCollapse(); - this.$forceUpdate() - }, 100) - calcHandleQty(this.detailSource); + this.showErrorMessage("物料号【" + itemCode + "】" + "批次【" + batch + "】库位【" + locationCode + + "】不在列表中") + } else { var scanedLength = 0; itemDetail.packList.forEach(res => { @@ -435,15 +392,15 @@ scanedLength++; } }) - + //大哥让加的 itemDetail.fromInventoryStatus = result.balance.inventoryStatus; - + if (!itemDetail.cancleScanedHiht && itemDetail.scaned && scanedLength == itemDetail.packList .length) { // this.showMessage("箱码【" + packingNumber + "】已经扫描") - // this.showMessage("批次【" + batch + "】已经扫描") - itemDetail.handleQty = calc.add(Number(result.label.qty),itemDetail.handleQty) + // this.showMessage("批次【" + batch + "】已经扫描") + itemDetail.handleQty = calc.add(Number(result.label.qty), itemDetail.handleQty) } else { itemDetail.scaned = true; itemDetail.balanceQty = result.balance.qty; @@ -455,7 +412,7 @@ pac.handleQty = Number(pac.qty); pac.toLocationCode = this.toLocationCode; }) - + this.continueScan() this.$forceUpdate() } @@ -466,105 +423,105 @@ this.showMessage(e.message) } }, - - setData(result, managementPrecision){ + + setData(result, managementPrecision) { try { var packingNumber = result.label.packingNumber; var batch = result.label.batch; var qty = result.label.qty; var itemCode = result.label.itemCode; var locationCode = result.fromLocationCode; - + if (!result.balance) { this.showMessage("箱码【" + packingNumber + "】没有库存余额") return; } - + // var inventoryStatus = "OK"; var detail = this.detailSource.find(r => r.itemCode == itemCode); - + if (detail == undefined) { this.showErrorMessage("物料号【" + itemCode + "】不在列表中") } else { detail.scaned = true - - - var itemDetail = detail.subList.find(r => { - return r.packingNumber == packingNumber && - r.batch == batch && - r.fromLocationCode == result.fromLocationCode - }) - - if (itemDetail == undefined) { - var isExit; - for (let subItem of detail.subList) { - var item; - for (let pack of subItem.packList) { - if (pack.packingNumber == packingNumber && - pack.batch == batch) { - item = pack; - isExit = pack; - break; - } - } - if (item != undefined) { - subItem.scaned = true - subItem.handleQty = 0; - item = undefined + + + var itemDetail = detail.subList.find(r => { + return r.packingNumber == packingNumber && + r.batch == batch && + r.fromLocationCode == result.fromLocationCode + }) + + if (itemDetail == undefined) { + var isExit; + for (let subItem of detail.subList) { + var item; + for (let pack of subItem.packList) { + if (pack.packingNumber == packingNumber && + pack.batch == batch) { + item = pack; + isExit = pack; + break; } } - if (isExit == undefined) { - this.showErrorMessage("箱码【" + packingNumber + "】,批次【" + batch + "】库位【" + result - .fromLocationCode + "】不在列表中") + if (item != undefined) { + subItem.scaned = true + subItem.handleQty = 0; + item = undefined + } + } + if (isExit == undefined) { + this.showErrorMessage("箱码【" + packingNumber + "】,批次【" + batch + "】库位【" + result + .fromLocationCode + "】不在列表中") + } else { + if (!isExit.cancleScanedHiht && isExit.scaned) { + this.showMessage("箱码【" + packingNumber + "】已经扫描") } else { - if (!isExit.cancleScanedHiht && isExit.scaned) { - this.showMessage("箱码【" + packingNumber + "】已经扫描") + isExit.scaned = true + let qty = 0; + if (result.balance != null) { + qty = Number(result.balance.qty); } else { - isExit.scaned = true - let qty = 0; - if (result.balance != null) { - qty = Number(result.balance.qty); - } else { - qty = Number(result.label.qty); - } - - isExit.handleQty = Number(result.label.qty); - isExit.toLocationCode = this.toLocationCode; + qty = Number(result.label.qty); } + + isExit.handleQty = Number(result.label.qty); + isExit.toLocationCode = this.toLocationCode; + } + } + calcTreeHandleQty(this.detailSource); + this.continueScan() + this.$forceUpdate() + } else { + var scanedLength = 0; + itemDetail.packList.forEach(res => { + if (res.scaned) { + scanedLength++; } + }) + + //大哥让加的 + itemDetail.fromInventoryStatus = result.balance.inventoryStatus; + + if (!itemDetail.cancleScanedHiht && itemDetail.scaned && scanedLength == itemDetail.packList + .length) { + this.showMessage("箱码【" + packingNumber + "】已经扫描") + } else { + itemDetail.scaned = true; + this.detailSource[0].subList.sort(compareAsc('scaned')); //按扫描信息排序 + itemDetail.handleQty = result.label.qty; + // itemDetail.toInventoryStatus = "OK" + itemDetail.packList.forEach(pac => { + pac.scaned = true + pac.handleQty = Number(pac.qty); + pac.toLocationCode = this.toLocationCode; + }) + calcTreeHandleQty(this.detailSource); this.continueScan() this.$forceUpdate() - } else { - var scanedLength = 0; - itemDetail.packList.forEach(res => { - if (res.scaned) { - scanedLength++; - } - }) - - //大哥让加的 - itemDetail.fromInventoryStatus = result.balance.inventoryStatus; - - if (!itemDetail.cancleScanedHiht && itemDetail.scaned && scanedLength == itemDetail.packList - .length) { - this.showMessage("箱码【" + packingNumber + "】已经扫描") - } else { - itemDetail.scaned = true; - this.detailSource[0].subList.sort(compareAsc('scaned')); //按扫描信息排序 - itemDetail.handleQty = result.label.qty; - // itemDetail.toInventoryStatus = "OK" - itemDetail.packList.forEach(pac => { - pac.scaned = true - pac.handleQty = Number(pac.qty); - pac.toLocationCode = this.toLocationCode; - }) - - calcTreeHandleQty(this.detailSource); - this.continueScan() - this.$forceUpdate() - } } + } } if (this.managementType == 'BY_BATCH') { this.detailSource.forEach(item => { @@ -577,13 +534,30 @@ this.showMessage(e.message) } }, + scanLocationCode(location, code) { - this.toLocationCode = code - this.detailSource.forEach(item => { - item.subList.forEach(detail => { - detail.toLocationCode = code + //允许修改库位 + if(this.jobContent.allowModifyLocation=="TRUE"){ + this.toLocationCode = code + this.detailSource.forEach(item => { + item.subList.forEach(detail => { + detail.toLocationCode = code + }) }) - }) + }else { + //不允许修改库位,判断扫描的是否和推荐的一致 + if(code==this.jobToLocationCode){ + this.toLocationCode = code + this.detailSource.forEach(item => { + item.subList.forEach(detail => { + detail.toLocationCode = code + }) + }) + }else { + this.showErrorMessage("扫描的库位【"+code+"】与推荐的库位【"+this.jobToLocationCode+"】不一致") + } + + } }, openDetail(item) { @@ -610,7 +584,7 @@ }); }, // 校验 - check(){ + check() { //扫描数量和任务数量相等,直接提交 if (this.scanCount == this.subList.length) { this.submitJob(); @@ -632,80 +606,86 @@ }); } } - + }, //按批次的校验 - checkBatch(){ - //扫描数量和任务数量相等,直接提交 - let str = '' - let str1 = '' - let str2 = '' - var scanCount=0; - // this.jobContent.allowBiggerQty = "FALSE" - // this.jobContent.allowSmallerQty = "FALSE" - // this.jobContent.allowPartialComplete = "TRUE" - this.detailSource.forEach((item) => { - item.subList.forEach(cur=>{ - if(cur.scaned){ - scanCount++; - if(parseFloat(cur.qty)>parseFloat(cur.handleQty)){ - str += `物料号【${item.itemCode}】批次【${cur.batch}】实际提交数量【${cur.handleQty}】不可以小于任务数量【${cur.qty}】\n` - } - if(parseFloat(cur.qty)parseFloat(cur.balanceQty)){ - str2 += `物料号【${item.itemCode}】批次【${cur.batch}】实际提交数量【${cur.handleQty}】不可以大于库存数量【${cur.balanceQty}】\n` - } + checkBatch() { + //扫描数量和任务数量相等,直接提交 + let str = '' + let str1 = '' + let str2 = '' + var scanCount = 0; + // this.jobContent.allowBiggerQty = "FALSE" + // this.jobContent.allowSmallerQty = "FALSE" + // this.jobContent.allowPartialComplete = "TRUE" + this.detailSource.forEach((item) => { + item.subList.forEach(cur => { + if (cur.scaned) { + scanCount++; + if (parseFloat(cur.qty) > parseFloat(cur.handleQty)) { + str += + `物料号【${item.itemCode}】批次【${cur.batch}】实际提交数量【${cur.handleQty}】不可以小于任务数量【${cur.qty}】\n` } - }) + if (parseFloat(cur.qty) < parseFloat(cur.handleQty)) { + str1 += + `物料号【${item.itemCode}】批次【${cur.batch}】实际提交数量【${cur.handleQty}】不可以大于任务数量【${cur.qty}】\n` + } + if (parseFloat(cur.handleQty) > parseFloat(cur.balanceQty)) { + str2 += + `物料号【${item.itemCode}】批次【${cur.batch}】实际提交数量【${cur.handleQty}】不可以大于库存数量【${cur.balanceQty}】\n` + } + } }) - if (scanCount == 0) { - this.showErrorMessage("扫描数为0,请先扫描") + }) + if (scanCount == 0) { + this.showErrorMessage("扫描数为0,请先扫描") + return; + } + if (!this.checkLocation()) { + return + } + if (this.jobContent.allowBiggerQty == "FALSE") { + if (str1) { + this.$refs.comMessage.showErrorMessage(str1); return; } - if (!this.checkLocation()) { - return - } - if(this.jobContent.allowBiggerQty == "FALSE"){ - if(str1){ - this.$refs.comMessage.showErrorMessage(str1); - return; - } - } - if(this.jobContent.allowSmallerQty == "FALSE"){ - if(str){ - this.$refs.comMessage.showErrorMessage(str); - return; - } - } - if(str2){ - this.$refs.comMessage.showErrorMessage(str2); + } + if (this.jobContent.allowSmallerQty == "FALSE") { + if (str) { + this.$refs.comMessage.showErrorMessage(str); return; } - if(this.scanCount < this.subList.length){ - //扫描数量小于任务数量,判断是否允许部分提交 - if (this.jobContent.allowPartialComplete == "TRUE") { - //提交 - this.$refs.comMessage.showQuestionMessage1("任务明细未全部完成,是否提交?", 'red', res => { - if (res) { - this.submitJob() - } - }); - } else { - //不允许部分提交,提示 - this.$refs.comMessage.showErrorMessage("任务明细未全部完成,不允许部分提交!", res => { - if (res) { - this.openScanPopup(this.jobToLocationCode); - } - }); - } - }else{ - this.submitJob(); + } + if (str2) { + this.$refs.comMessage.showErrorMessage(str2); + return; + } + if (this.scanCount < this.subList.length) { + //扫描数量小于任务数量,判断是否允许部分提交 + if (this.jobContent.allowPartialComplete == "TRUE") { + //提交 + this.$refs.comMessage.showQuestionMessage1("任务明细未全部完成,是否提交?", 'red', res => { + if (res) { + this.submitJob() + } + }); + } else { + //不允许部分提交,提示 + this.$refs.comMessage.showErrorMessage("任务明细未全部完成,不允许部分提交!", res => { + if (res) { + this.openScanPopup(this.jobToLocationCode); + } + }); } + } else { + this.submitJob(); + } }, commit() { + if (!this.checkLocation()) { + return + } var itemCodes = [] this.detailSource.forEach(item => { itemCodes.push(item.itemCode) @@ -714,10 +694,12 @@ getManagementPrecisions(itemCodes, this.toLocationCode, res => { if (res.success) { this.managementList = res.list; - this.managementType = this.managementList&&this.managementList[0]&&this.managementList[0].ManagementPrecision ? this.managementList[0].ManagementPrecision : 'BY_PACKAGING' - if(this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY'){ + this.managementType = this.managementList && this.managementList[0] && this.managementList[ + 0].ManagementPrecision ? this.managementList[0].ManagementPrecision : + 'BY_PACKAGING' + if (this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY') { this.checkBatch() - }else{ + } else { this.check() } } else { @@ -754,7 +736,7 @@ item.subList.forEach(detail => { if (detail.scaned) { var info = getPackingNumberAndBatch(this.managementList, detail.itemCode, - detail.packingNumber, detail.batch); + detail.packingNumber, detail.batch); detail.toPackingNumber = info.packingNumber; detail.packingNumber = info.packingNumber; detail.fromPackingNumber = info.packingNumber;