优化PersonnelSelect
parent
c5d3c28470
commit
fd2cf41c5f
|
|
@ -15,18 +15,22 @@ function PersonnelSelect(props) {
|
||||||
isNeedCorpInfoId = false,
|
isNeedCorpInfoId = false,
|
||||||
isNeedDepartmentId = true,
|
isNeedDepartmentId = true,
|
||||||
isNeedPostId = false,
|
isNeedPostId = false,
|
||||||
extraParams = {
|
extraParams = {},
|
||||||
noMain: "",
|
|
||||||
eqEmploymentFlag: 1,
|
|
||||||
},
|
|
||||||
...restProps
|
...restProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const defaultExtraParams = {
|
||||||
|
noMain: "",
|
||||||
|
eqEmploymentFlag: 1,
|
||||||
|
};
|
||||||
|
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
|
const actualExtraParams = { ...defaultExtraParams, ...extraParams };
|
||||||
|
|
||||||
// 生成缓存键
|
// 生成缓存键
|
||||||
const cacheKey = JSON.stringify({ params, extraParams });
|
const cacheKey = JSON.stringify({ params, extraParams: actualExtraParams });
|
||||||
|
|
||||||
// 检查缓存,如果存在直接返回缓存结果
|
// 检查缓存,如果存在直接返回缓存结果
|
||||||
if (cacheMap.has(cacheKey)) {
|
if (cacheMap.has(cacheKey)) {
|
||||||
|
|
@ -47,7 +51,7 @@ function PersonnelSelect(props) {
|
||||||
return;
|
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);
|
cacheMap.set(cacheKey, data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue