fix:修复商品未添加口味时id读取错误

This commit is contained in:
weiwei committed 2025-08-21 17:29:06 +08:00
1 parent 6517d33d1c
commit 867cabdee8
2 files changed
+21 -37

No files matched your search

@@ -143,7 +143,6 @@ export interface rowVU {
costPrice: number costPrice: number
isBase?: boolean | null isBase?: boolean | null
flag?: string flag?: string
taste?: string
tasteId: string tasteId: string
tasteName?: string tasteName?: string
} }
@@ -203,27 +202,24 @@ const slotInputChange = (slotParams: any) => {
} }
// 底部新增行 // 底部新增行
const pushEvent = (row?: rowVU | undefined) => { const pushEvent = (flag?: "flag" | undefined) => {
const newRow = {} as rowVU const newRow: rowVU = {
if (row) { id: "tmp_" + nanoid(5),
Object.assign(newRow, row) barCode: "",
} else { spec: "",
row = { unit: "",
id: "tmp_" + nanoid(5), status: "0",
barCode: "", packageNum: 1,
spec: "", purchasePrice: 0,
unit: "", retailPrice: 0.01,
status: "0", promotionPrice: 0,
packageNum: 1, costPrice: 0,
purchasePrice: 0, tasteName: "",
retailPrice: 0.01, tasteId: "",
promotionPrice: 0,
costPrice: 0,
taste: "",
tasteId: "",
}
Object.assign(newRow, row)
} }
if (flag) newRow.flag = "defaultPackageUnitRow"
packageUnitList.value.push(newRow) packageUnitList.value.push(newRow)
nextTick(() => { nextTick(() => {
const $table = tableRef.value const $table = tableRef.value
@@ -147,20 +147,8 @@ const setDefaultPackageUnit = () => {
if (!form.id && tabPaneActiveIndex.value == 1) { if (!form.id && tabPaneActiveIndex.value == 1) {
const isFlagRowExist = form.smErpUnitEntityList.some((item: rowVU) => item.flag === "defaultPackageUnitRow") const isFlagRowExist = form.smErpUnitEntityList.some((item: rowVU) => item.flag === "defaultPackageUnitRow")
if (isFlagRowExist) return if (isFlagRowExist) return
const row = {
id: "tmp_" + nanoid(5), packageUnitRef.value.pushEvent("flag")
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.setRadioRow(0) // 自动设置基础包装单位的radio单选行 packageUnitRef.value.setRadioRow(0) // 自动设置基础包装单位的radio单选行
} }
} }
@@ -248,7 +236,7 @@ const settlePackageUnitList = () => {
item.isBase = false item.isBase = false
} }
if (item.id.startsWith("tmp_")) item.id = "" 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.tasteName = form.smErpTasteStockEntityList.find((tasteItem: any) => tasteItem.id === item.tasteId).tasteName
item.tasteId = "" item.tasteId = ""
} }
@@ -277,7 +265,7 @@ const settleAuxiliaryCode = () => {
const settleSmErpTasteStockEntityList = () => { const settleSmErpTasteStockEntityList = () => {
const smErpTasteStockEntityList = [...form.smErpTasteStockEntityList] const smErpTasteStockEntityList = [...form.smErpTasteStockEntityList]
return smErpTasteStockEntityList.map((item: rowVC) => { return smErpTasteStockEntityList.map((item: rowVC) => {
if (item.id.startsWith("tmp_")) item.id = "" if (item.id && item.id.startsWith("tmp_")) item.id = ""
return item return item
}) })
} }