diff --git a/docs/design/20261022-商品表单去除计价单位字段.md b/docs/design/20261022-商品表单去除计价单位字段.md new file mode 100644 index 0000000..5c23919 --- /dev/null +++ b/docs/design/20261022-商品表单去除计价单位字段.md @@ -0,0 +1,34 @@ +# 商品新增/编辑:去除「计价单位」字段 + +- 日期:2026-10-22 +- 开发者需求(附截图):「我们不需要计价单位 给我去除」 + +## 1. 改前事实 + +| # | 事实 | +|---|---| +| F1 | 商品新增/编辑弹窗在「规格」与「品牌」之间有「计价单位」字段:`SearchableSelect`,候选复用 `unitOptions`,可新建 | +| F2 | 该字段写 `formData.pricing_unit`,提交时映射到 `product_catalog.pricing_unit`(`insertCatalogProduct` / `updateCatalogProduct`),同步进 `skus.pricing_unit` | +| F3 | 界面上**只有**这一处使用该字段;列表、详情、录单、小程序均不展示 | +| F4 | 后端仍会读取该列:`prepPriceNormalizeService.ts` 用它作为备货价归一的目标维度(`COALESCE(pc.pricing_unit, s.pricing_unit, pc.unit, s.unit, '斤')`) | +| F5 | 4 条文案键仅在上述字段使用:`form.pricingUnit` / `form.pricingUnitPh` / `form.pricingUnitCreate` / `form.pricingUnitHint`(后者改前已无引用) | + +## 2. 方案 + +1. **删除**「计价单位」整块 UI(label + `SearchableSelect`),字段顺序变为 规格 → 品牌 → 默认仓库区域编号。 +2. **删除**随之失效的 4 条 i18n 键(zh-CN / en / id 三语同步删)。 +3. **保留** `formData.pricing_unit` 与提交参数:新商品仍按原逻辑默认等于「单位」; + 编辑既有商品时沿用库中已存值,不会因为隐藏字段被覆盖成单位。 +4. 「单位」变更时同步 `pricing_unit` 的原逻辑保留(`pricingSame` 判定),保证新商品的计价单位继续跟随单位。 + +## 3. 非目标 + +- 不删 `product_catalog.pricing_unit` / `skus.pricing_unit` 两列,不动备货价归一(`prepPriceNormalizeService.ts`)与行情/价格异常维度; +- 不改包装折算区域(`form.packPricingFallback` 等文案不动)。 + +## 4. 验收 + +1. 商品新增/编辑弹窗**不再出现**「计价单位」字段。 +2. 新增商品保存后 `pricing_unit` 仍等于所选单位;编辑既有商品保存后该值不变。 +3. 其余字段(单位 / 规格 / 品牌 / 区域 / 税码 / 税率 / 包装折算 / 报价)位置与行为不变。 +4. `npm run typecheck` 通过;`src/i18n` 与 `src/pages/products` 测试全绿。 diff --git a/docs/design/README.md b/docs/design/README.md index 6cd351d..4e7e194 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -153,6 +153,7 @@ AI 提示词清理已停用条目(7 条归档不删、清单过滤 archived、 **商品新增/编辑:去示例占位文字 + 仓库区域改选择框**:开发者附截图「首先是品牌输入框 这些输入框里面不能存在默认占位文字;仓库区域这个不是输入框而是选择框 没有选择支持新建区域」——商品名称「如: 大白菜」、品牌「选填,如:金龙鱼、双汇」两个 placeholder 已移除;「默认仓库区域编号」由文本输入改为 `SearchableSelect`,候选 = `GET /inventory/storage-zones`(库存用过的)∪ 当前商品列表已填的 `storage_zone`,空值显示「未设置」,**输入无匹配时可新建**(「+ 使用区域「X」」);保存仍写 `skus.storage_zone`(区域是自由文本,无新表)。分类选择框与**录单同款**:下拉常显「新建分类」、输入无匹配显示「新建分类「X」」,点击弹出同一个快捷建类弹窗,确定后新分类直接选中(同名同级复用、税档按分类重算、安全线归 0)。税率/税码/报价等操作说明类提示未动,见 [20261022-商品表单去占位示例文字与区域改选择框.md](./20261022-商品表单去占位示例文字与区域改选择框.md)。 **快速新建分类弹窗去小字**:开发者附截图「这个分类的选择弹窗小字太多了 去除小字」——`QuickCategoryModal` 标题下的说明行(含「带供应商」变体)与输入框占位「例如:调料、冷冻品」均已删除,标题下间距 `mb-1` 调为 `mb-4`;建类逻辑、可选供应商选择器、按钮文案均未动。⚠️ 该组件被**商品新增/编辑、录单、订单详情改分类**三处复用,三处一起变,见 [20261022-快速新建分类弹窗去小字.md](./20261022-快速新建分类弹窗去小字.md)。 **商品表单:标题改「税收编码」+ 去官方库搜索框 + 去输入占位**:开发者附截图「税收分类编码 变为税收编码修改文字 然后下方的手上实时官方库的那个输入框去掉」、「税收编码里面的默认文字去掉」——`products.form.taxCode` 文案改为「税收编码 / Tax code / Kode pajak」;税码输入下方那块「搜索实时官方库(货物和劳务名称 / 简称)」输入框、加载行、结果列表整体删除,并清理对应 state/防抖 effect/`searchTaxCatalogApi` 引用与弹窗重置调用;税码输入框的占位「规则引擎 + 官方库 + AI 分层匹配」也去掉。税码推荐卡片、候选、确认采用与税率联动未动,见 [20261022-商品表单税收编码标题与去官方库搜索框.md](./20261022-商品表单税收编码标题与去官方库搜索框.md)。**追加**:开发者「当前这块输入完毕商品名出现的推荐分类?首先改为推荐编码」——推荐卡片标题 `products.form.taxRecommend` 改为「推荐编码 / Suggested code / Kode disarankan」,卡片正文与推荐逻辑未动;该编码来自随代码发布的官方库(`server/data/tax-catalog-entries.json`,1820 条 / 19 位),同商品名同库版本下确定,AI 只能从候选中挑、不能造码。 +**商品新增/编辑:去除计价单位字段**:开发者附截图「我们不需要计价单位 给我去除」——弹窗中「计价单位」整块 UI(label + `SearchableSelect`)已删,字段顺序变为 规格 → 品牌 → 区域编号;随之失效的 4 条三语文案键(`form.pricingUnit*`)同步删除。⚠️ **后端列保留**:`formData.pricing_unit` 与提交参数未删,新商品仍默认等于单位、编辑既有商品沿用库中值,备货价归一(`prepPriceNormalizeService`)不受影响,见 [20261022-商品表单去除计价单位字段.md](./20261022-商品表单去除计价单位字段.md)。 ## 全量对齐与改造方案(2026-09-28) diff --git a/src/i18n/locales/en/products.ts b/src/i18n/locales/en/products.ts index 71c7c40..4d10385 100644 --- a/src/i18n/locales/en/products.ts +++ b/src/i18n/locales/en/products.ts @@ -145,11 +145,6 @@ export const products: MessageDict = { 'form.unitCreateHint': 'For this product only; not written to the unit dictionary', 'form.unitHint': 'Common units are maintained under Unit Management; typed values can be temporary and are not forced into the dictionary.', - 'form.pricingUnit': 'Pricing unit', - 'form.pricingUnitPh': 'Defaults to the same as unit, often jin', - 'form.pricingUnitCreate': 'Use “{q}” as pricing unit', - 'form.pricingUnitHint': - 'Market averages, price anomalies, and purchase memory compare only in this dimension.', 'form.packFactors': 'Pack conversion', 'form.packUnitPh': 'pcs', 'form.packEquals': '1 of this unit =', diff --git a/src/i18n/locales/id/products.ts b/src/i18n/locales/id/products.ts index 157e635..7c51c31 100644 --- a/src/i18n/locales/id/products.ts +++ b/src/i18n/locales/id/products.ts @@ -146,11 +146,6 @@ export const products: MessageDict = { 'form.unitCreateHint': 'Hanya untuk produk ini; tidak ditulis ke kamus satuan', 'form.unitHint': 'Satuan umum dikelola di Manajemen Satuan; input manual bisa sementara dan tidak wajib masuk kamus.', - 'form.pricingUnit': 'Satuan harga', - 'form.pricingUnitPh': 'Default sama dengan satuan, biasanya jin', - 'form.pricingUnitCreate': 'Gunakan “{q}” sebagai satuan harga', - 'form.pricingUnitHint': - 'Rata-rata pasar, anomali harga, dan memori pembelian hanya dibandingkan pada dimensi ini.', 'form.packFactors': 'Konversi kemasan', 'form.packUnitPh': 'pcs', 'form.packEquals': '1 satuan ini =', diff --git a/src/i18n/locales/zh-CN/products.ts b/src/i18n/locales/zh-CN/products.ts index e34a12c..db6967a 100644 --- a/src/i18n/locales/zh-CN/products.ts +++ b/src/i18n/locales/zh-CN/products.ts @@ -144,10 +144,6 @@ export const products: MessageDict = { 'form.unitCreate': '使用自定义单位「{q}」', 'form.unitCreateHint': '仅本商品使用,不会写入单位字典', 'form.unitHint': '常用单位在「单位管理」维护;手输可临时用,不强制入库。', - 'form.pricingUnit': '计价单位', - 'form.pricingUnitPh': '默认与单位相同,多为斤', - 'form.pricingUnitCreate': '使用「{q}」作计价单位', - 'form.pricingUnitHint': '行情均价、价格异常、采购记忆只在此维度比较。', 'form.packFactors': '包装折算', 'form.packUnitPh': '件', 'form.packEquals': '1 该单位 =', diff --git a/src/pages/products/SkuManagement.tsx b/src/pages/products/SkuManagement.tsx index 1860653..f489a48 100644 --- a/src/pages/products/SkuManagement.tsx +++ b/src/pages/products/SkuManagement.tsx @@ -2838,32 +2838,6 @@ export const SkuManagement: React.FC = () => { className="app-input w-full px-3 py-2 border border-slate-300 rounded-lg text-slate-900 placeholder:text-slate-400 focus:ring-2 focus:ring-[var(--app-theme-accent)] dark:text-slate-100" /> -