From 706db1633761a30fbdc1300d0fa66290d9854bfd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com>
Date: Tue, 11 Aug 2026 10:52:29 +0800
Subject: [PATCH] =?UTF-8?q?fix(shopGoods):=20=E4=BF=AE=E5=A4=8DSKU?=
=?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=BA=93=E5=AD=98=E5=88=97=E5=92=8C=E8=BF=90?=
=?UTF-8?q?=E8=B4=B9=E6=A8=A1=E6=9D=BF=E6=A0=A1=E9=AA=8C=E7=BC=BA=E5=A4=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 补充多规格SKU表格中缺失的划线价和库存列定义
- 添加快递配送开启时运费模板前端必填校验
- 在保存逻辑中增加运费模板缺失时的错误提示
- 运费模板表单项动态显示必填标记及占位提示
- 保持与后端校验逻辑一致,提升用户体验
---
.workbuddy/memory/2026-08-11.md | 11 ++++++++++
.../shopGoods/components/shopGoodsEdit.vue | 20 ++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/.workbuddy/memory/2026-08-11.md b/.workbuddy/memory/2026-08-11.md
index f63ee31..eca1df6 100644
--- a/.workbuddy/memory/2026-08-11.md
+++ b/.workbuddy/memory/2026-08-11.md
@@ -40,3 +40,14 @@
3. 编辑弹窗:城市选择变化 → `form.regionIds = 逗号串`、`form.regionMode = 1`(有选)或 `0`(全国);回显从 `form.regionIds` 拆出。
4. 列表页:customRender 读 `record.regionIds` 反查城市名。
- 结论:**本需求纯前端即可闭环,后端无需改**。城市编码(`regions-data.json` 的 city value,6位)与 `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 优化:运费模板 `` 加 `:required="form.canExpress === 1"` 动态必填标记 + placeholder 提示文字。
diff --git a/src/views/shop/shopGoods/components/shopGoodsEdit.vue b/src/views/shop/shopGoods/components/shopGoodsEdit.vue
index 7f77205..01c2780 100644
--- a/src/views/shop/shopGoods/components/shopGoodsEdit.vue
+++ b/src/views/shop/shopGoods/components/shopGoodsEdit.vue
@@ -106,10 +106,11 @@
v-model:value="form.buyingPrice"
/>
-
+
{
.validate()
.then(() => {
loading.value = true;
+ // 快递配送时运费模板必选(后端也有此校验,前端提前拦截给出友好提示)
+ if (form.canExpress === 1 && !form.expressTemplateId && !merchantId) {
+ loading.value = false;
+ return message.error('请选择运费模板');
+ }
if (form.priceGift && !form.priceGiftNum)
return message.error('请输入会员赠品数量');
if (ensureTag.value.length) form.ensureTag = ensureTag.value.join();