From 0e9fde1f8a18e9cf1e4afca76894c622bb1a78f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=85=86=E7=90=A6?= <1361001127@qq.com> Date: Wed, 14 Aug 2024 08:57:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=80=BC=E6=97=B6=E5=A2=9E=E5=8A=A0=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=98=AF=E5=B7=B2=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E5=B1=9E=E6=80=A7=E5=8F=91=E5=87=BA=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E4=B8=94=E4=B8=8D=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spu/form/ProductPropertyAddForm.vue | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/views/mall/product/spu/form/ProductPropertyAddForm.vue b/src/views/mall/product/spu/form/ProductPropertyAddForm.vue index 47915c7c..66fecfca 100644 --- a/src/views/mall/product/spu/form/ProductPropertyAddForm.vue +++ b/src/views/mall/product/spu/form/ProductPropertyAddForm.vue @@ -85,19 +85,9 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗 /** 提交表单 */ const submitForm = async () => { // 情况一:如果是已存在的属性,直接结束,不提交表单新增 - for (const option of attributeOptions.value) { - if (option.name === formData.value.name) { - // 添加到属性列表 - attributeList.value.push({ - id: option.id, - ...formData.value, - values: [] - }) - // 触发属性列表的加载 - emit('success', option.id, option.id) - // 关闭弹窗 - dialogVisible.value = false - return + for (const attrItem of attributeList.value) { + if (attrItem.name === formData.value.name) { + return message.error('该属性已存在,请勿重复添加') } } @@ -117,6 +107,15 @@ const submitForm = async () => { ...formData.value, values: [] }) + // 判断最终提交的属性名称是否是用户下拉选择的 自己手动输入的属性名称就不执行emit获取该属性名下属性值列表 + for (const element of attributeOptions.value) { + if (element.name === formData.value.name) { + emit('success', propertyId, element.id) + message.success(t('common.createSuccess')) + dialogVisible.value = false + return + } + } // 关闭弹窗 message.success(t('common.createSuccess')) dialogVisible.value = false