From a68829e953071ad7cd2339bb58efc35ba0650e30 Mon Sep 17 00:00:00 2001 From: weiwei Date: Thu, 21 Aug 2025 18:39:34 +0800 Subject: [PATCH] --- .../components/package-unit.vue | 148 +++++++----------- .../supermarketerp/supermarketSpu/form.vue | 3 +- 2 files changed, 56 insertions(+), 95 deletions(-) diff --git a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue index a021459..9fbca26 100644 --- a/src/views/supermarketerp/supermarketSpu/components/package-unit.vue +++ b/src/views/supermarketerp/supermarketSpu/components/package-unit.vue @@ -210,43 +210,6 @@ const slotInputChange = (slotParams: any) => { } // 底部新增行 -<<<<<<< HEAD -const pushEvent = (row?: rowVU | undefined) => { - const newRow = {} as rowVU - if (row) { - Object.assign(newRow, row) - } else { -1 row = { - id: "tmp_" + nanoid(5), - barCode: "", - spec: "", - unit: "", - status: "0", - packageNum: 1, - purchasePrice: 0, - retailPrice: 0.01, - promotionPrice: 0, - costPrice: 0, - tasteName: "", - tasteId: "", - } - Object.assign(newRow, row)1 - 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: "", - } -======= const pushEvent = (flag?: "flag" | undefined) => { const newRow: rowVU = { id: "tmp_" + nanoid(5), @@ -262,71 +225,70 @@ const pushEvent = (flag?: "flag" | undefined) => { tasteName: "", tasteId: "", } ->>>>>>> 09ed9cd1a67bafec7fdb6796de0dcfbb0b357dec - if (flag) newRow.flag = "defaultPackageUnitRow" + 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..6d826e3 100644 --- a/src/views/supermarketerp/supermarketSpu/form.vue +++ b/src/views/supermarketerp/supermarketSpu/form.vue @@ -32,7 +32,7 @@