diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue index fa675b9c8..94e1e7b70 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/examineApplication.vue @@ -309,49 +309,46 @@ 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) => { + if (!targetDepartment) return ''; let name = ''; for (let index = 0; index < orgOptions.value.length; index++) { const obj = orgOptions.value[index]; if (obj.id == targetDepartment) { name = obj.name; + break; } const subObjArray = obj['children']; if (subObjArray && subObjArray.length > 0) { - for (let index = 0; index < subObjArray.length; index++) { - const item = subObjArray[index]; + for (let i = 0; i < subObjArray.length; i++) { + const item = subObjArray[i]; if (item.id == targetDepartment) { name = item.name; + break; } } } + if (name) break; } return name; }; 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) { try { const obj = JSON.parse(row.descJson); - // 确保科室数据已加载 - if (!orgOptions.value || orgOptions.value.length === 0) { - await new Promise((resolve) => { - getDepartmentList().then((res) => { - orgOptions.value = res.data || []; - resolve(); - }); - }); - } obj.targetDepartment = recursionFun(obj.targetDepartment); descJsonData.value = obj; } catch (e) {