diff --git a/common/calc.js b/common/calc.js index 358252ee..2b48e481 100644 --- a/common/calc.js +++ b/common/calc.js @@ -2,16 +2,16 @@ import { Decimal } from 'decimal.js';//引入 class Calc { add(num1,num2) { - return new Decimal(num1).add(new Decimal(num2)) + return new Decimal(num1).add(new Decimal(num2)).toNumber() } sub(num1,num2) { - return new Decimal(num1).sub(new Decimal(num2)) + return new Decimal(num1).sub(new Decimal(num2)).toNumber() } mul(num1,num2) { - return new Decimal(num1).mul(new Decimal(num2)) + return new Decimal(num1).mul(new Decimal(num2)).toNumber() } div(num1,num2) { - return new Decimal(num1).div(new Decimal(num2)) + return new Decimal(num1).div(new Decimal(num2)).toNumber() } } export const calc = new Calc(); \ No newline at end of file diff --git a/common/record.js b/common/record.js index 2e457395..db2b1110 100644 --- a/common/record.js +++ b/common/record.js @@ -6,6 +6,10 @@ import { getDirectoryItemArray, } from '@/common/directory.js'; import { calc } from '@/common/calc' +import { Decimal } from 'decimal.js';//引入 + import { + deepCopyData + } from '@/common/basic.js'; export function createItemInfo(balance, pack) { let item = { @@ -13,25 +17,24 @@ export function createItemInfo(balance, pack) { itemName: pack.itemName, stdPackQty: pack.stdPackQty, stdPackUnit: pack.stdPackUnit, - qty: Number(balance.qty), - handleQty: 0, + qty: new Decimal(balance.qty).toNumber(), + handleQty:new Decimal(0).toNumber(), uom: pack.uom, subList: [] } return item; } -export function createDetailInfo(data, pack) { - data.scaned = true; +export function createDetailInfo(balance, pack) { + balance.scaned = true; // data.toInventoryStatus = this.toInventoryStatus == "" ? data.inventoryStatus : this.toInventoryStatus; // data.inventoryStatus = data.inventoryStatus; - let detail = {}; - Object.assign(detail, data) - detail.balanceQty = Number(detail.qty) - detail.qty = Number(detail.qty); - detail.stdPackQty = Number(pack.stdPackQty) + let detail = deepCopyData(balance); + detail.balanceQty = new Decimal(detail.qty).toNumber() + detail.qty = new Decimal(detail.qty).toNumber(); + detail.stdPackQty = new Decimal(pack.stdPackQty).toNumber() detail.stdPackUnit = pack.stdPackUnit - detail.handleQty =0; + detail.handleQty = new Decimal(detail.qty).toNumber() ; detail.package = pack; return detail; @@ -40,10 +43,10 @@ export function createDetailInfo(data, pack) { //计算实际数量 export function calcHandleQty(detailSource) { for (let item of detailSource) { - item.qty = 0; + item.handleQty = new Decimal(0).toNumber(); for (let detail of item.subList) { if (detail != undefined && detail.scaned) { - item.qty = calc.add(item.qty,detail.qty); + item.handleQty = calc.add(item.handleQty,detail.handleQty); } } } diff --git a/mycomponents/item/itemQty.vue b/mycomponents/item/itemQty.vue index 7eb84b5d..12da2d8a 100644 --- a/mycomponents/item/itemQty.vue +++ b/mycomponents/item/itemQty.vue @@ -4,9 +4,9 @@ - + + :handleQty="dataContent.handleQty" :isShowStatus="false"> - + diff --git a/pages/container/record/containerUnBindRecord.vue b/pages/container/record/containerUnBindRecord.vue index cad024aa..881a7fe6 100644 --- a/pages/container/record/containerUnBindRecord.vue +++ b/pages/container/record/containerUnBindRecord.vue @@ -301,7 +301,7 @@ detail.itemCode = detail.itemCode; detail.batch = detail.batch; detail.inventoryStatus = detail.inventoryStatus; - + detail.qty =detail.handleQty; detail.package = null; subList.push(detail) } diff --git a/pages/count/job/countDetail.vue b/pages/count/job/countDetail.vue index bd732f71..38fd4f7b 100644 --- a/pages/count/job/countDetail.vue +++ b/pages/count/job/countDetail.vue @@ -106,7 +106,6 @@ return { id: '', receiptJob: {}, - received: false, fromLocationCode: '', isShowPackingCode: true, scanCount: 0, @@ -117,7 +116,8 @@ editInventoryStatus: false, package: {}, //包装 label: {}, //标签 - currentEditItem: {} + currentEditItem: {}, + jobStatus:"" }; }, onLoad(option) { @@ -126,7 +126,6 @@ //新建的任务自动接收 if (option.status == "1") { this.receive((callback => { - this.received = true; this.getDetail(); })); } else { @@ -144,7 +143,7 @@ onBackPress(e) { //已经接收但是没提交任务 if (e.from === 'backbutton') { - if (this.received) { + if (this.jobStatus=="2") { //取消承接任务 cancleTakeCountJob(this.id).then(res => { uni.navigateBack(); @@ -190,6 +189,7 @@ that.showMessage('未获取到详情'); } else { that.jobContent = res.data; + that.jobStatus = res.data.status; that.fromLocationCode = that.jobContent.locationCode; that.subList = res.data.subList; that.detailSource = that.getDataSource(that.subList) diff --git a/pages/customerReturn/job/returnDetail.vue b/pages/customerReturn/job/returnDetail.vue index 2c6f06c9..3b282218 100644 --- a/pages/customerReturn/job/returnDetail.vue +++ b/pages/customerReturn/job/returnDetail.vue @@ -82,7 +82,6 @@ data() { return { id: '', - received: false, scanCount: 0, jobContent: {}, //任务内容 subList: [], //接口返回的任务subList @@ -92,6 +91,7 @@ toLocationCode: "", toLocationInfo: {}, tolocationTypeList: [], + jobStatus:"" }; }, onLoad(option) { @@ -100,7 +100,6 @@ //新建的任务自动接收 if (option.status == "1") { this.receive((callback => { - this.received = true; this.getDetail(); })); } else { @@ -118,7 +117,7 @@ onBackPress(e) { //已经接收但是没提交任务 if (e.from == 'backbutton') { - if (this.received) { + if (this.jobStatus=="2") { //取消承接任务 cancleTakeCustomerReturnJob(this.id).then(res => { uni.navigateBack(); @@ -167,8 +166,9 @@ if (res.data.subList.length > 0) { that.jobContent = res.data; that.subList = res.data.subList; + that.jobStatus = res.data.status + that.detailSource = getDataSource(that.subList) - that.fromLocationCode = that.subList[0].fromLocationCode that.toLocationCode = that.subList[0].toLocationCode that.tolocationTypeList = getDirectoryItemArray(that.jobContent.toLocationTypes) diff --git a/pages/customerReturn/record/returnRecord.vue b/pages/customerReturn/record/returnRecord.vue index bfe6611a..aac1152a 100644 --- a/pages/customerReturn/record/returnRecord.vue +++ b/pages/customerReturn/record/returnRecord.vue @@ -149,8 +149,10 @@ } }) if (item == undefined) { + var itemp = createItemInfo(balance, pack); let newDetail = createDetailInfo(balance, pack); // + itemp.subList.push(newDetail); this.detailSource.push(itemp) } else { @@ -316,7 +318,6 @@ }, setParams() { - var subList = [] var creator = this.$store.state.user.id this.detailSource.forEach(item => { @@ -346,7 +347,7 @@ submitItem.fromLocationCode = detail.locationCode; submitItem.toLocationCode = detail.toLocationCode; - submitItem.qty = detail.handleQty!=0?detail.handleQty:detail.qty; + submitItem.qty = detail.handleQty; submitItem.package =""; subList.push(submitItem) diff --git a/pages/customerReturn/request/customerReturnRequestCreate.vue b/pages/customerReturn/request/customerReturnRequestCreate.vue index c91ed6dc..01f1c890 100644 --- a/pages/customerReturn/request/customerReturnRequestCreate.vue +++ b/pages/customerReturn/request/customerReturnRequestCreate.vue @@ -56,6 +56,7 @@ - - diff --git a/pages/productPutaway/job/productPutawayDetail.vue b/pages/productPutaway/job/productPutawayDetail.vue index b91b5119..48c2a833 100644 --- a/pages/productPutaway/job/productPutawayDetail.vue +++ b/pages/productPutaway/job/productPutawayDetail.vue @@ -102,7 +102,6 @@ data() { return { id: '', - received: false, scanCount: 0, jobContent: {}, //任务内容 subList: [], //接口返回的任务subList @@ -112,6 +111,7 @@ toLocationCode: "", toLocationInfo: {}, tolocationTypeList: [], + jobStatus:"" }; }, onLoad(option) { @@ -120,7 +120,6 @@ //新建的任务自动接收 if (option.status == "1") { this.receive((callback => { - this.received = true; this.getDetail(); })); } else { @@ -138,7 +137,7 @@ onBackPress(e) { //已经接收但是没提交任务 if (e.from == 'backbutton') { - if (this.received) { + if (this.jobStatus=="2") { //取消承接任务 cancleTakeProductPutawayJob(this.id).then(res => { uni.navigateBack(); @@ -183,6 +182,7 @@ if (res.data.subList.length > 0) { that.jobContent = res.data; that.subList = res.data.subList; + that.jobStatus = res.data.status that.fromLocationCode = that.subList[0].fromLocationCode that.toLocationCode = that.subList[0].toLocationCode that.tolocationTypeList = getLocationTypeArray(that.jobContent.toLocationTypes) diff --git a/pages/productPutaway/record/productPutawayRecord.vue b/pages/productPutaway/record/productPutawayRecord.vue index 644abbca..76f30d73 100644 --- a/pages/productPutaway/record/productPutawayRecord.vue +++ b/pages/productPutaway/record/productPutawayRecord.vue @@ -335,7 +335,7 @@ submitItem.fromLocationCode = detail.locationCode; submitItem.toLocationCode = detail.toLocationCode; - submitItem.qty = detail.handleQty!=0?detail.handleQty:detail.qty; + submitItem.qty = detail.handleQty; submitItem.package =""; subList.push(submitItem) } diff --git a/pages/productPutaway/request/putawayRequestCreate.vue b/pages/productPutaway/request/putawayRequestCreate.vue index 414b0561..bc89b7b2 100644 --- a/pages/productPutaway/request/putawayRequestCreate.vue +++ b/pages/productPutaway/request/putawayRequestCreate.vue @@ -53,6 +53,7 @@ import { goHome, updateTitle, + deepCopyData, getCurrDateTime, getPackingNumberAndBatchByList } from '@/common/basic.js'; @@ -210,14 +211,7 @@ }, calcHandleQty() { - for (let item of this.detailSource) { - item.qty = 0; - for (let detail of item.subList) { - if (detail != undefined) { - item.qty = calc.add(item.qty,detail.qty) - } - } - } + calcHandleQty(this.detailSource) this.$forceUpdate(); }, @@ -283,7 +277,7 @@ productPutawayRequestSubmit(params).then(res => { uni.hideLoading() if (res.data) { - this.showCommitSuccessMessage("提交成功
生成制品上架申请
" + res.data, ) + this.showCommitSuccessMessage("提交成功
生成制品上架申请
" + res.data) } else { this.showErrorMessage("提交失败[" + res.msg + "]") } @@ -305,8 +299,7 @@ this.detailSource.forEach(item => { item.subList.forEach(detail => { if (detail.scaned) { - var subItem = {}; - Object.assign(subItem, detail) + var subItem = deepCopyData(detail) subItem.fromLocationCode = detail.locationCode; subItem.qty = detail.handleQty; subItem.package = null; diff --git a/pages/productReceipt/job/productReceiptDetail.vue b/pages/productReceipt/job/productReceiptDetail.vue index b4e75298..1d413251 100644 --- a/pages/productReceipt/job/productReceiptDetail.vue +++ b/pages/productReceipt/job/productReceiptDetail.vue @@ -97,7 +97,6 @@ return { id: '', receiptJob: {}, - received: false, toLocationCode: '', isShowPackingCode: true, scanCount: 0, @@ -105,7 +104,8 @@ subList: [], //接口返回的任务subList detailSource: [], //绑定在页面上的数据源 toLocationTypeList: [], - managementList: [] + managementList: [], + jobStatus:"" }; }, @@ -115,7 +115,6 @@ //新建的任务自动接收 if (option.status == "1") { this.receive((callback => { - this.received = true; this.getDetail(); })); } else { @@ -134,7 +133,7 @@ onBackPress(e) { //已经接收但是没提交任务 if (e.from == 'backbutton') { - if (this.received) { + if (this.jobStatus=="2") { //取消承接任务 cancleTakeProductReceiptJob(this.id).then(res => { uni.navigateBack(); @@ -184,6 +183,7 @@ if (res.data.subList.length > 0) { that.jobContent = res.data; that.subList = res.data.subList; + that.jobStatus = res.data.status that.toLocationCode = that.subList[0].toLocationCode that.toLocationTypeList = getDirectoryItemArray(that.jobContent.toLocationTypes) that.detailSource = getDataSource(that.subList) diff --git a/pages/productReceipt/record/productReceiptRecord.vue b/pages/productReceipt/record/productReceiptRecord.vue index f6495709..e1d9b0c2 100644 --- a/pages/productReceipt/record/productReceiptRecord.vue +++ b/pages/productReceipt/record/productReceiptRecord.vue @@ -64,6 +64,8 @@ import { calc } from '@/common/calc.js'; + + import { Decimal } from 'decimal.js';//引入 import { getInventoryStatusDesc, @@ -186,8 +188,8 @@ itemName: pack.itemName, stdPackQty: pack.stdPackQty, stdPackUnit: pack.stdPackUnit, - qty: Number(label.qty), - handleQty: 0, + qty: new Decimal(label.qty).toNumber(), + handleQty: new Decimal(0).toNumber(), uom: pack.uom, subList: [] } @@ -195,11 +197,10 @@ }, createDetailInfo(label, pack) { - let detail = {}; - Object.assign(detail, label) + let detail = deepCopyData(label); detail.scaned = true; - detail.qty = Number(label.qty); - detail.handleQty = 0; + detail.qty = new Decimal(label.qty).toNumber(); + detail.handleQty = new Decimal(label.qty).toNumber(); detail.inventoryStatus = "OK" detail.stdPackQty = pack.stdPackQty; detail.stdPackUnit = pack.stdPackUnit; @@ -211,10 +212,10 @@ calcHandleQty() { for (let item of this.detailSource) { - item.qty = 0; + item.handleQty = new Decimal(0).toNumber(); for (let detail of item.subList) { if (detail != undefined) { - item.qty = calc.add(item.qty,detail.qty) + item.handleQty = calc.add(item.handleQty,detail.handleQty) } } } @@ -331,7 +332,7 @@ submitItem.productionlineCode = this.productionLineCode; submitItem.workStationCode = this.workStationCode; - submitItem.qty = detail.handleQty != 0 ? detail.handleQty : detail.qty; + submitItem.qty = detail.handleQty; submitItem.package = ""; subList.push(submitItem) diff --git a/pages/productionReceipt/job/productionReceiptDetail.vue b/pages/productionReceipt/job/productionReceiptDetail.vue index 2c6bef2f..e724635b 100644 --- a/pages/productionReceipt/job/productionReceiptDetail.vue +++ b/pages/productionReceipt/job/productionReceiptDetail.vue @@ -100,7 +100,6 @@ data() { return { id: '', - received: false, scanCount: 0, jobContent: {}, //任务内容 subList: [], //接口返回的任务subList @@ -109,6 +108,7 @@ fromLocationCode: "", toLocationCode: "", tolocationTypeList: [], + jobStatus:"" }; }, onLoad(option) { @@ -117,7 +117,6 @@ //新建的任务自动接收 if (option.status == "1") { this.receive((callback => { - this.received = true; this.getDetail(); })); } else { @@ -135,7 +134,7 @@ onBackPress(e) { //已经接收但是没提交任务 if (e.from == 'backbutton') { - if (this.received) { + if (this.jobStatus=="2") { //取消承接任务 cancleTakeProductionReceiptJob(this.id).then(res => { uni.navigateBack(); @@ -179,6 +178,7 @@ } else { if (res.data.subList.length > 0) { that.jobContent = res.data; + that.jobStatus = res.data.status that.subList = res.data.subList; that.fromLocationCode = that.subList[0].fromLocationCode that.toLocationCode = that.subList[0].toLocationCode diff --git a/pages/productionReceipt/record/productionReceiptRecord.vue b/pages/productionReceipt/record/productionReceiptRecord.vue index 6a51526b..593a1b6c 100644 --- a/pages/productionReceipt/record/productionReceiptRecord.vue +++ b/pages/productionReceipt/record/productionReceiptRecord.vue @@ -316,6 +316,7 @@ showCommitSuccessMessage(hint) { this.$refs.comMessage.showSuccessMessage(hint, res => { this.fromLocationCode = ''; + this.toLocationCode ="" }) }, diff --git a/pages/productionReturn/coms/comReturnRecord.vue b/pages/productionReturn/coms/comReturnRecord.vue index b201da49..0f8d156a 100644 --- a/pages/productionReturn/coms/comReturnRecord.vue +++ b/pages/productionReturn/coms/comReturnRecord.vue @@ -5,8 +5,7 @@