Fix Bug #524: 根因+修复方案摘要

This commit is contained in:
2026-05-18 09:08:36 +08:00
committed by guanyu
parent fad5130072
commit 02a1889f2c

View File

@@ -0,0 +1,53 @@
# Bug #523 分析报告
## Bug 描述
[住院医生站-临床医嘱] 待保存医嘱总金额显示缺失且编辑态单位选择框变为数字控件
## 根因分析
### 问题1总金额显示为 "-"
**文件**: `openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/index.vue`
**根因**: `setValue()` 函数约1441行在选中药品后初始化行数据时
- 设置了 `unitPrice``minUnitPrice`(西药/中成药/中草药)
- 设置了诊疗类型的 `totalPrice`adviceType==3 分支1537-1538行
- **但没有为药品类型adviceType==1计算 `totalPrice`**
`totalPrice` 只在用户后续交互(修改总量、切换单位)时通过 `calculateTotalAmount()` 才计算。
列表显示逻辑259行`scope.row.totalPrice ? ... : '-'`,未设置则显示横杠。
**数据流**: 选药 → setValue(设unitPrice) → 用户填总量 → calculateTotalAmount(算totalPrice) → 列表显示
**问题**: 用户选好药后还没触发计算事件时totalPrice 为空
### 问题2编辑态单位选择框变为数字控件
**文件**: `openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/index.vue`
**根因**: `setValue()` 函数1518行
```js
unitCode: row.partAttributeEnum == 1 ? row.minUnitCode : row.unitCode,
```
后端返回的 `row.unitCode` / `row.minUnitCode` 可能是 **Number 类型**
`row.unitCodeList` 中每个 option 的 `value``String` 类型(从后端字典值来)。
`el-select``v-model`Number与所有 option 的 `value`String类型不匹配时
Element Plus 无法找到匹配选项,渲染异常,表现为数字输入控件。
## 修复方案
### 修复1总金额
`setValue()` 的药品分支中,设置价格后立即计算初始 `totalPrice`
```js
// 在 positionName 设置后添加:
totalPrice: row.quantity ? (row.unitCode == row.minUnitCode
? (row.quantity * row.minUnitPrice).toFixed(6)
: (row.quantity * row.unitPrice).toFixed(6))
: undefined,
```
### 修复2单位选择框
`setValue()``updatedRow` 中,将 `unitCode``minUnitCode` 转为字符串:
```js
minUnitCode: String(row.minUnitCode),
unitCode: row.partAttributeEnum == 1 ? String(row.minUnitCode) : String(row.unitCode),
```
确保与 el-option 的 valueString类型一致。