Files
zyt/ADD_DOSE_UNIT_TO_ORDER_SUMMARY.md
T
2026-04-15 16:31:25 +08:00

76 lines
2.7 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.
# 添加剂量单位和剂数字段到订单编辑表单
## 任务概述
在处方订单编辑表单中添加 `dose_unit`(剂量单位)和 `dose_count`(剂数)字段,支持用户选择和编辑。
## 实现内容
### 1. 前端表单字段(admin/src/views/consumer/prescription/order_list.vue
#### 添加的表单项:
- **剂量单位** (`dose_unit`): 下拉选择框,7个选项
- 剂、丸、袋、盒、瓶、膏、贴
- 默认值:剂
- **剂数** (`dose_count`): 数字输入框
- 最小值:1
- 默认值:1
#### 修改位置:
- 表单定义:在 `medication_days` 字段后添加
- 数据加载:`openEdit()` 函数中加载 `dose_count``dose_unit`
- 数据提交:`submitEdit()` 函数中包含 `dose_count``dose_unit`
### 2. 后端逻辑(server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php
#### 修改的方法:
- `edit()` 方法添加字段处理:
```php
$order->dose_unit = (string) ($params['dose_unit'] ?? '剂');
$order->dose_count = isset($params['dose_count']) && (int)$params['dose_count'] > 0 ? (int)$params['dose_count'] : 1;
```
### 3. 数据库迁移(add_dose_unit_to_prescription_order.sql
#### 添加的字段:
```sql
ALTER TABLE `zyt_tcm_prescription_order`
ADD COLUMN `dose_unit` varchar(20) NOT NULL DEFAULT '剂' COMMENT '剂量单位:剂、丸、袋、盒、瓶、膏、贴' AFTER `medication_days`,
ADD COLUMN `dose_count` int(11) NOT NULL DEFAULT 1 COMMENT '剂数' AFTER `dose_unit`;
```
## 字段说明
| 字段名 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| dose_unit | varchar(20) | 剂 | 剂量单位:剂、丸、袋、盒、瓶、膏、贴 |
| dose_count | int(11) | 1 | 剂数,最小值为1 |
## 部署步骤
1. **执行数据库迁移**
```bash
mysql -u用户名 -p数据库名 < add_dose_unit_to_prescription_order.sql
```
2. **部署后端代码**
- 更新 `server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php`
3. **部署前端代码**
- 更新 `admin/src/views/consumer/prescription/order_list.vue`
- 重新构建前端:`npm run build`
## 测试要点
- [ ] 创建新订单时,`dose_unit` 默认为"剂"`dose_count` 默认为1
- [ ] 编辑订单时,能正确加载已保存的 `dose_unit` 和 `dose_count` 值
- [ ] 修改 `dose_unit` 和 `dose_count` 后能正确保存
- [ ] 验证 `dose_count` 不能小于1
- [ ] 验证所有7个剂量单位选项都能正常选择和保存
## 相关文件
- `admin/src/views/consumer/prescription/order_list.vue` - 前端订单列表和编辑表单
- `server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php` - 后端订单编辑逻辑
- `add_dose_unit_to_prescription_order.sql` - 数据库迁移脚本