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" > - + + +