Files
shanxia2.0/docs/crm-migration/plans/customer-pool/06-steps.md
T
2026-06-01 08:21:21 +08:00

298 lines
8.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 公海池模块迁移方案 — 06 分步实施计划
---
## 步骤 1:清理现有不符合规范的代码
### 目标
删除现有 shanxia2.0 中公海池相关的不规范代码,为重新移植做准备。
### 具体任务
1. 删除前端:`web-admin/src/views/crm/customer/pool/` 目录
2. 删除前端:`web-admin/src/api/crm/poolRule.ts`
3. 清理前端:`web-admin/src/api/crm/customer.ts` 中的公海池 API 函数
4. 删除后端:`backend/app/crud/crm/customer_pool.py`
5. 删除后端:`backend/app/crud/crm/pool_rule.py`
6. 删除后端:`backend/app/schemas/crm/customer_pool.py`
7. 删除后端:`backend/app/schemas/crm/pool_rule.py`
8. 清理后端:`backend/app/models/crm_models.py` 中的 CrmCustomerPool 和 CrmCustomerPoolRule
9. 清理后端:`backend/app/api/crm.py` 中的公海池相关路由
10. 删除后端:`backend/app/tasks/customer_pool.py`
### 涉及文件
- 上述所有文件
### 完成标准
- [ ] 所有公海池相关代码已删除
- [ ] 后端能正常启动(无 import 错误)
### 预计代码量
- 删除约 800 行
---
## 步骤 2:前端拷贝 — 公海池列表页
### 目标
从原 CRM 拷贝 `pool/index.vue` 到 shanxia2.0,保留完整功能。
### 具体任务
1. 拷贝 `shanxia/crm/web/src/views/crm/pool/index.vue` → `web-admin/src/views/crm/customer/pool/index.vue`
2. 不做任何修改,先保留原版代码
### 涉及文件
- `web-admin/src/views/crm/customer/pool/index.vue`(新建)
### 完成标准
- [ ] 文件已拷贝,内容与原 CRM 一致
---
## 步骤 3:前端拷贝 — 领取/分配弹窗
### 目标
拷贝 claimDialog 和 assignDialog 到 shanxia2.0。
### 具体任务
1. 拷贝 `claimDialog.vue` → `ClaimDialog.vue`
2. 拷贝 `assignDialog.vue` → `AssignDialog.vue`
### 涉及文件
- `web-admin/src/views/crm/customer/pool/components/ClaimDialog.vue`(新建)
- `web-admin/src/views/crm/customer/pool/components/AssignDialog.vue`(新建)
### 完成标准
- [ ] 两个弹窗文件已拷贝
---
## 步骤 4:前端适配 — pool/index.vue script 部分
### 目标
逐行审阅并适配 pool/index.vue 的 `<script>` 部分。
### 具体任务
1. 移除 `getCurrentInstance()` / `proxy`,改用直接 API 调用
2. 替换 `proxy?.useDict('xxx')` → `dictStore.getOptions('xxx')`
3. 替换 `proxy?.$modal.msgSuccess` → `ElMessage.success`
4. 移除手动 import(Element Plus 自动导入)
5. 替换 API 调用:`request({ url, method })` → `request.post(url, data)`
6. 创建 `web-admin/src/api/crm/pool.ts` 统一公海池 API
### 涉及文件
- `web-admin/src/views/crm/customer/pool/index.vue`
- `web-admin/src/api/crm/pool.ts`(新建)
### 完成标准
- [ ] 无 proxy/getCurrentInstance 残留
- [ ] 无手动 Element Plus import
- [ ] API 调用使用 shanxia2.0 风格
---
## 步骤 5:前端适配 — pool/index.vue template + style
### 目标
适配模板和样式为 Fresh Mint 风格。
### 具体任务
1. 替换 `<el-card>` 布局 → `page-container` + `panel` 布局
2. 替换 `<right-toolbar>` → `list-toolbar`
3. 替换 `<dict-tag>` → `<el-tag>` + dictStore
4. 添加模块标题竖线样式(`title-bar-heading`)
5. 弹窗适配:`label-width` → `label-position="top"`,添加 `dialog-form-layout`
6. 替换 UnoCSS 类 → SCSS/Tailwind
7. 添加 `<el-icon>` 到所有按钮
### 涉及文件
- `web-admin/src/views/crm/customer/pool/index.vue`
### 完成标准
- [ ] 无 el-card / right-toolbar / dict-tag 残留
- [ ] 按钮 icon 齐全
- [ ] 弹窗符合 dialog-form-layout 标准
---
## 步骤 6:前端适配 — ClaimDialog 和 AssignDialog
### 目标
适配两个弹窗组件。
### 具体任务
1. 移除 proxy/getCurrentInstance
2. 替换消息提示为 ElMessage
3. 弹窗样式适配(label-position="top",icon 按钮)
4. AssignDialog 中 `listUser` API 替换为 shanxia2.0 的用户列表 API
### 完成标准
- [ ] 弹窗功能完整,符合 UI 规范
---
## 步骤 7:前端新增 — 规则管理页面
### 目标
新建公海池规则管理页面(原 CRM 无前端,shanxia2.0 新增)。
### 具体任务
1. 新建 `views/crm/customer/pool/RuleIndex.vue`(参考标准列表模板 `unit/index.vue`)
2. 新建 `views/crm/customer/pool/components/RuleDialog.vue`(新增/编辑弹窗)
3. 在 `api/crm/pool.ts` 中添加规则管理 API 函数
4. 在 `router/modules/sqxp.ts` 中添加规则管理路由
### 涉及文件
- `web-admin/src/views/crm/customer/pool/RuleIndex.vue`(新建)
- `web-admin/src/views/crm/customer/pool/components/RuleDialog.vue`(新建)
- `web-admin/src/api/crm/pool.ts`
- `web-admin/src/router/modules/sqxp.ts`
### 完成标准
- [ ] 规则 CRUD 页面可正常渲染
- [ ] 路由已配置
---
## 步骤 8:后端 DDL + Model
### 目标
创建正确的 DDL 和 SQLAlchemy Model。
### 具体任务
1. 创建增量 SQL 脚本 `docs/sql/incremental_crm_customer_pool.sql`
2. 修正 `crm_models.py` 中的 CrmCustomerPool(字段名回归 sx.sql)
3. 修正 `crm_models.py` 中的 CrmCustomerPoolRule(字段名/类型/值回归 sx.sql)
### 涉及文件
- `docs/sql/incremental_crm_customer_pool.sql`(新建)
- `backend/app/models/crm_models.py`
### 完成标准
- [ ] DDL 与 sx.sql 业务字段一致
- [ ] Model 字段与 DDL 一一对应
- [ ] 7 项公共字段适配正确
---
## 步骤 9:后端 Schema
### 目标
创建 Pydantic v2 Schema,字段名回归。
### 具体任务
1. 重写 `schemas/crm/customer_pool.py`:字段用 `fromUserId`, `toUserId`, `reason`, `createByName`
2. 重写 `schemas/crm/pool_rule.py`:字段用 `poolName`, `timeoutDays`, `sort`, `ruleType`(no_follow/no_deal), `status`(enable/disable)
### 完成标准
- [ ] Schema 字段名与 DDL 字段 camelCase 一致
- [ ] 校验规则与 Java Bo 一致
---
## 步骤 10:后端 CRUD — 操作记录
### 目标
重写 `crud/crm/customer_pool.py`。
### 具体任务
1. `_row_to_dict`:字段名回归(fromUserId, toUserId, reason, createByName)
2. `list_pool_records`:按 create_time DESC
3. `create_pool_record`:写入操作记录
4. `get_pool_record`:按 ID 查询
### 完成标准
- [ ] CRUD 函数与 API 规格对应
---
## 步骤 11:后端 CRUD — 规则管理 + 定时任务
### 目标
重写 `crud/crm/pool_rule.py` 和 `tasks/customer_pool.py`。
### 具体任务
1. pool_rule CRUD:list/add/update/delete/toggle/execute
2. execute_pool_rules:按 no_follow/no_deal 规则类型执行回收
3. 定时任务:check_protect_period_expired + remind_protect_expiring
### 完成标准
- [ ] 规则 CRUD 完整
- [ ] 执行逻辑与 Java 一致(no_follow/no_deal 分支)
---
## 步骤 12:后端 API 路由
### 目标
在 `api/crm.py` 中添加公海池相关路由。
### 具体任务
1. 公海池客户列表:`/customer/pool/list`
2. 操作记录:`/customer/pool/record/list`, `/customer/pool/record/detail`
3. 规则管理:`/customer/pool/rule/list|detail|add|update|delete|updateStatus|execute`
4. 领取/分配/放入:复用客户管理路由
### 完成标准
- [ ] 路由与 API 规格一一对应
- [ ] 前端 API URL 与后端路由匹配
---
## 步骤 13:字典数据导入
### 目标
将公海池相关字典从 sx.sql 导入 shanxia2.0。
### 具体任务
1. 检查 sx.sql 中 `sys_dict_data` 是否有 `crm_pool_*` 字典
2. 如有,导出 INSERT 语句到增量 SQL 脚本
3. 如没有,根据 Java Bo 注解创建字典数据
### 完成标准
- [ ] 字典值与原 CRM 一致
---
## 步骤 14:整体验证
### 目标
端到端验证所有公海池功能。
### 验证清单
- [ ] 页面正常渲染,无控制台错误
- [ ] 公海池客户列表加载正常
- [ ] 搜索筛选功能正常
- [ ] 统计信息显示正确
- [ ] 领取功能正常
- [ ] 分配功能正常
- [ ] 放入公海功能正常(从客户管理操作)
- [ ] 规则 CRUD 功能正常
- [ ] 规则启停功能正常
- [ ] 列设置功能正常
- [ ] UI 规范合规(见 07-verify.md)
### 参考
- 验证清单详见 `07-verify.md`
---
## 步骤汇总
| 步骤 | 类型 | 目标 | 涉及文件 | 预计代码量 |
|------|------|------|---------|-----------|
| 1 | 清理 | 删除不规范代码 | 10+ 文件 | -800行 |
| 2 | 前端拷贝 | 拷贝 pool/index.vue | 1 文件 | ~350行 |
| 3 | 前端拷贝 | 拷贝弹窗组件 | 2 文件 | ~200行 |
| 4 | 前端适配 | script 部分适配 | 2 文件 | ~100行改动 |
| 5 | 前端适配 | template/style 适配 | 1 文件 | ~150行改动 |
| 6 | 前端适配 | 弹窗适配 | 2 文件 | ~60行改动 |
| 7 | 前端新增 | 规则管理页面 | 3 文件 | ~400行 |
| 8 | 后端 | DDL + Model | 2 文件 | ~120行 |
| 9 | 后端 | Schema | 2 文件 | ~120行 |
| 10 | 后端 | 操作记录 CRUD | 1 文件 | ~100行 |
| 11 | 后端 | 规则 CRUD + 任务 | 2 文件 | ~250行 |
| 12 | 后端 | API 路由 | 1 文件 | ~200行 |
| 13 | 数据 | 字典导入 | 1 文件 | ~20行 |
| 14 | 验证 | 整体验证 | — | — |
| **合计** | | | | **~1170行** |