叶静 1 долоо хоног өмнө
parent
commit
e7b95e0f54

+ 8 - 0
src/app/shop/admin/goods/goods/edit.vue

@@ -1064,6 +1064,14 @@ const submitGoods = async () => {
         ElMessage.error(t('modules.goods.specificationValueRequired', { name: sku.name }));
         return;
       }
+
+      // 检查同一规格下的规格值是否重复
+      const specValueNames = validChildren.map(child => child.name.trim().toLowerCase());
+      const uniqueNames = [...new Set(specValueNames)];
+      if (specValueNames.length !== uniqueNames.length) {
+        ElMessage.error(t('modules.goods.specificationValueDuplicate', { name: sku.name }));
+        return;
+      }
     }
 
     // 验证商品属性(如果有SKU)

+ 1 - 0
src/locales/en-US/index.json

@@ -1143,6 +1143,7 @@
       "pleaseAddSpecification": "Please add goods specification first",
       "pleaseCompleteSpecification": "Please complete goods specification information",
       "specificationValueRequired": "Specification \"{name}\" must have at least one specification value",
+      "specificationValueDuplicate": "Duplicate specification values found in \"{name}\", please check",
       "specificationSalePriceError": "The sale price of specification {index} cannot be empty and must be greater than 0",
       "specificationMarketPriceError": "The market price of specification {index} cannot be empty and must be greater than 0",
       "specificationStockError": "The stock of specification {index} cannot be empty and cannot be less than 0",

+ 1 - 0
src/locales/zh-CN/index.json

@@ -1145,6 +1145,7 @@
       "pleaseAddSpecification": "请先添加商品规格",
       "pleaseCompleteSpecification": "请完善商品规格信息",
       "specificationValueRequired": "规格\"{name}\"必须添加至少一个规格值",
+      "specificationValueDuplicate": "规格\"{name}\"下存在重复的规格值,请检查",
       "specificationSalePriceError": "第{index}个规格的销售价格不能为空且必须大于0",
       "specificationMarketPriceError": "第{index}个规格的市场价不能为空且必须大于0",
       "specificationStockError": "第{index}个规格的商品库存不能为空且不能小于0",