# 商机 price 字段统一为 businessPrice — 前端联调方案 ## 问题背景 前端产品编辑表使用 `contractPrice` 作为价格字段发送给后端,但后端使用的是 `businessPrice`(商机价格)。两者是同一个概念,需要统一为 `businessPrice`。 ## 涉及页面 - 商机新增/编辑弹窗(`src/views/crm/business/modules/form.vue`) - 产品编辑表组件(`src/views/crm/product/components/edit-table.vue`) - 产品编辑表列定义(`src/views/crm/product/components/data.ts`) ## API 说明 | 方法 | 路径 | 说明 | |------|------|------| | PUT | `/crm/business/update` | 更新商机 | | POST | `/crm/business/create` | 新增商机 | **请求体字段变更(`products[]` 内):** | 字段 | 变更 | 说明 | |------|------|------| | `contractPrice` | ❌ 移除 | 改为 `businessPrice` | | `businessPrice` | ✅ 统一使用 | 商机价格 | | `totalProductPrice` | ✅ 已有 | 产品总价(后端已新增支持) | | `totalPrice` | ✅ 已有 | 商机总价(折后)(后端已新增支持) | ## 前端修改点 ### 1. `edit-table.vue` — 字段名 `contractPrice` → `businessPrice` 文件:`src/views/crm/product/components/edit-table.vue` 涉及 6 处: | 行号 | 修改 | |------|------| | 55 | `row.contractPrice` → `row.businessPrice` | | 57 | `row.contractPrice` → `row.businessPrice` | | 63 | `row.contractPrice` → `row.businessPrice` | | 70 | `row.contractPrice` → `row.businessPrice` | | 132 | `contractPrice` → `businessPrice`(template slot name) | | 134 | `row.contractPrice` → `row.businessPrice`(v-model) | ### 2. `data.ts` — 编辑表列定义 文件:`src/views/crm/product/components/data.ts` 第 91-95 行,编辑表(非 business 视图)的列定义: ``` field: 'contractPrice' → field: 'businessPrice' title: '合同价(元)' → title: '商机价格(元)' slots: { default: 'contractPrice' } → slots: { default: 'businessPrice' } ``` ## 业务规则说明 | 场景 | 规则 | |------|------| | 更新商机时产品 `businessPrice` 为 null | 后端自动用旧数据的 `businessPrice` merge(无需前端处理) | | 新增商机时 | `businessPrice` 必填,不可为 null | | 产品 `totalPrice` | 前端可直接传计算好的值,后端优先使用;未传时后端用 `businessPrice * count` 自动计算 | | 头级 `totalProductPrice` / `totalPrice` | 前端可直接传,后端不再覆盖 | ## 注意事项 - **不涉及的文件**:`contract`、`statistics`、`report`、`saleTrace` 中的 `contractPrice` 是其他业务概念,不用改 - 产品 `id` 字段后端已新增支持,更新时传 `id` 即可标识已有产品 - 前端 `businessPrice` 的初始化值来自 `product.salesPrice`(选中产品时的默认价) - 更新时只需传要修改的字段,未传字段后端自动从旧数据继承