优化PersonnelSelect

master
LiuJiaNan 2026-01-27 15:49:52 +08:00
parent c5d3c28470
commit fd2cf41c5f
1 changed files with 10 additions and 6 deletions

View File

@ -15,18 +15,22 @@ function PersonnelSelect(props) {
isNeedCorpInfoId = false,
isNeedDepartmentId = true,
isNeedPostId = false,
extraParams = {
noMain: "",
eqEmploymentFlag: 1,
},
extraParams = {},
...restProps
} = props;
const defaultExtraParams = {
noMain: "",
eqEmploymentFlag: 1,
};
const [data, setData] = useState([]);
const getData = async () => {
const actualExtraParams = { ...defaultExtraParams, ...extraParams };
// 生成缓存键
const cacheKey = JSON.stringify({ params, extraParams });
const cacheKey = JSON.stringify({ params, extraParams: actualExtraParams });
// 检查缓存,如果存在直接返回缓存结果
if (cacheMap.has(cacheKey)) {
@ -47,7 +51,7 @@ function PersonnelSelect(props) {
return;
}
const { data } = await request("/basicInfo/user/listAll", "get", { ...params, ...extraParams, time: new Date().getTime() });
const { data } = await request("/basicInfo/user/listAll", "get", { ...params, ...actualExtraParams, time: new Date().getTime() });
// 存入缓存
cacheMap.set(cacheKey, data);