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

This commit is contained in:
2026-05-18 13:29:59 +08:00
committed by guanyu
parent 8bf3664585
commit c43b48c552

79
BUG540_ANALYSIS.md Normal file
View File

@@ -0,0 +1,79 @@
# Bug #540 分析报告
## Bug 描述
【住院医生站-检查申请】详情页弹窗中"申请单描述"区域缺少临床必要信息显示
## 数据流分析
### 前端组件
- 入口: `src/views/inpatientDoctor/home/index.vue` → "检查申请" tab → `ExamineApplication`
- 实际组件: `src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue`
- 编辑表单组件: `src/views/inpatientDoctor/home/components/order/applicationForm/medicalExaminations.vue`
### 后端 API
- 查询: `GET /reg-doctorstation/request-form/get-check``typeCode = '23'` (ActivityDefCategory.TEST)
- 保存: `POST /reg-doctorstation/request-form/save-check``typeCode = '23'`
- SQL: `RequestFormManageAppMapper.xml``getRequestForm` 查询SELECT `drf.desc_json`
- DTO: `RequestFormQueryDto``descJson` 字段 (String 类型)
### 数据库
- 表: `doc_request_form`type_code = '23' 的记录 desc_json 均有数据
- descJson 包含: targetDepartment, urgencyLevel, symptom, sign, clinicalDiagnosis, otherDiagnosis, relatedResult, attention, examinationPurpose, medicalHistorySummary, allergyHistory, expectedExaminationTime 等
## 根因定位
对比检验申请 (testApplication.vue) 和检查申请 (examineApplication.vue) 的详情弹窗中"申请单描述"区域的渲染逻辑:
**testApplication.vue (检验申请) - 正确:**
```vue
<template v-for="(value, key) in descJsonData" :key="key">
<el-descriptions-item v-if="isFieldMatched(key)" :label="getFieldLabel(key)">
{{ value || '-' }}
</el-descriptions-item>
</template>
```
- 遍历 `descJsonData` 的所有 key只要 key 在 labelMap 中就显示
- 空值显示为 '-'
**examineApplication.vue (检查申请) - 问题:**
```vue
<el-descriptions-item
v-for="key in orderedDescFieldKeys"
:key="key"
v-if="descJsonData[key] != null && descJsonData[key] !== ''"
:label="getFieldLabel(key)"
>
{{ transformField(key, descJsonData[key]) || '-' }}
</el-descriptions-item>
```
- 遍历固定的 `orderedDescFieldKeys` 数组,不遍历 descJsonData 的所有 key
- **关键问题**: `v-if="descJsonData[key] != null && descJsonData[key] !== ''"` 会过滤掉空值字段
但是,更关键的是外层条件:
```vue
<div v-if="descJsonData && hasMatchedFields" class="applicationShow-container-content">
```
`hasMatchedFields` 检查 `descJsonData` 的 key 是否在 `labelMap` 中。`labelMap` 包含所有需要显示的字段。
**实际根因**:通过对比 testApplication.vue 与 examineApplication.vue发现两个组件在 "申请单描述" 区域的渲染方式不同。testApplication 遍历 descJsonData 的所有 key只要有值就显示而 examineApplication 只遍历 orderedDescFieldKeys 数组。
**最可能的根因**:当 descJsonData 中的字段值为空字符串时examineApplication 的 `v-if` 条件 `descJsonData[key] !== ''` 会过滤掉该字段(整行不显示),而 testApplication 会显示该字段标签并填入 `-`
对于 `targetDepartment` 字段,`recursionFun` 函数在科室列表中找不到对应 ID 时会返回空字符串 `''`,导致 `targetDepartment` 被过滤不显示。
**但核心问题是**:如果 descJsonData 存在但某些字段为空,这些字段会被完全隐藏而不是显示 `-`。用户期望看到的是字段标签+占位符 `-`,而不是整个字段不显示。
## 修复方案
将 examineApplication.vue 中"申请单描述"区域的渲染方式改为与 testApplication.vue 一致:
1. 遍历 `descJsonData` 的所有 key而非固定 orderedDescFieldKeys
2. 使用 `isFieldMatched(key)` 过滤需要显示的字段
3. 空值显示为 `-`(而非完全隐藏)
同时保留 `orderedDescFieldKeys` 用于打印功能(已有代码使用)。
## 变更文件
- `openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue`(前端模板修改)
修复结果:✅ 成功5行改动+5/-8