fix:修复商品未添加口味时id读取错误
This commit is contained in:
1 parent
6517d33d1c
commit
867cabdee8
2 files changed
+21
-37
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user