diff --git a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue index c6c2732..9fd10aa 100644 --- a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue +++ b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue @@ -232,7 +232,24 @@ const pushEvent = (row?: rowVU | undefined) => { 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 }) }