diff --git a/src/pages/deliver/job/deliverDetailBatch.vue b/src/pages/deliver/job/deliverDetailBatch.vue index b9cbe947..a9f9140e 100644 --- a/src/pages/deliver/job/deliverDetailBatch.vue +++ b/src/pages/deliver/job/deliverDetailBatch.vue @@ -30,9 +30,8 @@ + @updateData='updateData' > - @@ -129,6 +128,7 @@ toLocationCode: "", jobStatus: "", allowBiggerQty:"TRUE",//开启数量校验提示 + jobToLocationCode:"" }; }, @@ -206,11 +206,38 @@ that.jobContent = res.data; that.jobStatus = res.data.status; that.subList = res.data.subList; + that.subList.forEach(item=>{ + item.recommend=true + }) // that.detailSource = res.data; that.detailSource = getDataSourceBatch(that.subList) that.toLocationCode = that.subList[0].toLocationCode that.allowBiggerQty = res.data.allowBiggerQty; that.resizeCollapse(); + + var itemCodes = [] + this.detailSource.forEach(item => { + itemCodes.push(item.itemCode) + item.scaned = false + }) + this.jobToLocationCode=this.detailSource[0].subList[0].toLocationCode + getManagementPrecisions(itemCodes, this.jobToLocationCode, res => { + if (res.success) { + this.managementList = res.list; + //赋值管理精度 + this.detailSource.forEach(item => { + var manageInfo = this.managementList.find(r => + r.itemCode == item.itemCode) + if (manageInfo) { + item.manageType = manageInfo + .ManagementPrecision + } else { + item.manageType = "BY_BATCH" + } + + }) + } + }) } else { that.showMessage('未获取到详情'); } @@ -232,9 +259,13 @@ }); }, - - getScanResult(result, managementTypeParams) { - this.managementType = managementTypeParams + getScanResult(result) { + var detail =this.detailSource.find(r => r.itemCode == result.label.itemCode); + if (detail == undefined) { + this.showErrorMessage("物料号【" + result.label.itemCode + "】不在列表中") + return; + } + let array1 = []//记录推荐的库位 let array2 = []//记录推荐的批次 this.detailSource.forEach(item=>{ @@ -263,9 +294,13 @@ }else{ this.recommendQty = result.balance.qty } - if(managementTypeParams == "BY_BATCH" ||managementTypeParams == "BY_QUANTITY" ){ + + if(detail.manageType == "BY_BATCH" ){ this.setDataBatch(result) - }else{ + }else if(detail.manageType == "BY_QUANTITY" ){ + this.setDataQty(result) + } + else{ this.setData(result) } }, @@ -293,6 +328,7 @@ var itemDetail = detail.subList.find(r => { return r.batch == batch && r.fromLocationCode == result.fromLocationCode + &&!r.recommend }) if (itemDetail == undefined) { var isExit; @@ -439,6 +475,176 @@ this.showMessage(e.message) } }, + + setDataQty(result) { + try { + let that = this + this.balanceinfo = result.balance + 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("没有库存余额") + return; + } + // var inventoryStatus = "OK"; + var detail = this.detailSource.find(r => r.itemCode == itemCode); + + if (detail == undefined) { + this.showErrorMessage("物料号【" + itemCode + "】不在列表中") + } else { + + var itemDetail = detail.subList.find(r => + r.fromLocationCode == result.fromLocationCode&&!r.recommend) + if (itemDetail == undefined) { + var isExit; + for (let subItem of detail.subList) { + var item; + // for (let pack of subItem.packList) { + // if (pack.batch == batch) { + // item = pack; + // isExit = pack; + // break; + // } + // } + // if (item != undefined) { + // subItem.scaned = true + // subItem.handleQty = 0; + // item = undefined + // } + } + if (isExit == undefined) { + // this.showErrorMessage("批次【" + batch + "】库位【" + result + // .fromLocationCode + "】不在列表中") + detail.subList.push({ + scaned:true, + fromLocationCode:this.fromLocationCode, + toLocationCode:this.toLocationCode, + batch:"", + handleQty:result.label.qty, + qty:0, + 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, + // packList:[{ + // scaned : true, + // handleQty : Number(result.label.qty), + // toLocationCode : result.balance.toLocationCode, + // }] + }) + detail.handleQty = 0 + detail.qty = 0 + detail.subList.forEach(item=>{ + item.handleQty = item.handleQty || 0 + detail.handleQty = calc.add(detail.handleQty,item.handleQty) + detail.qty = calc.add(detail.qty,item.qty) + // item.packList.forEach(cur=>{ + // cur.handleQty = calc.add(detail.handleQty,item.handleQty) + // }) + }) + setTimeout(r => { + that.resizeCollapse(); + that.$forceUpdate() + }, 100) + } else { + if (!isExit.cancleScanedHiht && isExit.scaned) { + // this.showMessage("批次【" + batch + "】已经扫描") + } 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; + } + itemDetail.handleQty = calc.add(itemDetail.handleQty,result.label.qty); + detail.handleQty = 0 + detail.balance = result.balance, + detail.subList.forEach(item=>{ + item.handleQty = item.handleQty || 0 + detail.handleQty = calc.add(detail.handleQty,item.handleQty) + // item.packList.forEach(cur=>{ + // cur.handleQty = calc.add(detail.handleQty,item.handleQty) + // }) + }) + // calcHandleQtyAdd(this.detailSource, result.label); + } + this.continueScan() + this.$forceUpdate() + } else { + var scanedLength = 0; + // itemDetail.packList.forEach(res => { + // if (res.scaned) { + // scanedLength++; + // } + // }) + //大哥让加的 + itemDetail.fromInventoryStatus = result.balance.inventoryStatus; + + if (itemDetail.scaned ) { + // this.showMessage("箱码【" + packingNumber + "】已经扫描") + // calcHandleQtyAdd(this.detailSource, result.label); + itemDetail.balance=result.balance + itemDetail.balanceQty=result.balance.qty + itemDetail.uom=result.balance.uom, + itemDetail.handleQty = calc.add(itemDetail.handleQty,result.label.qty); + detail.handleQty = 0 + detail.subList.forEach(item=>{ + item.handleQty = item.handleQty || 0 + detail.handleQty = calc.add(detail.handleQty,item.handleQty) + }) + } else { + itemDetail.scaned = true; + this.detailSource[0].subList.sort(compareAsc('scaned')); //按扫描信息排序 + itemDetail.handleQty = result.label.qty; + itemDetail.scaned = true + itemDetail.balance=result.balance + itemDetail.balanceQty=result.balance.qty + itemDetail.uom=result.balance.uom + itemDetail.packQty=result.package.packQty + itemDetail.packUnit=result.package.packUnit + itemDetail.fromlocationCode=this.fromLocationCode + itemDetail.toLocationCode=this.toLocationCode + // itemDetail.toInventoryStatus = "OK" + // itemDetail.packList.forEach(pac => { + // pac.scaned = true + // pac.handleQty = Number(result.label.qty); + // pac.toLocationCode = result.balance.toLocationCode; + // }) + detail.handleQty = 0 + detail.subList.forEach(item=>{ + item.handleQty = item.handleQty || 0 + detail.handleQty = calc.add(detail.handleQty,item.handleQty) + // item.packList.forEach(cur=>{ + // cur.handleQty = calc.add(detail.handleQty,item.handleQty) + // }) + }) + // calcTreeHandleQty(this.detailSource); + this.continueScan() + this.$forceUpdate() + } + } + } + this.detailSource.forEach(item => { + item.subList.forEach(detail => { + detail.packingNumber = '' + }) + }) + } catch (e) { + this.showMessage(e.message) + } + }, + //继续扫描 continueScan() { this.scanCount = getScanCount(this.subList); @@ -547,7 +753,12 @@ detail.totalQty =calc.add(detail.totalQty,item.handleQty) if(item.scaned){ if(item.handleQty>item.balance.qty){ - str2 += `物料号【${detail.itemCode}】批次【${item.batch}】提交数量【${item.handleQty}】不可以大于库存数量【${item.balance.qty}】` + if(item.batch){ + str2 += `物料号【${detail.itemCode}】批次【${item.batch}】提交数量【${item.handleQty}】不可以大于库存数量【${item.balance.qty}】` + }else { + str2 += `物料号【${detail.itemCode}】提交数量【${item.handleQty}】不可以大于库存数量【${item.balance.qty}】` + } + } } }) @@ -609,8 +820,6 @@ } var params = this.setParams() - console.log("提交参数", params); - console.log("提交参数", params.subList); // const isTrue = params.subList.some(item=>{ // console.log(item.recordList.some(cur=>cur.scaned)) // return item.recordList.some(cur=>cur.scaned) == true @@ -662,13 +871,13 @@ obj1.toLocationCode = record.toLocationCode; obj1.supplierCode = record.supplierCode; obj1.uom = record.uom; - obj1.toPackingNumber =''; - obj1.packingNumber = '' - obj1.fromPackingNumber = ''; - obj1.toBatch = record.batch; - obj1.toPackingNumber = ''; - obj1.packingNumber = ''; - obj1.fromPackingNumber =''; + var info = getPackingNumberAndBatch(this.managementList, toLocationCode.itemCode, + record.packingNumber, record.batch); + + obj1.toPackingNumber =info.packingNumber; + obj1.packingNumber = info.packingNumber; + obj1.fromPackingNumber = info.packingNumber; + obj1.toBatch = info.batch; obj = {...obj1} recordList.push(obj1) }) diff --git a/src/pages/deliver/job/deliverJob.vue b/src/pages/deliver/job/deliverJob.vue index 7d33ce40..af2d36f2 100644 --- a/src/pages/deliver/job/deliverJob.vue +++ b/src/pages/deliver/job/deliverJob.vue @@ -196,7 +196,7 @@ }, openJobDetail(item) { - getManagementPrecisions([item.itemCode], item.fromLocationCode, ret => { + getManagementPrecisions([item.itemCode], item.toLocationCode, ret => { if (ret.success) { this.managementList = ret.list; this.managementType = this.managementList&&this.managementList[0]&&this.managementList[0].ManagementPrecision diff --git a/src/pages/productReceipt/coms/comProductDetailCardQty.vue b/src/pages/productReceipt/coms/comProductDetailCardQty.vue new file mode 100644 index 00000000..3a21ce92 --- /dev/null +++ b/src/pages/productReceipt/coms/comProductDetailCardQty.vue @@ -0,0 +1,168 @@ + + + + + \ No newline at end of file diff --git a/src/pages/productReceipt/job/productReceiptDetail.vue b/src/pages/productReceipt/job/productReceiptDetail.vue index f3d5b7fa..9b7933ec 100644 --- a/src/pages/productReceipt/job/productReceiptDetail.vue +++ b/src/pages/productReceipt/job/productReceiptDetail.vue @@ -28,7 +28,7 @@ 班次 - + {{jobContent.shiftName}} @@ -36,19 +36,23 @@ - - - + @remove="updateData" @updateData="updateData" :locationAreaTypeList='toLocationAreaTypeList' + v-if="item.manageType=='BY_PACKAGING'"> + + + + + @@ -70,7 +74,8 @@ - + @@ -90,7 +95,7 @@ import { goHome, navigateBack, - getPackingNumberAndBatch, + getPackingNumberAndBatch, getSwitchInfoByCode } from '@/common/basic.js'; @@ -117,6 +122,7 @@ import jobTop from '@/mycomponents/job/jobTop.vue' import comProductDetailCard from "@/pages/productReceipt/coms/comProductDetailCard.vue" import comProductDetailCardBatch from "@/pages/productReceipt/coms/comProductDetailCardBatch.vue" + import comProductDetailCardQty from "@/pages/productReceipt/coms/comProductDetailCardQty.vue" export default { @@ -127,8 +133,9 @@ locationCompare, winScanPack, jobTop, - comProductDetailCard, - comProductDetailCardBatch + comProductDetailCard, + comProductDetailCardBatch, + comProductDetailCardQty }, data() { return { @@ -142,13 +149,13 @@ detailSource: [], //绑定在页面上的数据源 toLocationAreaTypeList: [], managementList: [], - managementType:'', + managementType: '', jobStatus: "", jobToLocationCode: "", status: '', scanMessage: "", productionLineCode: "", - isNoSearchPackage:false + isNoSearchPackage: false }; }, onLoad(option) { @@ -159,7 +166,7 @@ this.id = option.id; this.scanMessage = option.scanMessage; this.status = option.status || '' - this.isNoSearchPackage=option.isNoSearchPackage + this.isNoSearchPackage = option.isNoSearchPackage }, onShow() { @@ -233,16 +240,16 @@ } else { if (res.data.subList.length > 0) { that.jobContent = res.data; - console.log(344,that.jobContent.allowModifyLocation) + console.log(344, that.jobContent.allowModifyLocation) that.subList = res.data.subList; that.jobStatus = res.data.status; that.jobToLocationCode = that.subList[0].toLocationCode; - that.productionLineCode = that.jobContent.subList[0].productionLineCode; - var valiDate = getSwitchInfoByCode("semiProductReceipCommitValidate") - if(valiDate){ - that.jobContent.allowModifyLocation = 'TRUE' - }else{ - that.jobContent.allowModifyLocation = 'FALSE' + that.productionLineCode = that.jobContent.subList[0].productionLineCode; + var valiDate = getSwitchInfoByCode("semiProductReceipCommitValidate") + if (valiDate) { + that.jobContent.allowModifyLocation = 'TRUE' + } else { + that.jobContent.allowModifyLocation = 'FALSE' } that.toLocationCode = that.subList[0].toLocationCode that.toLocationAreaTypeList = getDirectoryItemArray(that.jobContent.toAreaTypes) @@ -259,8 +266,18 @@ 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.detailSource.forEach(item => { + var manageInfo = this.managementList.find(r => + r.itemCode == item.itemCode) + if (manageInfo) { + item.manageType = manageInfo + .ManagementPrecision + } else { + item.manageType = "BY_BATCH" + } + + }) } }) } else { @@ -279,57 +296,102 @@ mask: true }); const res1 = await getNumberForStatus(result.label.requestNumber) - if(res1.data == 5){ - uni.hideLoading() + if (res1.data == 5) { + uni.hideLoading() this.showErrorMessage(`该品番对应的申请【${result.label.requestNumber}】已关闭`) return - }else if(res1.data == 8){ - uni.hideLoading() + } else if (res1.data == 8) { + uni.hideLoading() this.showErrorMessage(`该品番对应的生产任务【${result.label.requestNumber}】已经完成`) return } - uni.hideLoading() + uni.hideLoading() let label = result.label; var packingNumber = label.packingNumber; var batch = label.batch; var qty = label.qty; var itemCode = label.itemCode; + 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 => - r.batch == batch); - if (itemDetail == undefined) { - this.showErrorMessage("批次[" + batch + "]不在任务列表中") - } else { - if (itemDetail.scaned) { - // this.showErrorMessage("批次[" + batch + "]已经扫描") - itemDetail.handleQty = calc.add(Number(result.label.qty),itemDetail.handleQty); + var itemDetail; + //如果是包装管理,需要包装参与判断 + if (detail.manageType == "BY_PACKAGING") { + itemDetail = detail.subList.find(r => + r.itemCode == itemCode && + r.batch == batch && + r.packingNumber == packingNumber); + if (itemDetail) { + if (itemDetail.scaned) { + this.showErrorMessage("包装[" + packingNumber + "]" + "批次[" + batch + "]不在任务列表中") + } else { + itemDetail.scaned = true; + itemDetail.handleQty = Number(result.label.qty); + // itemDetail.toLocationCode = this.toLocationCode; + itemDetail.labelQty = Number(result.label.qty); + this.continueScan() + this.$forceUpdate() + } + calcHandleQty(this.detailSource); } else { - itemDetail.scaned = true; - itemDetail.handleQty = Number(result.label.qty); - // itemDetail.toLocationCode = this.toLocationCode; - itemDetail.labelQty = Number(result.label.qty); - this.continueScan() - this.$forceUpdate() + this.showErrorMessage("包装[" + packingNumber + "]" + "批次[" + batch + "]不在任务列表中") } + } else if (detail.manageType == "BY_BATCH") { + itemDetail = detail.subList.find(r => + r.itemCode == itemCode && + r.batch == batch); + if (itemDetail) { + if (itemDetail.scaned) { + itemDetail.handleQty = calc.add(Number(result.label.qty), itemDetail.handleQty); + } else { + itemDetail.scaned = true; + itemDetail.handleQty = Number(result.label.qty); + itemDetail.labelQty = Number(result.label.qty); + this.continueScan() + this.$forceUpdate() + } calcHandleQty(this.detailSource); + } else { + this.showErrorMessage("批次[" + batch + "]不在任务列表中") + } + + } else if (detail.manageType == "BY_QUANTITY") { + itemDetail = detail.subList.find(r => + r.itemCode == itemCode); + if (itemDetail) { + if (itemDetail.scaned) { + itemDetail.handleQty = calc.add(Number(result.label.qty), itemDetail.handleQty); + } else { + itemDetail.scaned = true; + itemDetail.handleQty = Number(result.label.qty); + itemDetail.labelQty = Number(result.label.qty); + this.continueScan() + this.$forceUpdate() + } + calcHandleQty(this.detailSource); + } else { + this.showErrorMessage("包装[" + packingNumber + "]" + "批次[" + batch + "]不在任务列表中") + } } + } }, //继续扫描 continueScan() { - this.scanCount = getScanCount(this.subList); - if (this.scanCount == this.subList.length) { - this.closeScanPopup(); - } else { - this.scanPopupGetFocus(); - } + this.scanPopupGetFocus(); + // this.scanCount = getScanCount(this.subList); + // if (this.scanCount == this.subList.length) { + // this.closeScanPopup(); + // } else { + // this.scanPopupGetFocus(); + // } }, @@ -376,20 +438,20 @@ }); }, - async commit() { + async commit() { this.scanCount = getScanCount(this.subList); if (this.scanCount == 0) { this.showErrorMessage("扫描数为0,请先扫描") return; - } + } var valiDate = getSwitchInfoByCode("semiProductReceipCommitValidate") - //校验库位、 - if(valiDate){ - if (!this.checkLocation()) { - return - } - }else{ - this.toLocationCode = this.jobToLocationCode + //校验库位、 + if (valiDate) { + if (!this.checkLocation()) { + return + } + } else { + this.toLocationCode = this.jobToLocationCode } //获取管理模式,封装参数 var itemCodes = [] @@ -399,16 +461,17 @@ await 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' + this.managementType = this.managementList && this.managementList[0] && this + .managementList[0].ManagementPrecision; } }) //扫描数量和任务数量相等,直接提交 if (this.scanCount == this.subList.length) { - if(this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY'){ + if (this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY') { if (this.checkCountBatch()) { this.submitJob(); } - }else{ + } else { if (this.checkCount()) { this.submitJob(); } @@ -417,11 +480,11 @@ //扫描数量小于任务数量,判断是否允许部分提交 if (this.jobContent.allowPartialComplete == "TRUE") { //提交 - if(this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY'){ + if (this.managementType == 'BY_BATCH' || this.managementType == 'BY_QUANTITY') { if (this.checkCountBatch()) { this.submitJob(); } - }else{ + } else { if (this.checkCount()) { this.submitJob(); } @@ -445,7 +508,8 @@ var subItem = item.subList[i] if (calc.sub(subItem.handleQty, subItem.qty) < 0) { isCheck = false; - hint = "包装【" + subItem.packingNumber + "】实际收货数量:[" + subItem.handleQty + "]与包装数量[" + subItem.qty + + hint = "包装【" + subItem.packingNumber + "】实际收货数量:[" + subItem.handleQty + "]与包装数量[" + subItem + .qty + "]不相等,是否继续收货?" break } @@ -462,42 +526,42 @@ return isCheck; }, - checkCountBatch(){ - var isCheck = true; - var hint = "" - for (var i = 0; i < this.detailSource.length; i++) { - var item = this.detailSource[i]; - let handleQty = 0 - for (var j = 0; j < item.subList.length; j++) { + checkCountBatch() { + var isCheck = true; + var hint = "" + for (var i = 0; i < this.detailSource.length; i++) { + var item = this.detailSource[i]; + let handleQty = 0 + for (var j = 0; j < item.subList.length; j++) { var subItem = item.subList[j] - handleQty = calc.add(handleQty,subItem.handleQty) + handleQty = calc.add(handleQty, subItem.handleQty) + } + if (parseFloat(handleQty) < parseFloat(item.qty)) { + hint = "物料号【" + item.itemCode + "】实际收货数量【" + handleQty + "】小于任务的收货数量【" + item.qty + "】,\n" + isCheck = false; + } + // for (var j = 0; j < item.subList.length; j++) { + // var subItem = item.subList[i] + // console.log(calc.sub(subItem.handleQty, subItem.qty) ) + // if (calc.sub(subItem.handleQty, subItem.qty) < 0 || calc.sub(subItem.handleQty, subItem.qty) > 0) { + // isCheck = false; + // hint = "批次【" + subItem.batch + "】批次【" + subItem.batch + "】实际收货数量【" + subItem.handleQty + "】小于任务的收货数量【" + subItem.qty + + // "】,对于未收货部分将创建一个新的收货任务?" + // break + // } + + // } } - if(parseFloat(handleQty) { + if (res) { + this.submitJob(); + } + }) } - // for (var j = 0; j < item.subList.length; j++) { - // var subItem = item.subList[i] - // console.log(calc.sub(subItem.handleQty, subItem.qty) ) - // if (calc.sub(subItem.handleQty, subItem.qty) < 0 || calc.sub(subItem.handleQty, subItem.qty) > 0) { - // isCheck = false; - // hint = "批次【" + subItem.batch + "】批次【" + subItem.batch + "】实际收货数量【" + subItem.handleQty + "】小于任务的收货数量【" + subItem.qty + - // "】,对于未收货部分将创建一个新的收货任务?" - // break - // } - - // } - } - console.log(isCheck) - if (!isCheck) { - this.showQuestMessage(hint+'对于未收货部分将创建一个新的收货任务?', res => { - if (res) { - this.submitJob(); - } - }) - } - - return isCheck; + + return isCheck; }, submitJob() { uni.showLoading({ @@ -512,17 +576,16 @@ if (res.success) { this.managementList = res.list; let params = this.setParams(); - console.log("提交参数", JSON.stringify(params)); productReceiptJobsubmit(params).then(res => { uni.hideLoading() if (res.data) { var hint = "" - if(params.type=='predict'){ - hint="提交成功\n生成补给品收货记录\n" +res.data - }else if(params.type=='assemble'){ - hint="提交成功\n生成号口品收货记录\n" +res.data - }else { - hint="提交成功\n生成收货记录\n" + if (params.type == 'predict') { + hint = "提交成功\n生成补给品收货记录\n" + res.data + } else if (params.type == 'assemble') { + hint = "提交成功\n生成号口品收货记录\n" + res.data + } else { + hint = "提交成功\n生成收货记录\n" } this.showCommitSuccessMessage(hint) } else {