From 867cabdee891e996b3d4d6e73f020845bcb88171 Mon Sep 17 00:00:00 2001 From: weiwei Date: Thu, 21 Aug 2025 17:29:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=9C=AA=E6=B7=BB=E5=8A=A0=E5=8F=A3=E5=91=B3=E6=97=B6id?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/package-unit.vue | 38 +++++++++---------- .../supermarketerp/supermarketSpu/form.vue | 20 ++-------- 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue index fffa8eb..9e985c3 100644 --- a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue +++ b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue @@ -143,7 +143,6 @@ export interface rowVU { costPrice: number isBase?: boolean | null flag?: string - taste?: string tasteId: string tasteName?: string } @@ -203,27 +202,24 @@ const slotInputChange = (slotParams: any) => { } // 底部新增行 -const pushEvent = (row?: rowVU | undefined) => { - const newRow = {} as rowVU - if (row) { - Object.assign(newRow, row) - } else { - row = { - id: "tmp_" + nanoid(5), - barCode: "", - spec: "", - unit: "", - status: "0", - packageNum: 1, - purchasePrice: 0, - retailPrice: 0.01, - promotionPrice: 0, - costPrice: 0, - taste: "", - tasteId: "", - } - Object.assign(newRow, row) +const pushEvent = (flag?: "flag" | undefined) => { + const newRow: rowVU = { + id: "tmp_" + nanoid(5), + barCode: "", + spec: "", + unit: "", + status: "0", + packageNum: 1, + purchasePrice: 0, + retailPrice: 0.01, + promotionPrice: 0, + costPrice: 0, + tasteName: "", + tasteId: "", } + + if (flag) newRow.flag = "defaultPackageUnitRow" + packageUnitList.value.push(newRow) nextTick(() => { const $table = tableRef.value diff --git a/src/views/supermarketerp/supermarketSpu/form.vue b/src/views/supermarketerp/supermarketSpu/form.vue index a2893be..bc84556 100644 --- a/src/views/supermarketerp/supermarketSpu/form.vue +++ b/src/views/supermarketerp/supermarketSpu/form.vue @@ -147,20 +147,8 @@ const setDefaultPackageUnit = () => { if (!form.id && tabPaneActiveIndex.value == 1) { const isFlagRowExist = form.smErpUnitEntityList.some((item: rowVU) => item.flag === "defaultPackageUnitRow") if (isFlagRowExist) return - const row = { - id: "tmp_" + nanoid(5), - barCode: form.barCode, - spec: form.spec, - unit: form.unit, - status: form.unitStatus, - packageNum: form.packageNum, - purchasePrice: form.purchasePrice, - retailPrice: form.retailPrice, - promotionPrice: form.promotionPrice, - costPrice: form.costPrice, - flag: "defaultPackageUnitRow", - } - packageUnitRef.value.pushEvent(row) + + packageUnitRef.value.pushEvent("flag") packageUnitRef.value.setRadioRow(0) // 自动设置基础包装单位的radio单选行 } } @@ -248,7 +236,7 @@ const settlePackageUnitList = () => { item.isBase = false } if (item.id.startsWith("tmp_")) item.id = "" - if (item.tasteId.startsWith("tmp_")) { + if (item.tasteId?.startsWith("tmp_")) { item.tasteName = form.smErpTasteStockEntityList.find((tasteItem: any) => tasteItem.id === item.tasteId).tasteName item.tasteId = "" } @@ -277,7 +265,7 @@ const settleAuxiliaryCode = () => { const settleSmErpTasteStockEntityList = () => { const smErpTasteStockEntityList = [...form.smErpTasteStockEntityList] return smErpTasteStockEntityList.map((item: rowVC) => { - if (item.id.startsWith("tmp_")) item.id = "" + if (item.id && item.id.startsWith("tmp_")) item.id = "" return item }) }