Fix Bug #470: 住院医生工作站-手术申请单加载手术项目耗时过长,影响医生开单效率
添加模块级缓存(surgeryRecordsCache + surgeryMappedCache),首次打开弹窗请求API后 缓存数据,后续打开直接复用,避免重复请求500条手术项目列表导致加载缓慢。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,9 @@ import {getApplicationList, saveSurgery} from './api';
|
||||
import {ElMessage} from 'element-plus';
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
// 模块级缓存:避免每次打开弹窗都重新请求手术项目列表
|
||||
let surgeryRecordsCache = null; // 原始 API 记录
|
||||
let surgeryMappedCache = null; // 映射后的 el-transfer 数据
|
||||
// 递归查找树形科室节点
|
||||
const findTreeItem = (list, id) => {
|
||||
if (!list || list.length === 0) return null;
|
||||
@@ -110,6 +113,12 @@ const getList = () => {
|
||||
applicationList.value = [];
|
||||
return;
|
||||
}
|
||||
// 命中缓存时直接使用,避免重复请求导致加载缓慢
|
||||
if (surgeryMappedCache && surgeryMappedCache.length > 0) {
|
||||
applicationList.value = surgeryMappedCache;
|
||||
applicationListAll.value = surgeryRecordsCache;
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
getApplicationList({
|
||||
pageSize: 500,
|
||||
@@ -132,6 +141,9 @@ const getList = () => {
|
||||
key: item.adviceDefinitionId,
|
||||
};
|
||||
});
|
||||
// 写入模块缓存,后续打开弹窗直接复用
|
||||
surgeryRecordsCache = res.data.records;
|
||||
surgeryMappedCache = applicationList.value;
|
||||
} else {
|
||||
console.warn('获取手术项目列表失败:', res.message);
|
||||
applicationList.value = [];
|
||||
|
||||
Reference in New Issue
Block a user