This commit is contained in:
weiwei committed 2025-08-21 18:39:34 +08:00
1 parent 7b9ab4ecd0
commit a68829e953
2 files changed
+56 -95

No files matched your search

@@ -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,
})
</script>
@@ -32,7 +32,7 @@
<script setup lang="ts">
import BaseInfo from "./components/base-info.vue"
import PackageUnit, { type rowVU } from "./components/package-unit.vue"
import { type rowVU } from "./components/package-unit.vue"
import ProductInventory from "./components/product-inventory.vue"
import AuxiliaryCode, { type rowVC } from "./components/auxiliary-code.vue"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/supermarketSpu"
@@ -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"])