Fix Bug #498: 看报告功能参数名不匹配(prescriptionNo→encounterId),修复后端接口无法获取正确参数导致报告查询返回空列表的问题

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
赵云
2026-05-16 20:16:43 +08:00
parent 0d9b2879ac
commit 3a928afbc7
2 changed files with 65 additions and 1 deletions

64
docs/bug498_analysis.md Normal file
View File

@@ -0,0 +1,64 @@
# Bug #498 分析报告
## Bug 描述
【住院医生工作站-检查申请】检查申请列表操作项过于单一,缺失修改/作废/打印/看报告等核心临床操作
## 阶段1深度分析
### 当前代码状态
`examineApplication.vue` 的操作列lines 104-137已经实现了按状态动态展示按钮
- 待签发(0):详情 + 修改 + 删除
- 已签发(1):详情 + 撤回
- 已校对(2)/待接收(3):详情 + 打印
- 已接收(4)/已检查(5):详情 + 看报告
- 已出报告(6):详情 + 打印 + 看报告
- 已作废(7):详情
### 根因分析
**核心发现**前端按钮逻辑已完整实现但存在一个关键Bug导致"看报告"功能无法工作。
#### Bug`handleViewReport` 传递错误的参数
前端代码 (examineApplication.vue:920):
```js
const res = await getTestResult({ prescriptionNo: row.prescriptionNo });
```
后端接口 (DoctorStationAdviceController.java:190-192):
```java
@GetMapping(value = "/test-result")
public R<?> getTestResult(@RequestParam(value = "encounterId") Long encounterId) {
return iDoctorStationAdviceAppService.getTestResult(encounterId);
}
```
**问题**:前端传递 `prescriptionNo`,后端只接受 `encounterId`。Spring 忽略未知参数,`encounterId` 为 null后端直接返回空列表。
后端服务实现 (DoctorStationAdviceAppServiceImpl.java:2357-2376):
```java
public R<?> getTestResult(Long encounterId) {
if (encounterId == null) {
return R.ok(new ArrayList<>()); // encounterId为空时直接返回空列表
}
// ... 查询逻辑 ...
}
```
#### 数据流追踪
1. 前端 `handleViewReport(row)` → 获取 `row.prescriptionNo`
2. 调用 `getTestResult({ prescriptionNo: "JCZ26051600001" })`
3. 后端接收:`encounterId = null`(参数名不匹配,被忽略)
4. 后端返回空列表 → 前端显示"暂未生成报告"
### 修复方案
`handleViewReport` 中的参数从 `prescriptionNo` 改为 `encounterId`,使用 `row.encounterId``patientInfo.value.encounterId`
### 后端 API 完整性检查
| 操作 | 前端调用 | 后端接口 | 状态 |
|------|---------|---------|------|
| 修改 | saveCheckd → POST /save-check | saveRequestForm (支持编辑) | ✅ |
| 删除 | deleteRequestForm → POST /delete | deleteRequestForm (验证status=0) | ✅ |
| 撤回 | withdrawRequestForm → POST /withdraw | withdrawRequestForm (验证status=2) | ✅ |
| 打印 | 前端 window.open 打印 | 无后端依赖 | ✅ |
| 看报告 | getTestResult → GET /test-result | getTestResult(encounterId) | ❌ 参数名不匹配 |

View File

@@ -917,7 +917,7 @@ const handleViewReport = async (row) => {
reportLoading.value = true;
reportData.value = null;
try {
const res = await getTestResult({ prescriptionNo: row.prescriptionNo });
const res = await getTestResult({ encounterId: row.encounterId || patientInfo.value?.encounterId });
if (res.code === 200) {
if (res.data) {
// 支持两种返回格式: