Fix Bug #510: [住院医生工作站] 进入页面报错

根因:order/index.vue 中 getList() 在模块顶层执行(非生命周期钩子),
组件导入时立即触发 API 调用,此时患者尚未选择导致 encounterId 为 undefined;
同时 getListInfo() 缺少患者选择守护检查,多处 API 以空参数调用后端引发循环报错。

修复:
1. 将 getList() 从模块顶层移至 onMounted() 生命周期钩子
2. 在 getListInfo() 开头添加 patientInfo.encounterId 守护检查
This commit is contained in:
关羽
2026-05-14 06:19:28 +08:00
committed by 荀彧
parent d3a04062dd
commit 6fa32c6116

View File

@@ -533,6 +533,7 @@ const statusOption = [
let loadingInstance = undefined;
onMounted(() => {
document.addEventListener('keydown', escKeyListener);
getList();
});
onBeforeUnmount(() => {
@@ -573,7 +574,6 @@ function handleTotalAmount() {
}
}, new Decimal(0));
}
getList();
function getList() {
getDiagnosisDefinitionList(queryParams.value).then((res) => {
// prescriptionList.value = res.data.records;
@@ -585,6 +585,11 @@ function refresh() {
}
// 获取列表信息
function getListInfo(addNewRow) {
// 守护:未选择患者时不发起 API 请求,避免页面加载时循环报错
if (!patientInfo.value || !patientInfo.value.encounterId) {
console.warn('⚠️ getListInfo 跳过:未选择患者');
return;
}
loadingInstance = ElLoading.service({ fullscreen: true });
setTimeout(() => {
loadingInstance.close();