Fix Bug #477: 住院医生工作站-住院检查申请详情弹窗中"发往科室"字段显示为短横线(-),未正常获取数据

根因:handleViewDetail 为同步方法,点击详情时 getLocationInfo 尚未返回,
orgOptions 为空导致 recursionFun 无法将 targetDepartment ID 解析为科室名称。

修复:
1. 前端(4个申请组件):handleViewDetail 改为 async,解析 descJson 前确保 orgOptions 已加载
2. 前端:watch encounterId 改为 Promise.all 并行加载数据和科室列表
3. 后端:新增 keyword 关键字筛选参数(申请单号/检查项目模糊匹配)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
关羽
2026-05-11 14:03:40 +08:00
parent 8fae6fe3d5
commit 8093f8acda
9 changed files with 100 additions and 43 deletions

View File

@@ -33,7 +33,7 @@ public interface IRequestFormManageAppService {
List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode);
/**
* 查询申请单(支持筛选)
* 查询申请单(支持日期和状态筛选)
*
* @param encounterId 就诊id
* @param typeCode 申请单类型
@@ -44,6 +44,19 @@ public interface IRequestFormManageAppService {
*/
List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status);
/**
* 查询申请单(支持日期、状态和关键字筛选)
*
* @param encounterId 就诊id
* @param typeCode 申请单类型
* @param startDate 开始日期可选格式yyyy-MM-dd
* @param endDate 结束日期可选格式yyyy-MM-dd
* @param status 单据状态(可选)
* @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配)
* @return 申请单列表
*/
List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status, String keyword);
/**
* 分页查询申请单
*

View File

@@ -415,7 +415,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
@Override
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode) {
// 调用重载方法,不传筛选参数
return getRequestForm(encounterId, typeCode, null, null, null);
return getRequestForm(encounterId, typeCode, null, null, null, null);
}
/**
@@ -426,16 +426,17 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
* @param startDate 开始日期可选格式yyyy-MM-dd
* @param endDate 结束日期可选格式yyyy-MM-dd
* @param status 单据状态(可选)
* @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配)
* @return 申请单列表
*/
@Override
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status) {
public List<RequestFormQueryDto> getRequestForm(Long encounterId, String typeCode, String startDate, String endDate, String status, String keyword) {
// 检查参数
if (encounterId == null) {
return new java.util.ArrayList<>(); // 返回空列表而不是查询数据库
}
List<RequestFormQueryDto> requestFormList = requestFormManageAppMapper.getRequestForm(encounterId, typeCode, startDate, endDate, status);
List<RequestFormQueryDto> requestFormList = requestFormManageAppMapper.getRequestForm(encounterId, typeCode, startDate, endDate, status, keyword);
for (RequestFormQueryDto requestFormQueryDto : requestFormList) {
// 查询处方详情
List<RequestFormDetailQueryDto> requestFormDetail =

View File

@@ -84,6 +84,7 @@ public class RequestFormManageController {
* @param startDate 开始日期可选格式yyyy-MM-dd
* @param endDate 结束日期可选格式yyyy-MM-dd
* @param status 单据状态(可选)
* @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配)
* @return 检查申请单
*/
@GetMapping(value = "/get-check")
@@ -91,11 +92,12 @@ public class RequestFormManageController {
@RequestParam(required = false) Long encounterId,
@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate,
@RequestParam(required = false) String status) {
@RequestParam(required = false) String status,
@RequestParam(required = false) String keyword) {
if (encounterId == null) {
return R.fail("就诊ID不能为空");
}
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.TEST.getCode(), startDate, endDate, status));
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.TEST.getCode(), startDate, endDate, status, keyword));
}
/**

View File

@@ -37,13 +37,15 @@ public interface RequestFormManageAppMapper {
* @param startDate 开始日期可选格式yyyy-MM-dd
* @param endDate 结束日期可选格式yyyy-MM-dd
* @param status 单据状态(可选)
* @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配)
* @return 申请单列表
*/
List<RequestFormQueryDto> getRequestForm(@Param("encounterId") Long encounterId,
@Param("typeCode") String typeCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("status") String status);
@Param("status") String status,
@Param("keyword") String keyword);
/**
* 查询申请单详情

View File

@@ -31,6 +31,16 @@
<if test="status != null and status != ''">
AND drf.status = #{status}::integer
</if>
<if test="keyword != null and keyword != ''">
AND (drf.prescription_no LIKE CONCAT('%', #{keyword}, '%')
OR EXISTS (
SELECT 1 FROM wor_service_request wsr_kw
LEFT JOIN wor_activity_definition wad_kw ON wad_kw.id = wsr_kw.activity_id
WHERE wsr_kw.prescription_no = drf.prescription_no
AND wsr_kw.delete_flag = '0'
AND wad_kw.name LIKE CONCAT('%', #{keyword}, '%')
))
</if>
</select>
<select id="getRequestFormDetail" resultType="com.openhis.web.regdoctorstation.dto.RequestFormDetailQueryDto">

View File

@@ -175,10 +175,9 @@ const hasMatchedFields = computed(() => {
});
/** 查询科室 */
const getLocationInfo = () => {
getOrgList().then((res) => {
orgOptions.value = res.data.records;
});
const getLocationInfo = async () => {
const res = await getOrgList();
orgOptions.value = res.data.records;
};
const recursionFun = (targetDepartment) => {
@@ -199,7 +198,12 @@ const recursionFun = (targetDepartment) => {
return name;
};
const handleViewDetail = (row) => {
const handleViewDetail = async (row) => {
// 确保科室数据已加载,以便将 ID 解析为名称
if (!orgOptions.value || orgOptions.value.length === 0) {
await getLocationInfo();
}
currentDetail.value = row;
// 解析 descJson
if (row.descJson) {
@@ -220,10 +224,9 @@ const handleViewDetail = (row) => {
watch(
() => patientInfo.value?.encounterId,
(val) => {
async (val) => {
if (val) {
fetchData();
getLocationInfo();
await Promise.all([fetchData(), getLocationInfo()]);
} else {
tableData.value = [];
}

View File

@@ -496,10 +496,9 @@ const hasMatchedFields = computed(() => {
});
/** 查询科室 */
const getLocationInfo = () => {
getOrgList().then((res) => {
orgOptions.value = res.data.records;
});
const getLocationInfo = async () => {
const res = await getOrgList();
orgOptions.value = res.data.records;
};
const recursionFun = (targetDepartment) => {
@@ -527,9 +526,14 @@ const recursionFun = (targetDepartment) => {
return name;
};
const handleViewDetail = (row) => {
const handleViewDetail = async (row) => {
console.log('targetDepartment========>', JSON.stringify(row));
// 确保科室数据已加载,以便将 ID 解析为名称
if (!orgOptions.value || orgOptions.value.length === 0) {
await getLocationInfo();
}
currentDetail.value = row;
// 解析 descJson
if (row.descJson) {
@@ -780,10 +784,9 @@ const handleViewReport = async (row) => {
watch(
() => patientInfo.value?.encounterId,
(val) => {
async (val) => {
if (val) {
fetchData();
getLocationInfo();
await Promise.all([fetchData(), getLocationInfo()]);
} else {
tableData.value = [];
filterForm.value.dateRange = getDefaultDateRange();

View File

@@ -181,10 +181,9 @@ const hasMatchedFields = computed(() => {
});
/** 查询科室 */
const getLocationInfo = () => {
getOrgList().then((res) => {
orgOptions.value = res.data.records;
});
const getLocationInfo = async () => {
const res = await getOrgList();
orgOptions.value = res.data.records;
};
const recursionFun = (targetDepartment) => {
@@ -205,7 +204,12 @@ const recursionFun = (targetDepartment) => {
return name;
};
const handleViewDetail = (row) => {
const handleViewDetail = async (row) => {
// 确保科室数据已加载,以便将 ID 解析为名称
if (!orgOptions.value || orgOptions.value.length === 0) {
await getLocationInfo();
}
currentDetail.value = row;
// 解析 descJson
if (row.descJson) {
@@ -226,10 +230,9 @@ const handleViewDetail = (row) => {
watch(
() => patientInfo.value?.encounterId,
(val) => {
async (val) => {
if (val) {
fetchData();
getLocationInfo();
await Promise.all([fetchData(), getLocationInfo()]);
} else {
tableData.value = [];
}

View File

@@ -47,6 +47,15 @@
<el-option label="已作废" value="5" />
</el-select>
</el-form-item>
<el-form-item label="关键字">
<el-input
v-model="filterForm.keyword"
placeholder="申请单号/检验项目"
clearable
style="width: 200px"
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch" :loading="loading">
<el-icon><Search /></el-icon>
@@ -188,6 +197,7 @@ const orgOptions = ref([]);
const filterForm = ref({
dateRange: [], // [startDate, endDate]
status: '', // 单据状态
keyword: '', // 关键字搜索
});
const fetchData = async () => {
@@ -211,7 +221,12 @@ const fetchData = async () => {
if (filterForm.value.status !== '' && filterForm.value.status !== undefined) {
params.status = filterForm.value.status;
}
// 添加关键字搜索
if (filterForm.value.keyword && filterForm.value.keyword.trim()) {
params.keyword = filterForm.value.keyword.trim();
}
const res = await getInspection(params);
if (res.code === 200 && res.data) {
const raw = res.data?.records || res.data;
@@ -251,6 +266,7 @@ const handleReset = () => {
// 重置筛选条件为默认值
filterForm.value.dateRange = [];
filterForm.value.status = '';
filterForm.value.keyword = '';
// 重新加载数据
fetchData();
};
@@ -331,10 +347,9 @@ const hasMatchedFields = computed(() => {
});
/** 查询科室 */
const getLocationInfo = () => {
getDepartmentList().then((res) => {
orgOptions.value = res.data || [];
});
const getLocationInfo = async () => {
const res = await getDepartmentList();
orgOptions.value = res.data || [];
};
const recursionFun = (targetDepartment) => {
@@ -357,7 +372,12 @@ const recursionFun = (targetDepartment) => {
return name;
};
const handleViewDetail = (row) => {
const handleViewDetail = async (row) => {
// 确保科室数据已加载,以便将 ID 解析为名称
if (!orgOptions.value || orgOptions.value.length === 0) {
await getLocationInfo();
}
currentDetail.value = row;
// 解析 descJson
if (row.descJson) {
@@ -378,13 +398,13 @@ const handleViewDetail = (row) => {
watch(
() => patientInfo.value?.encounterId,
(val) => {
async (val) => {
if (val) {
// 设置默认日期范围为近7天
const today = new Date();
const sevenDaysAgo = new Date(today);
sevenDaysAgo.setDate(today.getDate() - 6); // 包含今天共7天
// 格式化为 YYYY-MM-DD
const formatDate = (date) => {
const year = date.getFullYear();
@@ -392,19 +412,19 @@ watch(
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};
filterForm.value.dateRange = [
formatDate(sevenDaysAgo),
formatDate(today)
];
fetchData();
getLocationInfo();
await Promise.all([fetchData(), getLocationInfo()]);
} else {
tableData.value = [];
// 重置筛选条件
filterForm.value.dateRange = [];
filterForm.value.status = '';
filterForm.value.keyword = '';
}
},
{ immediate: true }