fix(shopGoods): 修复SKU表格库存列和运费模板校验缺失

- 补充多规格SKU表格中缺失的划线价和库存列定义
- 添加快递配送开启时运费模板前端必填校验
- 在保存逻辑中增加运费模板缺失时的错误提示
- 运费模板表单项动态显示必填标记及占位提示
- 保持与后端校验逻辑一致,提升用户体验
This commit is contained in:
2026-08-11 10:52:29 +08:00
parent 40bcc77c50
commit 706db16337
2 changed files with 30 additions and 1 deletions
+11
View File
@@ -40,3 +40,14 @@
3. 编辑弹窗:城市选择变化 → `form.regionIds = 逗号串``form.regionMode = 1`(有选)或 `0`(全国);回显从 `form.regionIds` 拆出。 3. 编辑弹窗:城市选择变化 → `form.regionIds = 逗号串``form.regionMode = 1`(有选)或 `0`(全国);回显从 `form.regionIds` 拆出。
4. 列表页:customRender 读 `record.regionIds` 反查城市名。 4. 列表页:customRender 读 `record.regionIds` 反查城市名。
- 结论:**本需求纯前端即可闭环,后端无需改**。城市编码(`regions-data.json` 的 city value6位)与 `regionIds` 完全一致,下单校验 `DeliveryRegionChecker``regionIds` 直接生效。 - 结论:**本需求纯前端即可闭环,后端无需改**。城市编码(`regions-data.json` 的 city value6位)与 `regionIds` 完全一致,下单校验 `DeliveryRegionChecker``regionIds` 直接生效。
## 修复:多规格SKU表格缺少库存列
- 文件:`src/views/shop/shopGoods/components/shopGoodsEdit.vue`
- 问题:`columns` 数组缺少 `stock`(库存) 和 `salePrice`(划线价) 列定义,导致多规格SKU明细表不显示库存输入框(批量设置栏有,但表格列没有)
- 修复:在 columns 数组中补齐 `salePrice``stock` 两列(bodyCell 模板已有渲染逻辑,只需加列定义)
## 修复:商品保存「快递配送时运费模板必选」前端校验缺失
- 文件:`src/views/shop/shopGoods/components/shopGoodsEdit.vue`
- 问题:后端有校验规则——`canExpress=1` 时要求 `expressTemplateId` 必填,但前端无对应校验,用户开启快递配送后直接提交被后端拦住,报错"运费模板必选"。
- 修复:在 `save()` 的 validate 通过后、请求前增加前端拦截:`canExpress=1 && !expressTemplateId``message.error('请选择运费模板')`
- UI 优化:运费模板 `<a-form-item>``:required="form.canExpress === 1"` 动态必填标记 + placeholder 提示文字。
@@ -106,10 +106,11 @@
v-model:value="form.buyingPrice" v-model:value="form.buyingPrice"
/> />
</a-form-item> </a-form-item>
<a-form-item label="运费模板" v-if="!merchantId"> <a-form-item :label="form.canExpress === 1 ? '运费模板' : '运费模板'" v-if="!merchantId" :required="form.canExpress === 1">
<a-select <a-select
v-model:value="form.expressTemplateId" v-model:value="form.expressTemplateId"
style="width: 240px" style="width: 240px"
:placeholder="form.canExpress === 1 ? '请选择运费模板(必选)' : '请选择运费模板'"
> >
<a-select-option <a-select-option
v-for="(item, index) in expressTemplateList" v-for="(item, index) in expressTemplateList"
@@ -900,12 +901,24 @@ const columns = [
key: 'price', key: 'price',
align: 'center' align: 'center'
}, },
{
title: '划线价',
dataIndex: 'salePrice',
key: 'salePrice',
align: 'center'
},
{ {
title: '会员价', title: '会员价',
dataIndex: 'buyingPrice', dataIndex: 'buyingPrice',
key: 'buyingPrice', key: 'buyingPrice',
align: 'center' align: 'center'
}, },
{
title: '库存',
dataIndex: 'stock',
key: 'stock',
align: 'center'
},
{ {
title: '商品编号', title: '商品编号',
dataIndex: 'skuNo', dataIndex: 'skuNo',
@@ -1846,6 +1859,11 @@ const save = () => {
.validate() .validate()
.then(() => { .then(() => {
loading.value = true; loading.value = true;
// 快递配送时运费模板必选(后端也有此校验,前端提前拦截给出友好提示)
if (form.canExpress === 1 && !form.expressTemplateId && !merchantId) {
loading.value = false;
return message.error('请选择运费模板');
}
if (form.priceGift && !form.priceGiftNum) if (form.priceGift && !form.priceGiftNum)
return message.error('请输入会员赠品数量'); return message.error('请输入会员赠品数量');
if (ensureTag.value.length) form.ensureTag = ensureTag.value.join(); if (ensureTag.value.length) form.ensureTag = ensureTag.value.join();