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:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user