优化PersonnelSelect
parent
c5d3c28470
commit
fd2cf41c5f
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue