From 372e2215f01be07c9850e3cdd498d74439df4822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=85=86=E7=90=A6?= <1361001127@qq.com> Date: Mon, 12 Aug 2024 16:14:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=97=B6=E5=85=81=E8=AE=B8=E9=80=89=E6=8B=A9=E5=B7=B2?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E5=B1=9E=E6=80=A7=E5=80=BC=20Fixes=20#47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/product/spu/components/SkuList.vue | 6 +-- .../mall/product/spu/components/index.ts | 1 + .../product/spu/form/ProductAttributes.vue | 27 ++++++++++-- .../spu/form/ProductPropertyAddForm.vue | 41 ++++++++++++++++++- src/views/mall/product/spu/form/SkuForm.vue | 29 +++++++++++-- 5 files changed, 93 insertions(+), 11 deletions(-) diff --git a/src/views/mall/product/spu/components/SkuList.vue b/src/views/mall/product/spu/components/SkuList.vue index 9bbd38e4..2b881a46 100644 --- a/src/views/mall/product/spu/components/SkuList.vue +++ b/src/views/mall/product/spu/components/SkuList.vue @@ -24,7 +24,7 @@ > @@ -168,7 +168,7 @@ > @@ -248,7 +248,7 @@ > diff --git a/src/views/mall/product/spu/components/index.ts b/src/views/mall/product/spu/components/index.ts index e2cbe73d..5569bc99 100644 --- a/src/views/mall/product/spu/components/index.ts +++ b/src/views/mall/product/spu/components/index.ts @@ -5,6 +5,7 @@ interface PropertyAndValues { id: number name: string values?: PropertyAndValues[] + propertyOpts?: PropertyAndValues[] } interface RuleConfig { diff --git a/src/views/mall/product/spu/form/ProductAttributes.vue b/src/views/mall/product/spu/form/ProductAttributes.vue index ffe7397d..88515829 100644 --- a/src/views/mall/product/spu/form/ProductAttributes.vue +++ b/src/views/mall/product/spu/form/ProductAttributes.vue @@ -18,16 +18,28 @@ > {{ value.name }} - + > + + + { const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 const handleInputConfirm = async (index: number, propertyId: number) => { if (inputValue.value) { + // 重复添加校验 + if (attributeList.value[index].values.find((item) => item.name === inputValue.value)) { + message.warning('已存在相同属性值,请重试') + attributeIndex.value = null + inputValue.value = '' + return + } // 保存属性值 try { const id = await PropertyApi.createPropertyValue({ propertyId, name: inputValue.value }) diff --git a/src/views/mall/product/spu/form/ProductPropertyAddForm.vue b/src/views/mall/product/spu/form/ProductPropertyAddForm.vue index 15c5a8d5..6fc9f912 100644 --- a/src/views/mall/product/spu/form/ProductPropertyAddForm.vue +++ b/src/views/mall/product/spu/form/ProductPropertyAddForm.vue @@ -10,7 +10,22 @@ @keydown.enter.prevent="submitForm" > - + + +