From 02d3bff8f0473151494ce4cb1356b70de7f3b0d6 Mon Sep 17 00:00:00 2001 From: bb_pan Date: Thu, 29 Jan 2026 13:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../picking/apply/component/AddPicking.vue | 69 +++++++------------ 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/sgzb-ui/src/views/claimAndreturn/picking/apply/component/AddPicking.vue b/sgzb-ui/src/views/claimAndreturn/picking/apply/component/AddPicking.vue index 6401b078..efc6d8e4 100644 --- a/sgzb-ui/src/views/claimAndreturn/picking/apply/component/AddPicking.vue +++ b/sgzb-ui/src/views/claimAndreturn/picking/apply/component/AddPicking.vue @@ -961,17 +961,29 @@ export default { // 成套设备下拉框选择 async completeSetChange(val) { + if (!val) return + const { data: res } = await queryCompleteSetDetailsApi({ wholeTypeName: val, companyId: parseInt(this.queryParams.companyId), }) - // 1 如果模板列表为空 直接赋值 - if (this.leaseApplyDetails.length == 0) { - res.map((e) => { - const template = JSON.parse( - JSON.stringify(this.leaseApplyDetailsItem), - ) + const map = new Map() + + // 1️⃣ 已有数据 + this.leaseApplyDetails.forEach((item) => { + map.set(item.typeId, { ...item }) + }) + + // 2️⃣ 新数据:只累加 preNum + res.forEach((e) => { + if (map.has(e.typeId)) { + const oldItem = map.get(e.typeId) + oldItem.preNum = + Number(oldItem.preNum || 0) + Number(e.partNum || 0) + } else { + const template = { ...this.leaseApplyDetailsItem } + template.createBy = this.user.name template.num = e.num template.companyId = this.queryParams.companyId @@ -981,45 +993,16 @@ export default { template.guigeCn = e.typeModelName template.preNum = e.partNum - this.leaseApplyDetails.push(template) - }) + map.set(e.typeId, template) + } + }) - return - } + this.leaseApplyDetails = Array.from(map.values()) - // 2 如果模板不为空 则去重处理 - if (this.leaseApplyDetails.length > 0) { - let newTemplateList = [] - - res.map((e) => { - const template = JSON.parse( - JSON.stringify(this.leaseApplyDetailsItem), - ) - template.createBy = this.user.name - template.num = e.num - template.companyId = this.queryParams.companyId - template.typeId = e.typeId - template.unitCn = e.unitName - template.typeCn = e.typeName - template.guigeCn = e.typeModelName - template.preNum = e.partNum - - newTemplateList.push(template) - }) - - newTemplateList = [ - ...newTemplateList, - ...this.leaseApplyDetails, - ] - const map = new Map() - newTemplateList.map((e) => { - if (!map.has(e.typeId)) { - map.set(e.typeId, e) - } - }) - - this.leaseApplyDetails = [...map.values()] - } + // 清空选中值 + this.$nextTick(() => { + this.queryParams.completeSet = null + }) }, }, }