diff --git a/src/views/canteenDailyDishes/index.vue b/src/views/canteenDailyDishes/index.vue index e623eca..2dc76aa 100644 --- a/src/views/canteenDailyDishes/index.vue +++ b/src/views/canteenDailyDishes/index.vue @@ -1,193 +1,81 @@ diff --git a/src/views/supermarketerp/smErpTasteStock/form.vue b/src/views/supermarketerp/smErpTasteStock/form.vue deleted file mode 100644 index 1e39acf..0000000 --- a/src/views/supermarketerp/smErpTasteStock/form.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - diff --git a/src/views/supermarketerp/smErpTasteStock/index.vue b/src/views/supermarketerp/smErpTasteStock/index.vue deleted file mode 100644 index a09fd06..0000000 --- a/src/views/supermarketerp/smErpTasteStock/index.vue +++ /dev/null @@ -1,115 +0,0 @@ - - - diff --git a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue index 8b915da..098fd61 100644 --- a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue +++ b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue @@ -150,7 +150,6 @@ export interface rowVU { promotionPrice: number costPrice: number isBase?: boolean | null - flag?: string tasteName?: string tasteId: string } @@ -208,7 +207,9 @@ const slotInputChange = (slotParams: any) => { $table.updateStatus(slotParams) } } -const pushEvent = (flag?: "flag" | undefined) => { + +// 底部新增行 +const pushEvent = () => { const newRow: rowVU = { id: "tmp_" + nanoid(5), barCode: "", @@ -224,69 +225,67 @@ const pushEvent = (flag?: "flag" | undefined) => { tasteId: "", } - if (flag) newRow.flag = "defaultPackageUnitRow" - - packageUnitList.value.push(newRow) - nextTick(() => { - const $table = tableRef.value - if ($table) { - $table.setEditRow(newRow) - } - }) - } + packageUnitList.value.push(newRow) + nextTick(() => { + const $table = tableRef.value + if ($table) { + $table.setEditRow(newRow) + } + }) +} // 删除行 - const removeRow = (rowIndex: number) => { - packageUnitList.value.splice(rowIndex, 1) - } +const removeRow = (rowIndex: number) => { + packageUnitList.value.splice(rowIndex, 1) +} // 设置单选的行 - const setRadioRow = (index: number) => { - const $table = tableRef.value - if ($table) { - $table.setRadioRow(packageUnitList.value[index]) - } - } +const setRadioRow = (index: number) => { + const $table = tableRef.value + if ($table) { + $table.setRadioRow(packageUnitList.value[index]) + } +} // 获取单选的行 - const getRadioRow = () => { - const $table = tableRef.value - if ($table) { - const currRadioRow = $table.getRadioRecord() - return currRadioRow - } - } +const getRadioRow = () => { + const $table = tableRef.value + if ($table) { + const currRadioRow = $table.getRadioRecord() + return currRadioRow + } +} // 校验表格 成功返回 true 失败返回 false - const tableValidate = async (filed?: string) => { - const $table = tableRef.value - if ($table) { - if (filed) { - const errMap = await $table.validateField(packageUnitList.value, filed) - if (errMap) { - console.log("字段校验失败!", errMap) - return false - } else { - console.log("字段校验成功!") - return true - } - } else { - const errMap = await $table.validate(true) - if (errMap) { - console.log("全量校验失败!", errMap) - return false - } else { - console.log("全量校验成功!") - return true - } - } - } - } +const tableValidate = async (filed?: string) => { + const $table = tableRef.value + if ($table) { + if (filed) { + const errMap = await $table.validateField(packageUnitList.value, filed) + if (errMap) { + console.log("字段校验失败!", errMap) + return false + } else { + console.log("字段校验成功!") + return true + } + } else { + const errMap = await $table.validate(true) + if (errMap) { + console.log("全量校验失败!", errMap) + return false + } else { + console.log("全量校验成功!") + return true + } + } + } +} - defineExpose({ - tableValidate, - setRadioRow, - getRadioRow, - pushEvent, - }) +defineExpose({ + tableValidate, + setRadioRow, + getRadioRow, + pushEvent, +}) diff --git a/src/views/supermarketerp/supermarketSpu/form.vue b/src/views/supermarketerp/supermarketSpu/form.vue index bc84556..87354fb 100644 --- a/src/views/supermarketerp/supermarketSpu/form.vue +++ b/src/views/supermarketerp/supermarketSpu/form.vue @@ -40,7 +40,6 @@ import { fetchList } from "/@/api/supermarketerp/smErpTasteStock" import { TabPaneName } from "element-plus" import { useMessage } from "/@/hooks/message" import { displayPrice, storePrice } from "/@/utils/formatMoney" -import { nanoid } from "nanoid" const emit = defineEmits(["refresh"]) @@ -144,11 +143,8 @@ const nextStep = () => { // 默认设置一行基础包装单位 const setDefaultPackageUnit = () => { - if (!form.id && tabPaneActiveIndex.value == 1) { - const isFlagRowExist = form.smErpUnitEntityList.some((item: rowVU) => item.flag === "defaultPackageUnitRow") - if (isFlagRowExist) return - - packageUnitRef.value.pushEvent("flag") + if (!form.id && tabPaneActiveIndex.value == 1 && form.smErpUnitEntityList.length === 0) { + packageUnitRef.value.pushEvent() packageUnitRef.value.setRadioRow(0) // 自动设置基础包装单位的radio单选行 } } @@ -237,7 +233,7 @@ const settlePackageUnitList = () => { } if (item.id.startsWith("tmp_")) item.id = "" 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 = "" } // 转换金额单位