超市-添加口味字段

This commit is contained in:
weiwei committed 2025-06-18 19:06:21 +08:00
1 parent 86b3435821
commit 32472c89b0
2 files changed
+43 -8

No files matched your search

@@ -44,6 +44,11 @@
<span v-else style="color: #c0c4cf">请选择</span>
</template>
</vxe-column>
<vxe-column field="taste" title="口味">
<template #default="{ row }">
{{ computedSmErpUnitEntityList?.find((item: rowVU) => item.id === row.unitId)?.taste }}
</template>
</vxe-column>
<vxe-column field="barCode" title="辅助条码" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #edit="{ row }">
<el-input v-model.trim="row.barCode" />
@@ -63,6 +68,7 @@ export interface rowVC {
unitId: string
unit: string
barCode: string
taste: string
isNew?: boolean
}
@@ -72,6 +78,7 @@ const auxiliaryCodeList = defineModel("modelValue", {
id: nanoid(5),
unitId: "",
unit: "",
taste: "",
barCode: "",
},
],
@@ -102,6 +109,7 @@ const pushEvent = () => {
unitId: "",
unit: "",
barCode: "",
taste: "",
isNew: true,
}
auxiliaryCodeList.value.push(newRow)
@@ -128,7 +136,9 @@ const computedSmErpUnitEntityList = computed(() => props.smErpUnitEntityList?.fi
// 包装单位下拉选择变化
const handleUnitIdChange = (unitId: string, rowIndex: number) => {
;(auxiliaryCodeList.value[rowIndex] as any).unit = computedSmErpUnitEntityList.value?.find((item: rowVU) => item.id == unitId)?.unit
const unitItem = computedSmErpUnitEntityList.value?.find((item: rowVU) => item.id == unitId)
;(auxiliaryCodeList.value[rowIndex] as any).unit = unitItem?.unit
;(auxiliaryCodeList.value[rowIndex] as any).taste = unitItem?.taste
}
// 删除选中的行
@@ -56,14 +56,14 @@
</vxe-column>
<vxe-column field="unit" title="单位名称" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #edit="{ row }">
<el-input v-model.trim="row.unit" />
<el-input v-model.trim="row.unit" @input="(value: string | number) => handleUnitInput(row, value)" />
</template>
</vxe-column>
<vxe-column field="taste" title="口味" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #edit="{ row }">
<el-input v-model.trim="row.taste" @input="(value: string | number) => handleTasteInput(row, value)" />
</template>
</vxe-column>
<vxe-column field="taste" title="口味" :edit-render="{ autoFocus: 'input', placeholder: '请输入口味' }">
<template #edit="{ row }">
<el-input v-model.trim="row.taste" />
</template>
</vxe-column>
<vxe-column field="status" title="状态" :edit-render="{}">
<template #edit="{ row }">
<el-select v-model="row.status">
@@ -108,6 +108,7 @@
<script setup lang="ts">
import { nanoid } from "nanoid"
import { useMessage } from "/@/hooks/message"
export interface rowVU {
id: string
@@ -123,7 +124,7 @@ export interface rowVU {
isNew?: boolean
isBase?: boolean | null
flag?: string
taste?: string
taste?: string
}
const packageUnitList = defineModel<rowVU[]>("modelValue", {
@@ -139,6 +140,7 @@ const packageUnitList = defineModel<rowVU[]>("modelValue", {
retailPrice: 0.01,
promotionPrice: 0,
costPrice: 0,
taste: "",
},
],
})
@@ -172,6 +174,7 @@ const pushEvent = (row?: rowVU | undefined) => {
retailPrice: 0.01,
promotionPrice: 0,
costPrice: 0,
taste: "",
isNew: true,
}
Object.assign(newRow, row)
@@ -229,6 +232,28 @@ const editableTableValidate = async () => {
}
}
// 口味字段值改变
const handleTasteInput = (row: rowVU, value: string | number) => {
if (
packageUnitList.value.filter((item: rowVU) => item.id != row.id && item.unit == row.unit).some((item: rowVU) => item.taste == value)
) {
useMessage().warning("该包装单位的口味已存在")
return false
}
return true
}
// 单位字段值改变
const handleUnitInput = (row: rowVU, value: string | number) => {
if (
packageUnitList.value.filter((item: rowVU) => item.id != row.id && item.unit == row.unit).some((item: rowVU) => item.taste == row.taste)
) {
useMessage().warning("该包装单位的口味已存在")
return false
}
return true
}
defineExpose({
editableTableValidate,
getRadioRow,