From 21a6f3a18a32a9a210ca17769ea0a2276408c22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BF=97=E5=9B=BD?= <854933521@qq.com> Date: Fri, 1 Nov 2024 15:47:04 +0800 Subject: [PATCH] =?UTF-8?q?page/purchaseReturn=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=208/8-10/25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coms/comReturnDetailCard.vue | 176 +++ .../coms/comReturnDetailCardBatch.vue | 153 +++ .../purchaseReturn/coms/comReturnJobCard.vue | 2 +- .../purchaseReturn/coms/comScanReturnPack.vue | 1033 +++++++++++++++++ .../coms/comScanReturnPackBatch.vue | 558 +++++++++ src/pages/purchaseReturn/job/returnDetail.vue | 309 +++-- src/pages/purchaseReturn/js/return.js | 111 ++ .../purchaseReturn/record/returnRecord.vue | 5 +- .../request/returnRequestCreate.vue | 6 +- 9 files changed, 2248 insertions(+), 105 deletions(-) create mode 100644 src/pages/purchaseReturn/coms/comReturnDetailCard.vue create mode 100644 src/pages/purchaseReturn/coms/comReturnDetailCardBatch.vue create mode 100644 src/pages/purchaseReturn/coms/comScanReturnPack.vue create mode 100644 src/pages/purchaseReturn/coms/comScanReturnPackBatch.vue create mode 100644 src/pages/purchaseReturn/js/return.js diff --git a/src/pages/purchaseReturn/coms/comReturnDetailCard.vue b/src/pages/purchaseReturn/coms/comReturnDetailCard.vue new file mode 100644 index 00000000..907a29a3 --- /dev/null +++ b/src/pages/purchaseReturn/coms/comReturnDetailCard.vue @@ -0,0 +1,176 @@ + + + + \ No newline at end of file diff --git a/src/pages/purchaseReturn/coms/comReturnDetailCardBatch.vue b/src/pages/purchaseReturn/coms/comReturnDetailCardBatch.vue new file mode 100644 index 00000000..016e1177 --- /dev/null +++ b/src/pages/purchaseReturn/coms/comReturnDetailCardBatch.vue @@ -0,0 +1,153 @@ + + + + + \ No newline at end of file diff --git a/src/pages/purchaseReturn/coms/comReturnJobCard.vue b/src/pages/purchaseReturn/coms/comReturnJobCard.vue index 50e018ce..56564838 100644 --- a/src/pages/purchaseReturn/coms/comReturnJobCard.vue +++ b/src/pages/purchaseReturn/coms/comReturnJobCard.vue @@ -1,6 +1,6 @@ diff --git a/src/pages/purchaseReturn/coms/comScanReturnPack.vue b/src/pages/purchaseReturn/coms/comScanReturnPack.vue new file mode 100644 index 00000000..c80dc504 --- /dev/null +++ b/src/pages/purchaseReturn/coms/comScanReturnPack.vue @@ -0,0 +1,1033 @@ + + + + +export default { +name: 'winScanPack', +components: { +winComScan, +balance, +balanceQtyEdit, +balanceSelect +}, +props: { +title: { +type: String, +default: '' +}, +headerType: { +type: String, +default: "HPQ,HMQ" +}, +allowModifyLocation:{ +type:Boolean, +default:false +} + +}, +data() { +return { +dataContent: {}, +jobContent: {}, +expendIcon: 'arrow-down', +show: false, +scanList: [], +toLocation: null, +toLocationCode: '', +fromLocationList: [], +fromLocationCode: '', +fromLocation: null, +issueRecord: [], //退货历史 +expand: true, +scanOptions: {}, +editItem: {}, +positionInfo: "请选择位置", +positionList: [], +defaultValueList: [], +label: {}, +fromInventoryStatuses: [], +packageInfo: {} +} +}, +created() { + +}, +watch: {}, +mounted() { +this.detailOptions = getDetailOption(); +this.scanOptions = getDetailEditRemoveOption(); +}, +methods: { +openScanPopup(content, jobcontent) { +this.issueRecord = []; +this.dataContent = content; +this.jobContent = jobcontent; +this.initData(); +this.positionInfo = this.jobContent.workShopCode + "-" + this.jobContent.subList[0].productionLineCode + +"-" + this.jobContent.subList[0].workStationCode +this.$refs.popup.open('bottom') +setTimeout(res => { +this.getfocus(); +}, 500) +}, + +closeScanPopup() { +this.losefocus() +this.$refs.popup.close(); +this.$emit("closeScan") +//清除数据,恢复默认值 +// Object.assign(this.$data, this.$options.data()); +}, + +initData() { +let that = this; +that.fromLocationList = []; +if (that.dataContent != null) { +that.fromInventoryStatuses = getDirectoryItemArray(this.jobContent.outInventoryStatuses) +that.toLocation = that.dataContent[0]; +that.toLocationCode = that.dataContent[0].toLocationCode; +that.fromLocationList = that.getFromLocationList(); +} +}, + +showBalanceSelect(items, packageInfo) { +this.packageInfo = packageInfo; +this.$refs.balanceSelect.openPopup(items); +}, + +getFromLocationList() { +let list = []; +this.dataContent.forEach(location=>{ +location.Items.forEach(item => { +item.Locations.forEach(f => { +list.push(f.fromLocationCode) +}) +}) +}) +this.fromLocationCode = list[0]; +return list; +}, + +fromLocationUpdate(fromlocation) { +let location = this.fromLocationList.find(r => r == fromlocation) +// 成品退货任务--同一物料,可以扫描提交不在任务中的库位 +// if (location == undefined) { +this.fromLocationCode = fromlocation +// this.showErrorMessage('退货库位【' + fromlocation + '】不存在') +// } +}, +onScan(result) { +try { +let that = this; + +if (that.fromLocationCode == '') { +that.showErrorMessage('请选择来源库位', res => { +that.$refs.toLocationCombox.onFocus(); +}); +return; +} +let packageInfo = result.package; +let itemCode = result.label.itemCode; +let packingCode = result.label.packingNumber; +let lot = result.label.batch; +let item = that.toLocation.Items.find(r => r.itemCode == itemCode); +if (item == undefined) { +that.showErrorMessage('未查找到物料【' + itemCode + '】的退货明细', +res => { +that.getfocus(); +} +) +return; +} else { +//查找库存信息 +uni.showLoading({ +title: '加载中', +mask: true +}) +getBalanceByManagementPrecision(result.label, that.fromLocationCode, that.fromInventoryStatuses, +balanceRes => { +if (balanceRes.success) { +if (balanceRes.data.list.length == 0) { +this.showErrorMessage('在来源库位[' + this.fromLocationCode + '],未查找到该包装的库存记录', +res => { +this.packGetFocus(); +}) +} else if (balanceRes.data.list.length == 1) { +let balance = balanceRes.data.list[0]; +this.afterGetBalance(result.label, balance, packageInfo); +} else { +this.label = result.label; +this.showBalanceSelect(balanceRes.data.list, packageInfo); +} +} else { +this.showErrorMessage(balanceRes.message.message); +} +uni.hideLoading(); +}); +} +} catch (e) { +this.showErrorMessage(e.stack) +uni.hideLoading(); +} +}, + +selectBalanceItem(balance) { +this.afterGetBalance(balance, balance, this.packageInfo); +}, + + +afterGetBalance(label, balance, packageInfo) { +let that = this; +try { +let itemCode = label.itemCode; +let packingCode = label.packingNumber; +let lot = label.batch; +let item = that.toLocation.Items.find(r => r.itemCode == itemCode); +let fromLocation = item.Locations.find(l => l.fromLocationCode == that.fromLocationCode); +// 成品退货任务--同一物料,可以扫描提交不在任务中的库位 +if(!fromLocation){ +fromLocation = { +Batchs:[{ +Recommends:[], +Records: [], +batch: label.batch, +detail:{ +...packageInfo, +fromLocationCode: balance.locationCode, +toLocationCode:this.toLocationCode +}, +handleQty: 0, +packingNumber: null, +// packingNumber: label.packingNumber, +qty: label.qty, +uom: label.uom +}], +toLocationCode:this.toLocationCode, +fromLocationCode: balance.locationCode, +handleQty: 0, +qty: label.qty, +uom: label.uom +} +item.Locations.push(fromLocation) +} +if (fromLocation != undefined) { +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) { +//如果有推荐箱码 +if (batch.Recommends&&batch.Recommends.length > 0) { +let recommend = batch.Recommends.find(r => r.packingNumber == packingCode); +if (recommend != undefined) { +that.addRecord(batch, label, balance, packageInfo) +} else { +//允许修改箱码 +if (this.jobContent.allowModifyPackingNumber == 'TRUE') { +that.addRecord(batch, label, balance, packageInfo); +} else { +that.showErrorMessage('未查找到该箱码【' + packingCode + '】的明细', +res => { +that.getfocus(); +} +) +} +} +} else { +that.addRecord(batch, label, balance, packageInfo) +} +} else { +that.showErrorMessage('箱码【' + packingCode + '】已经扫描,请继续扫描下一箱', +res => { +that.getfocus(); +} +) +} +} else { +if (this.jobContent.allowModifyBatch == "TRUE") { +this.showQuestionMessage('在【' + that.fromLocationCode + '】库位下,未查找到批次【' + lot + +'】的退货明细,是否要继续退货?', res => { +if (res) { +let batch = that.createBatchInfo(label, balance,packageInfo); +fromLocation.Batchs.unshift(batch); +} +}) +} else { +that.showErrorMessage("未查找到\n物料【"+itemCode+"】批次【" + lot +" 】的退货明细", +res => { +that.getfocus(); +}); +} +} +} else { +that.showErrorMessage('未查找到推荐库位【' + that.fromLocationCode + '】的退货明细', +res => { +that.getfocus(); +} +) +} +} catch (e) { +that.showErrorMessage(e.stack, +res => { +that.getfocus(); +} +) +} +}, + +createBatchInfo(data, balance, packageInfo) { +let batch = { +batch: data.lot||data.batch, +qty: 0, +uom: data.uom, +handleQty: Number(data.qty), +Records: [], +detail:{ +fromLocationCode:this.fromLocationCode, //balance.locationCode +toLocationCode:this.toLocationCode, +itemCode:data.itemCode, +handleQty: Number(data.qty), +packingNumber:data.packingNumber, +qty: 0, +uom:data.uom, +itemName:packageInfo.itemName, +itemDesc1:packageInfo.itemDesc1, +itemDesc2:packageInfo.itemDesc2, +singlePrice:balance.singlePrice, +amount:balance.amount +} +} +let record = this.creatRecord(data, balance, packageInfo); +batch.Records.push(record); +this.issueRecord.unshift(record) +return batch; +}, + +creatRecord(label, balance, packageInfo) { +balance.packQty = packageInfo.packQty +balance.packUnit = packageInfo.packUnit +let record = { +scaned: true, +itemCode: label.itemCode, +packingNumber: label.packingNumber, +batch: label.batch, +qty: Number(label.qty) > Number(balance.qty) ? Number(balance.qty) : Number(label.qty), +uom: balance.uom, +inventoryStatus: balance.inventoryStatus, +balance: balance, +toLocationCode: this.toLocationCode, +supplierCode: label.supplierCode, +packUnit: packageInfo.packUnit, +packQty: packageInfo.packQty, +singlePrice:balance.singlePrice, +amount:balance.amount +} +return record; +}, + +calcBatchHandleQty(batch) { +let handleQty = 0; +batch.Records.forEach(res => { +handleQty = calc.add(handleQty, res.qty) +}) +batch.handleQty = handleQty; +}, + +addRecord(batch, label, balance, packageInfo) { +let record = this.creatRecord(label, balance, packageInfo); +batch.Records.push(record); +this.issueRecord.unshift(record) +this.calcBatchHandleQty(batch); +this.$emit('updateData', ""); +this.getfocus(); +}, + +getfocus() { +if (this.$refs.comscan != undefined) { +this.$refs.comscan.getfocus(); +} +}, + +losefocus() { +if (this.$refs.comscan != undefined) { +this.$refs.comscan.losefocus(); +} +}, + +expands() { +this.expand = !this.expand; +this.expendIcon = this.expand == true ? "arrow-down" : "arrow-up" +}, + +swipeClick(e, item, index) { +if (e.content.text == "详情") { +this.detail(item) +} else if (e.content.text == "编辑") { +this.edit(item) +} else if (e.content.text == "移除") { +this.remove(item, index) +} +}, +edit(item) { +this.editItem = item; +// item.balance.balanceQty = item.balance.qty; +item.balance.balanceQty = item.balance.qty; +this.$refs.balanceQtyEdit.openEditPopup(item.balance, item.qty); +}, + +detail(item) { +this.showItem = item; +this.$refs.receiptHint.openScanPopup() +}, +remove(record, index) { +this.showQuestionMessage("确定移除扫描信息?", +res => { +if (res) { +record.qty = 0; +this.issueRecord.splice(index, 1) + +let item = this.toLocation.Items.find(r => r.itemCode == record.itemCode); +if (item != undefined) { +item.Locations.forEach(l => { +let batch = l.Batchs.find(b => b.packingNumber == record.packingNumber && b +.batch == record.batch); +let rIndex = batch.Records.findIndex(r => r.packingNumber == record +.packingNumber && r +.batch == record.batch); +batch.Records.splice(rIndex, 1); +}) +} +this.$emit('updateData', item); +} +}); +}, + +packGetFocus() { +this.$refs.comscan.getfocus(); +}, +packLoseFocus() { +this.$refs.comscan.losefocus(); +}, +showMessage(message, callback) { +setTimeout(r => { +this.packLoseFocus(); +this.$refs.comMessage.showMessage(message, callback); +}) +}, +showErrorMessage(message, callback) { +setTimeout(r => { +this.packLoseFocus(); +this.$refs.comMessage.showErrorMessage(message, callback); + +}) +}, +showQuestionMessage(message, callback) { +setTimeout(r => { +this.packLoseFocus(); +this.$refs.comMessage.showQuestionMessage(message, callback); +}) +}, +confirm(val) { +this.editItem.qty = Number(val); +this.$emit('updateData', this.editItem) +}, +cancle() { +this.closeScanPopup() +} +} +} + + + diff --git a/src/pages/purchaseReturn/coms/comScanReturnPackBatch.vue b/src/pages/purchaseReturn/coms/comScanReturnPackBatch.vue new file mode 100644 index 00000000..d6aacd87 --- /dev/null +++ b/src/pages/purchaseReturn/coms/comScanReturnPackBatch.vue @@ -0,0 +1,558 @@ + + + + + diff --git a/src/pages/purchaseReturn/job/returnDetail.vue b/src/pages/purchaseReturn/job/returnDetail.vue index 7916aa02..2fb89c2f 100644 --- a/src/pages/purchaseReturn/job/returnDetail.vue +++ b/src/pages/purchaseReturn/job/returnDetail.vue @@ -5,17 +5,33 @@ - 申请单号:{{ jobContent.requestNumber }} + + + + 订单号 + {{poNumber}} + + + 来源库位 + {{fromLocationCode}} + + + - - - - + + + + + @@ -24,12 +40,13 @@ - + - - + + + @@ -43,15 +60,18 @@ import { getPurchasereturnJobDetail, purchaseReturnJobsubmit, cancleTakePurchase import { goHome, getCurrDateTime, getPackingNumberAndBatch, navigateBack } from '@/common/basic.js' import { getInventoryStatusName } from '@/common/directory.js' -import { getDataSource, createRecordInfo, calcHandleQty, getScanCount } from '@/common/detail.js' +import { createRecordInfo, calcHandleQty, getScanCount } from '@/common/detail.js' import { getManagementPrecisions } from '@/common/balance.js' - +import { getDataSource } from '@/pages/issue/js/issue.js'; +import { calc } from '@/common/calc.js'; import winScanButton from '@/mycomponents/scan/winScanButton.vue' import winScanPackAndLocation from '@/mycomponents/scan/winScanPackAndLocation.vue' -import comDetailCard from '@/mycomponents/detail/comDetailCard.vue' import returnDetailInfoPopup from '@/pages/purchaseReturn/coms/returnDetailInfoPopup.vue' import jobTop from '@/mycomponents/job/jobTop.vue' +import comReturnDetailCard from '@/pages/purchaseReturn/coms/comReturnDetailCard.vue' +import comReturnDetailCardBatch from '@/pages/purchaseReturn/coms/comReturnDetailCardBatch.vue' +import comScanReturnPack from '@/pages/purchaseReturn/coms/comScanReturnPack.vue' import { useCountStore } from '@/store' // 获取自定义的store const store = useCountStore() @@ -73,6 +93,11 @@ const scanPopup = ref() const comScanLocation = ref() const comMessageRef = ref() const jobDetailPopup = ref() +const poNumber = ref('') +const fromLocationCode = ref('') +const managementList = ref('') +const comIssueDetailCard = ref() +const comScanIssuePack = ref(null) onLoad((option) => { uni.setNavigationBarTitle({ title: `${option.title}详情` @@ -145,7 +170,9 @@ const getDetail = () => { jobStatus.value = res.data.status subList.value = res.data.subList toLocationCode.value = jobContent.value.toLocationCode - detailSource.value = getDataSource(subList.value) + detailSource.value = getDataSource(detailSource.value,subList.value); + fromLocationCode.value = subList.value[0].fromLocationCode + poNumber.value = subList.value[0].poNumber } else { showMessage('列表数据为0') } @@ -155,9 +182,16 @@ const getDetail = () => { showErrorMessage(error) }) } -const calcHandleQty1 = () => { - calcHandleQty(detailSource.value) - continueScan() +const closeScan = ()=> { + resizeCollapse(); +} + +const resizeCollapse = ()=> { + nextTick(r => { + comIssueDetailCard.value.forEach(r => { + r.resizeCollapse(); + }) + }); } const calcScanCount = (closeScan) => { const items = subList.value.filter((r) => { @@ -179,48 +213,108 @@ const continueScan = () => { scanPopupGetFocus() } } -const updateData = () => { - calcHandleQty1() -} -const getScanResult = (result) => { - try { - const { packingNumber } = result.label - const { batch } = result.label - const { qty } = result.label - const { itemCode } = result.label - let itemDetail - const detail = detailSource.value.find((r) => r.itemCode == itemCode) - if (detail == undefined) { - showMessage(`物料号【${itemCode}】不在列表中`) - } else { - // 箱码、批次、库位、 - itemDetail = detail.subList.find((r) => { - return r.packingNumber == packingNumber && r.batch == batch && r.fromLocationCode == result.fromLocationCode +const updateData = (record) => { + if(record){ + let requestLocation = detailSource.value.find(r => r.toLocationCode == record.toLocationCode); + let item = requestLocation.Items.find(r => r.itemCode == record.itemCode); + let itemHandleQty = 0; + if (item != undefined) { + item.Locations.forEach(l => { + let batch = l.Batchs.find(b => (b.packingNumber == record.packingNumber || b + .packingNumber == null || b.packingNumber == '') && b.batch == + record.batch); + let handleQty = 0; + if (batch != undefined) { + batch.Records.forEach(res => { + handleQty = calc.add(handleQty, res.qty) + }) + batch.handleQty = handleQty; + itemHandleQty = calc.add(itemHandleQty, handleQty) + } }) - // const balanceStatus = getInventoryStatusName(result.balance.inventoryStatus) - // 不存在提示 - if (itemDetail == undefined) { - showErrorMessage(`箱码【${packingNumber}】
批次【${batch}】
库位【${result.fromLocationCode}】
状态【${balanceStatus}】
未找到明细`) - return - } - if (itemDetail.scaned) { - showErrorMessage(`箱码【${packingNumber}】
批次【${batch}】
库位【${result.fromLocationCode}】已经扫描`) - return + item.handleQty=itemHandleQty; + } + }else { + //计算扫描数量 + detailSource.value.forEach(detail => { + detail.Items.forEach(item => { + let taskQty = 0; + item.taskQty = calc.add(taskQty,item.qty) + let totalQty = 0; + item.Locations.forEach(lco => { + lco.Batchs.forEach(batch => { + batch.Records.forEach(record => { + if(record){ + let handleQty =record.qty?record.qty:0 + totalQty = calc.add(totalQty,handleQty) + } + }) + }) + }) + //实际扫描的数量 + item.handleQty =totalQty + }) + }) + } +} +const submit = ()=>{ + uni.showLoading({ + title: "提交中....", + mask: true + }); + let params = setParams() + console.log("提交参数", JSON.stringify(params)); + + if (params.subList.length == 0) { + uni.hideLoading() + comMessageRef.value.showConfirmMessageModal('请扫描箱码') + return + } + if(!checkCount()){ + uni.hideLoading() + return ; + } + submitJob() +} +const checkCount = ()=>{ + let str="" + let commitHint="" + + //如果允许部分提交任务有扫描记录就可以直接提交;如果不允许部分执行,任务数量和提交数量不一致给出提示 + detailSource.value.forEach(detail=>{ + detail.Items.forEach(item=>{ + if(jobContent.value.allowPartialComplete=="FALSE"){ + if(item.taskQty!=item.handleQty){ + str += `物料号【${item.itemCode}】实际提交数量【${item.handleQty}】与任务数量【${item.taskQty}】不一致\n` + } + }else { + //允许部分提交,提交的数量和任务数量不一致,提示 + if(item.taskQty!=item.handleQty){ + commitHint += `物料号【${item.itemCode}】实际提交数量【${item.handleQty}】与任务数量【${item.taskQty}】不一致,是否提交?\n` + } } - itemDetail.scaned = true - itemDetail.handleQty = Number(result.label.qty) - itemDetail.toInventoryStatus = itemDetail.inventoryStatus - itemDetail.balance = { - packQty: Number(result.package.packQty), - uom: result.package.uom + }) + }) + + if(str){ + str = '不允许提交\n' + str + showErrorMessage(str) + } + + if(commitHint){ + showQuestionMessage(commitHint,res=>{ + if(res){ + submitJob() } - calcHandleQty1() - } - scanPopupGetFocus() - } catch (e) { - showErrorMessage(e.message) + }) + } + if(str||commitHint){ + return false + }else { + return true } } + const commit = () => { scanCount.value = getScanCount(subList.value) if (scanCount.value == 0) { @@ -237,7 +331,7 @@ const commit = () => { // 提交 submitJob() } else { - comMessageRef.value.showErrorMessage('请完成扫描后,再进行提交
' + `已经扫描[${scanCount.value}]箱总共[${subList.value.length}]箱`, (res) => { + comMessageRef.value.showErrorMessage('请完成扫描后,再进行提交\n' + `已经扫描[${scanCount.value}]箱总共[${subList.value.length}]箱`, (res) => { if (res) { openScanPopup() } @@ -247,68 +341,83 @@ const commit = () => { } const submitJob = () => { proxy.$modal.loading('提交中...') - const params = setParams() - purchaseReturnJobsubmit(params) - .then((res) => { - uni.hideLoading() - if (res.data) { - showCommitSuccessMessage(res.data) - } else { - showErrorMessage(`提交失败[${res.msg}]`) - } - }) - .catch((error) => { - uni.hideLoading() - showErrorMessage(error) + let itemCodes = [] + detailSource.value.forEach(item => { + item.Items.forEach(cur=>{ + itemCodes.push(cur.itemCode) }) + }) + //获取管理模式,封装参数 + getManagementPrecisions(itemCodes, fromLocationCode.value, res => { + if (res.success) { + managementList.value = res.list; + const params = setParams() + purchaseReturnJobsubmit(params) + .then((res) => { + uni.hideLoading() + if (res.data) { + showCommitSuccessMessage(res.data) + } else { + showErrorMessage(`提交失败[${res.msg}]`) + } + }) + .catch((error) => { + uni.hideLoading() + showErrorMessage(error) + }) + } + }) } const setParams = () => { const subList = [] const creator = store.id - detailSource.value.forEach((item) => { - item.subList.forEach((detail) => { - if (detail.scaned) { - detail.toPackingNumber = detail.packingNumber - detail.toContainerNumber = detail.containerNumber - detail.toBatch = detail.batch + detailSource.value.forEach(toLocationCode => { + toLocationCode.Items.forEach(item => { + item.Locations.forEach(fromLocation => { + fromLocation.Batchs.forEach(batch => { + let subItem = batch.detail; + subItem.handleQty =batch.handleQty + subItem.recordList = []; + if (batch.Records.length > 0) { + batch.Records.forEach(r => { + let record = {}; + record.handleQty = r.qty; + record.toContainerNumber = r.ContainerNumber; + record.inventoryStatus = r.inventoryStatus; + record.toLocationCode = subItem.toLocationCode; + record.supplierCode = r.supplierCode; - detail.toLocationCode = detail.toLocationCode - subList.push(detail) - } + //使用在途库不改变管理模式 + let info = getPackingNumberAndBatch(managementList.value, detail.itemCode,record.packingNumber, detail.batch); + record.toPackingNumber = info.packingNumber; + record.packingNumber = info.packingNumber; + record.fromPackingNumber = info.packingNumber; + record.fromBatch = r.batch; + record.fromPackingNumber = r.packingNumber + subItem.recordList.push(record); + }) + subList.push(subItem); + } + }) + }) }) }) jobContent.value.subList = subList + jobContent.value.createTime = createTime; jobContent.value.creator = creator return jobContent.value } const openScanPopup = () => { - let fromlocationCode = '' - const fromlocationList = [] - for (let i = 0; i < detailSource.value.length; i++) { - const item = detailSource.value[i] - item.subList.forEach((l) => { - // 重复的库位不往里面插入 - const location = fromlocationList.find((res) => res == l.fromLocationCode) - if (location == undefined) { - fromlocationList.push(l.fromLocationCode) - } - // 来源库位赋默认值 - if (fromlocationCode == '') { - if (!l.scaned) { - fromlocationCode = l.fromLocationCode - } - } - }) - } - - scanPopup.value.openScanPopupForJob(fromlocationCode, fromlocationList, jobContent.value) + comScanIssuePack.value.openScanPopup(detailSource.value, jobContent.value); } const closeScanPopup = () => { scanPopup.value.closeScanPopup() } const scanPopupGetFocus = () => { - scanPopup.value.packGetFocus() + if(scanPopup.value){ + scanPopup.value.packGetFocus() + } } const scanPopupLoseFocus = () => { scanPopup.value.packLoseFocus() @@ -317,6 +426,7 @@ const openDetail = (item) => { jobDetailPopup.value.openPopup(item) } const showMessage = (message) => { + scanPopupLoseFocus() setTimeout((r) => { comMessageRef.value.showMessage(message, (res) => { if (res) { @@ -326,6 +436,7 @@ const showMessage = (message) => { }) } const showErrorMessage = (message) => { + scanPopupLoseFocus() setTimeout((r) => { comMessageRef.value.showErrorMessage(message, (res) => { if (res) { @@ -335,7 +446,7 @@ const showErrorMessage = (message) => { }) } const showQuestionMessage = (message, callback) => { - setTimeout((r) => { + setTimeout(() => { scanPopupLoseFocus() comMessageRef.value.showQuestionMessage(message, (res) => { if (res) { @@ -345,8 +456,8 @@ const showQuestionMessage = (message, callback) => { }) } const showCommitSuccessMessage = (number) => { - setTimeout((r) => { - comMessageRef.value.showSuccessMessage(`提交成功
生成退货记录:${number}`, (res) => { + setTimeout(() => { + comMessageRef.value.showSuccessMessage(`提交成功\n生成退货记录:${number}`, (res) => { if (res) { navigateBack(1) } diff --git a/src/pages/purchaseReturn/js/return.js b/src/pages/purchaseReturn/js/return.js new file mode 100644 index 00000000..97b8b8b5 --- /dev/null +++ b/src/pages/purchaseReturn/js/return.js @@ -0,0 +1,111 @@ + import { + calc + } from '@/common/calc.js'; +export function getDataSource(list, subList) { + for (var i = 0; i < subList.length; i++) { + let detail = subList[i]; + var location = list.find(r => + r.toLocationCode == detail.toLocationCode) + if (location == undefined) { + location = { + toLocationCode: detail.toLocationCode, + productionLineCode: detail.productionLineCode, + workStationCode: detail.workStationCode, + Items: [] + } + list.push(location); + } + createDetailInfo(location, detail); + } + return list; +} + +//树形结构:需求库位 -> 物料Items -> 库位 Locations-> 批次Batchs -> 记录Records +export function createDetailInfo(location, detail) { + var item = location.Items.find(r => + r.itemCode == detail.itemCode) + if (item == undefined) { + item = createItemInfo(detail); + location.Items.push(item) + } else { + item.qty = calc.add(item.qty,detail.qty) + //在物料下查找库位 + let location = item.Locations.find(r => r.fromLocationCode == detail.fromLocationCode); + if (location == undefined) { + location = createLocationInfo(detail); + item.Locations.push(location); + } else { + //在库位下查找批次 + let batch = location.Batchs.find(r => r.batch == detail.batch); + if (batch == undefined) { + let batch = createBatchInfo(detail); + location.Batchs.push(batch); + } else { + if (detail.packingNumber != "" && detail.packingNumber != null) { + batch.Recommends.push(detail); + } + } + } + } +} + +export function createItemInfo(detail) { + let item = { + itemCode: detail.itemCode, + itemName: detail.itemName, + onTheWayLocationCode:detail.onTheWayLocationCode, + productionLineCode: detail.productionLineCode, + workStationCode: detail.workStationCode, + packQty: detail.packQty, + packUnit: detail.packUnit, + qty: detail.qty, + uom: detail.uom, + handleQty: 0, + Locations: [] + } + let location = createLocationInfo(detail); + item.Locations.push(location); + return item; +} + +export function createLocationInfo(detail) { + let location = { + fromLocationCode: detail.fromLocationCode, + qty: detail.qty, + uom: detail.uom, + handleQty: 0, + Batchs: [] + } + let batch = createBatchInfo(detail); + location.Batchs.push(batch); + return location; +} + +export function createBatchInfo(detail) { + let batch = { + detail: detail, + batch: detail.batch, + packingNumber: detail.packingNumber, + qty: detail.qty, + uom: detail.uom, + handleQty: 0, + Recommends: [], + Records: [], + } + + //推荐到了箱码和批次 + if (detail.packingNumber != "" && detail.packingNumber != null) { + batch.Recommends.push(detail); + } + return batch; +} + +export function createRecordInfo(detail) { + var record = {} + detail.scaned = true; + // let record = JSON.parse(JSON.stringify(detail)); + //克隆对象,深度克隆,防止双向绑定同一个变量 + Object.assign(record, detail) + record.toLocationCode = this.toLocationCode; + return record; +} diff --git a/src/pages/purchaseReturn/record/returnRecord.vue b/src/pages/purchaseReturn/record/returnRecord.vue index 29e1fb46..2095f0b1 100644 --- a/src/pages/purchaseReturn/record/returnRecord.vue +++ b/src/pages/purchaseReturn/record/returnRecord.vue @@ -155,10 +155,11 @@ const getDataSource = (result) => { const newDetail = createDetailInfo(balance, pack) item.subList.push(newDetail) } else { - showErrorMessage(`箱码[${balance.packingNumber}]已经在列表中`) + showErrorMessage(`箱码[${balance.packingNumber}]重复扫描`) } } calcHandleQty(detailSource.value) + scanPopupGetFocus() } const updateData = () => { calcHandleQty(detailSource.value) @@ -195,7 +196,7 @@ const commit = () => { .then((res) => { uni.hideLoading() if (res.data) { - showCommitSuccessMessage(`提交成功
生成采购退货记录
${res.data}`) + showCommitSuccessMessage(`提交成功\n生成采购退货记录\n${res.data}`) } else { showErrorMessage(`提交失败[${res.msg}]`) } diff --git a/src/pages/purchaseReturn/request/returnRequestCreate.vue b/src/pages/purchaseReturn/request/returnRequestCreate.vue index 9eada036..76d1ff81 100644 --- a/src/pages/purchaseReturn/request/returnRequestCreate.vue +++ b/src/pages/purchaseReturn/request/returnRequestCreate.vue @@ -116,7 +116,7 @@ const getDataSource = (result) => { detailSource.value.push(itemInfo) } else { const detail = item.subList.find((r) => { - if (r.packingNumber == balance.packingNumber && r.batch == balance.batch && r.locationCode == balance.locationCode && r.inventoryStatus == balance.inventoryStatus && r.scaned == true) { + if (r.batch == balance.batch && r.locationCode == balance.locationCode && r.inventoryStatus == balance.inventoryStatus && r.scaned == true) { return r } }) @@ -125,7 +125,7 @@ const getDataSource = (result) => { const newDetail = createDetailInfo(balance, pack) item.subList.push(newDetail) } else { - showErrorMessage(`箱码[${balance.packingNumber}]已经在列表中`) + showErrorMessage(`批次[${balance.batch}]重复扫描`) } } calcHandleQty(detailSource.value) @@ -160,7 +160,7 @@ const commit = () => { .then((res) => { uni.hideLoading() if (res.data) { - showCommitSuccessMessage(`提交成功
生成采购退货申请
${res.data}`) + showCommitSuccessMessage(`提交成功\n生成采购退货申请\n${res.data}`) } else { showErrorMessage(`提交失败[${res.msg}]`) }