|
@@ -42,7 +42,7 @@
|
|
|
|
|
|
<el-form-item :label="t('modules.goods.goodsDescription')" prop="storeInfo">
|
|
|
<el-input v-model="formData.storeInfo" type="textarea" :rows="4"
|
|
|
- :placeholder="t('form.inputGoodsDescription')" maxlength="500" show-word-limit />
|
|
|
+ :placeholder="t('form.inputGoodsDescription')" maxlength="256" show-word-limit />
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="t('modules.goods.shippingTemplate')" prop="tempId">
|
|
@@ -104,7 +104,8 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="t('modules.goods.goodsSupplier')" prop="itemSupplier" required>
|
|
|
- <el-input v-model="formData.itemSupplier" :placeholder="t('form.inputGoodsSupplier')" />
|
|
|
+ <el-input v-model="formData.itemSupplier" :placeholder="t('form.inputGoodsSupplier')" maxlength="20"
|
|
|
+ show-word-limit />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
@@ -135,7 +136,7 @@
|
|
|
<div v-show="currentStep === 1" class="" :key="forceUpdateKey">
|
|
|
<el-form ref="attrFormRef" :model="formData" :rules="attrRules" :label-width="formLabelWidth">
|
|
|
<!-- 多规格设置 -->
|
|
|
- <el-card class="spec-card">
|
|
|
+ <el-card ref="specCardRef" class="spec-card">
|
|
|
<template #header>
|
|
|
<div class="card-header">
|
|
|
<span>{{ t('modules.goods.specificationSettings') }}</span>
|
|
@@ -147,7 +148,8 @@
|
|
|
<div class="sku" v-for="(s, k) in formData.skus" :key="`sku-${k}-${forceUpdateKey}`">
|
|
|
<div class="sku-key sa-flex sa-row-between">
|
|
|
<div class="sa-flex">
|
|
|
- <div class="sa-m-r-16">{{ t('modules.goods.specificationName') }}</div>
|
|
|
+ <div class="sa-m-r-16"><span class="required">*</span>{{ t('modules.goods.specificationName') }}
|
|
|
+ </div>
|
|
|
<el-input v-model="s.name" :placeholder="t('form.inputSpecificationName')" class="sku-key-input"
|
|
|
@input="buildSkuPriceTable"></el-input>
|
|
|
</div>
|
|
@@ -156,7 +158,7 @@
|
|
|
</el-icon>
|
|
|
</div>
|
|
|
<div class="sku-value sa-flex sa-flex-wrap">
|
|
|
- <div class="sku-value-title sa-m-r-16 sa-m-b-16 sa-flex">{{
|
|
|
+ <div class="sku-value-title sa-m-r-16 sa-m-b-16 sa-flex"><span class="required">*</span>{{
|
|
|
t('modules.goods.specificationValue')
|
|
|
}}</div>
|
|
|
<div v-for="(sc, c) in s.children" :key="c" class="sku-value-box sa-m-b-16">
|
|
@@ -375,6 +377,7 @@ const forceUpdateKey = ref(0);
|
|
|
// 表单引用
|
|
|
const basicFormRef = ref();
|
|
|
const attrFormRef = ref();
|
|
|
+const specCardRef = ref();
|
|
|
|
|
|
// 表单数据
|
|
|
const formData = reactive({
|
|
@@ -913,6 +916,15 @@ const nextStep = async () => {
|
|
|
}
|
|
|
// 进入下一步(商品属性设置)
|
|
|
currentStep.value++;
|
|
|
+
|
|
|
+ // 等待DOM更新后滚动到规格设置区域
|
|
|
+ await nextTick();
|
|
|
+ if (specCardRef.value) {
|
|
|
+ specCardRef.value.$el.scrollIntoView({
|
|
|
+ behavior: 'smooth',
|
|
|
+ block: 'start'
|
|
|
+ });
|
|
|
+ }
|
|
|
} else if (currentStep.value === 1) {
|
|
|
// 第二步:提交所有数据(基本信息 + 商品属性)
|
|
|
await submitGoods();
|
|
@@ -1026,6 +1038,34 @@ const submitGoods = async () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 验证商品规格必填项
|
|
|
+ // 检查是否有有效的规格配置
|
|
|
+ const validSpecs = formData.skus.filter(sku =>
|
|
|
+ sku.name && sku.name.trim() && sku.children && sku.children.length > 0 &&
|
|
|
+ sku.children.some(child => child.name && child.name.trim())
|
|
|
+ );
|
|
|
+
|
|
|
+ if (validSpecs.length === 0) {
|
|
|
+ ElMessage.error(t('modules.goods.pleaseAddSpecification'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查每个规格是否都有规格名称和至少一个规格值
|
|
|
+ for (let i = 0; i < formData.skus.length; i++) {
|
|
|
+ const sku = formData.skus[i];
|
|
|
+ // 跳过空的规格项(没有名称的)
|
|
|
+ if (!sku.name || !sku.name.trim()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果有规格名称,必须有至少一个有效的规格值
|
|
|
+ const validChildren = sku.children.filter(child => child.name && child.name.trim());
|
|
|
+ if (validChildren.length === 0) {
|
|
|
+ ElMessage.error(t('modules.goods.specificationValueRequired', { name: sku.name }));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 验证商品属性(如果有SKU)
|
|
|
if (formData.sku_prices && formData.sku_prices.length > 0) {
|
|
|
// 验证SKU数据
|
|
@@ -1044,6 +1084,10 @@ const submitGoods = async () => {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 如果没有SKU价格数据,说明规格配置不完整
|
|
|
+ ElMessage.error(t('modules.goods.pleaseCompleteSpecification'));
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
// 调用统一保存接口
|