Fix Bug #548: 根因+修复方案摘要
This commit is contained in:
35
BUG548_ANALYSIS.md
Normal file
35
BUG548_ANALYSIS.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Bug #548 分析报告
|
||||
|
||||
## Title
|
||||
【住院医生站-检验申请】修改申请单时,"发往科室"字段未能正确回显原有数据
|
||||
|
||||
## 根因定位
|
||||
|
||||
文件: `openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/laboratoryTests.vue`
|
||||
|
||||
### 数据流
|
||||
|
||||
1. 用户点击"修改"→ `testApplication.vue` 的 `handleEdit` 将 row 数据作为 `editData` 传给 `LaboratoryTests` 组件
|
||||
2. `LaboratoryTests` 中 `watch(() => props.editData)` 解析 `descJson`,将 `form.targetDepartment` 设为申请单原有的科室ID
|
||||
3. 同一 watch 内调用 `applyEditTransferSelection()` → 设置 `transferValue.value = uniq`(已选项目ID数组)
|
||||
4. `transferValue` 的变化触发了另一个 watch(第341-346行)→ 调用 `projectWithDepartment(newValue, 1)`
|
||||
5. `projectWithDepartment` 第294行:`const manualDept = type === 2 ? form.targetDepartment : ''`(type=1时取空字符串)
|
||||
6. 第296行:`form.targetDepartment = ''` → **清空了步骤2中刚设置好的科室值**
|
||||
7. 后续逻辑(329-336行)仅在 `type === 2`(提交模式)下才保留用户手动选择的科室,`type === 1`(选择项目变化)时不恢复
|
||||
|
||||
### 根因
|
||||
|
||||
编辑模式下,`applyEditTransferSelection` 设置 `transferValue` 时触发了 watch → `projectWithDepartment(arr, type=1)` → 用 `type !== 2` 清空了 `form.targetDepartment`。`descJson` 中保存的科室ID被覆盖为空字符串,导致回显失败。
|
||||
|
||||
### 修复方案
|
||||
|
||||
在编辑初始化期间设置一个 `isInitializing` 标志,使 `transferValue` 的 watch 跳过 `projectWithDepartment` 调用。
|
||||
|
||||
### 修复结果:✅ 成功,8行改动
|
||||
|
||||
**改动文件**: `openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/laboratoryTests.vue`
|
||||
|
||||
1. 新增 `isInitializing` 标志(ref(false))
|
||||
2. `transferValue` 的 watch 增加 `if (isInitializing.value) return;` 拦截
|
||||
3. `applyEditTransferSelection()` 中设置 `transferValue` 前后加 `isInitializing` 标志
|
||||
4. `applicationListAll` 的 watch 中设置 `transferValue` 前后也加 `isInitializing` 标志
|
||||
Reference in New Issue
Block a user