添加商品时默认添加一条包装单位
This commit is contained in:
1 parent
1286e8757e
commit
29b50cda9e
2 files changed
+48
-11
No files matched your search
@@ -86,6 +86,7 @@
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.flag !== 'default'"
|
||||
icon="edit-pen"
|
||||
text
|
||||
type="primary"
|
||||
@@ -95,6 +96,7 @@
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.flag !== 'default'"
|
||||
icon="delete"
|
||||
text
|
||||
type="primary"
|
||||
@@ -118,6 +120,9 @@
|
||||
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
|
||||
|
||||
const supermarketUnitEntityList = defineModel<any>("supermarketUnitEntityList", { default: [] })
|
||||
const props = defineProps<{
|
||||
defaultSpuUnit: any
|
||||
}>()
|
||||
|
||||
const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
@@ -144,6 +149,25 @@ const tableStyle = {
|
||||
},
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.defaultSpuUnit,
|
||||
(newValue, oldValue) => {
|
||||
const defaultSpuUnitIndex = supermarketUnitEntityList.value.findIndex((item: any) => {
|
||||
return (item.flag = "default")
|
||||
})
|
||||
if (defaultSpuUnitIndex !== -1) {
|
||||
console.log(supermarketUnitEntityList.value[defaultSpuUnitIndex])
|
||||
supermarketUnitEntityList.value[defaultSpuUnitIndex] = newValue
|
||||
} else {
|
||||
supermarketUnitEntityList.value.push(newValue)
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true,
|
||||
},
|
||||
)
|
||||
|
||||
const getDataList = (formData: any) => {
|
||||
console.log(formData)
|
||||
const index = supermarketUnitEntityList.value?.findIndex((item: any) => item.id === formData.id)
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="自编码/条码" prop="barcode">
|
||||
<el-input v-model.trim="form.barcode" placeholder="请输入自编码/条码" />
|
||||
<el-form-item label="自编码/条码" prop="barCode">
|
||||
<el-input v-model.trim="form.barCode" placeholder="请输入自编码/条码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
@@ -90,17 +90,16 @@
|
||||
<el-input-number v-model="form.retailPrice" :min="0" :precision="2" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="促销价" prop="promotionPrice">
|
||||
<el-input-number v-model="form.promotionPrice" :min="0" :precision="2" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="进价" prop="purchasePrice">
|
||||
<el-input-number v-model="form.purchasePrice" :min="0" :precision="2" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="促销价" prop="promotionPrice">
|
||||
<el-input-number v-model="form.promotionPrice" :min="0" :precision="2" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="成本价" prop="costPrice">
|
||||
<el-input-number v-model="form.costPrice" :min="0" :precision="2" />
|
||||
@@ -158,7 +157,10 @@
|
||||
</el-row>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="包装单位" name="包装单位" style="overflow-y: auto; height: 60vh">
|
||||
<supermarketUnit v-model:supermarketUnitEntityList="form.smErpUnitEntityList" />
|
||||
<supermarketUnit
|
||||
v-model:supermarketUnitEntityList="form.smErpUnitEntityList"
|
||||
:defaultSpuUnit="defaultSpuUnit"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="辅助条码" name="辅助条码" style="overflow-y: auto; height: 60vh">
|
||||
<supermarketAuxiliaryCode v-model:supermarketAuxiliaryCodeEntityList="form.smErpAuxiliaryCodeEntityList" />
|
||||
@@ -209,7 +211,7 @@ const form = reactive({
|
||||
id: "",
|
||||
merchantId: "",
|
||||
productCode: "",
|
||||
barcode: "",
|
||||
barCode: "",
|
||||
productName: "",
|
||||
unit: "",
|
||||
categoryId: "",
|
||||
@@ -248,7 +250,7 @@ const dataRules = {
|
||||
productNature: [{ required: true, message: "请选择商品性质", trigger: "blur" }],
|
||||
merchantId: [{ required: true, message: "商户不能为空", trigger: "blur" }],
|
||||
productCode: [{ required: true, message: "货号不能为空", trigger: "blur" }],
|
||||
barcode: [{ required: true, message: "自编码/条码不能为空", trigger: "blur" }],
|
||||
barCode: [{ required: true, message: "自编码/条码不能为空", trigger: "blur" }],
|
||||
productName: [{ required: true, message: "商品名称不能为空", trigger: "blur" }],
|
||||
unit: [{ required: true, message: "单位不能为空", trigger: "blur" }],
|
||||
stock: [{ required: true, message: "总库存不能为空", trigger: "blur" }],
|
||||
@@ -267,6 +269,17 @@ const { supermarket_nature, status } = useDict("supermarket_nature", "status")
|
||||
const categoryOptions = ref<any>([]) // 商品分类的下拉选项
|
||||
const brandOptions = ref<any>([]) // 超市品牌的下拉选项
|
||||
const supplierOptions = ref<any>([]) // 货商的下拉选项
|
||||
// 默认包装单位
|
||||
const defaultSpuUnit = computed(() => ({
|
||||
flag: "default",
|
||||
barCode: form.barCode,
|
||||
unit: form.unit,
|
||||
packageNum: form.packageNum,
|
||||
retailPrice: form.retailPrice,
|
||||
purchasePrice: form.purchasePrice,
|
||||
promotionPrice: form.promotionPrice,
|
||||
status: "0",
|
||||
}))
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = async (id: string) => {
|
||||
|
||||
Reference in new issue
Block a user