Fix Bug #510: [住院医生工作站] 进入页面报错
根因:order/index.vue 中 getList() 在模块顶层执行(非生命周期钩子), 组件导入时立即触发 API 调用,此时患者尚未选择导致 encounterId 为 undefined; 同时 getListInfo() 缺少患者选择守护检查,多处 API 以空参数调用后端引发循环报错。 修复: 1. 将 getList() 从模块顶层移至 onMounted() 生命周期钩子 2. 在 getListInfo() 开头添加 patientInfo.encounterId 守护检查
This commit is contained in:
@@ -533,6 +533,7 @@ const statusOption = [
|
|||||||
let loadingInstance = undefined;
|
let loadingInstance = undefined;
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.addEventListener('keydown', escKeyListener);
|
document.addEventListener('keydown', escKeyListener);
|
||||||
|
getList();
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -573,7 +574,6 @@ function handleTotalAmount() {
|
|||||||
}
|
}
|
||||||
}, new Decimal(0));
|
}, new Decimal(0));
|
||||||
}
|
}
|
||||||
getList();
|
|
||||||
function getList() {
|
function getList() {
|
||||||
getDiagnosisDefinitionList(queryParams.value).then((res) => {
|
getDiagnosisDefinitionList(queryParams.value).then((res) => {
|
||||||
// prescriptionList.value = res.data.records;
|
// prescriptionList.value = res.data.records;
|
||||||
@@ -585,6 +585,11 @@ function refresh() {
|
|||||||
}
|
}
|
||||||
// 获取列表信息
|
// 获取列表信息
|
||||||
function getListInfo(addNewRow) {
|
function getListInfo(addNewRow) {
|
||||||
|
// 守护:未选择患者时不发起 API 请求,避免页面加载时循环报错
|
||||||
|
if (!patientInfo.value || !patientInfo.value.encounterId) {
|
||||||
|
console.warn('⚠️ getListInfo 跳过:未选择患者');
|
||||||
|
return;
|
||||||
|
}
|
||||||
loadingInstance = ElLoading.service({ fullscreen: true });
|
loadingInstance = ElLoading.service({ fullscreen: true });
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user