From 2837db2d6b8fea90b5d5cdcb685bcf2123c1730f Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Fri, 29 Aug 2025 17:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E5=95=86=E5=9F=8E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=95=86=E5=93=81=E6=80=A7=E8=B4=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/supermarket/shopSpu/form.vue | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/views/supermarket/shopSpu/form.vue b/src/views/supermarket/shopSpu/form.vue index a2ea1ad..587f848 100644 --- a/src/views/supermarket/shopSpu/form.vue +++ b/src/views/supermarket/shopSpu/form.vue @@ -28,6 +28,13 @@ /> + + + + + + + @@ -195,13 +202,13 @@ const dataFormRef = ref(); const visible = ref(false) const loading = ref(false) // 定义字典 -const {spu_status} = useDict('spu_status') - +const { supermarket_nature,spu_status} = useDict("supermarket_nature",'spu_status') // 提交表单数据 const form = reactive({ id: '', productCode: '', productName: '', + productNature: "", description: '', categoryId: '', picUrl: '', @@ -220,6 +227,7 @@ const form = reactive({ // 定义校验规则 const dataRules = ref({ + productNature: [{ required: true, message: "请选择商品性质", trigger: "blur" }], productCode: [{ required: true, message: '货号不能为空', trigger: 'blur' }], productName: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }], categoryId: [{ required: true, message: '商品分类不能为空', trigger: 'change' }], @@ -298,10 +306,10 @@ const onSubmit = async () => { loading.value = true; // merchantIds 逗号分隔字符串 const merchantIds = selectedMerchants.value.map(m => m.id).join(','); - const submitForm = { - ...form, + const submitForm = { + ...form, categoryId: Array.isArray(form.categoryId) ? form.categoryId.slice(-1)[0] : form.categoryId, - merchantIds + merchantIds }; form.id ? await putObj(submitForm) : await addObj(submitForm); useMessage().success(form.id ? '修改成功' : '添加成功');