优化部分功能

master
LiuJiaNan 2026-02-06 15:52:51 +08:00
parent b14a771cc9
commit 87bb9ed9eb
7 changed files with 30 additions and 23 deletions

View File

@ -18,6 +18,8 @@ function DictionaryCascader(props) {
const [treeData, setTreeData] = useState([]);
const getData = async () => {
setTreeData([]);
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
console.error(`【DictionaryCascader】 传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中,当前传入的 appKey 是 ${appKey}`);
return;
@ -28,13 +30,12 @@ function DictionaryCascader(props) {
return;
}
setTreeData([]);
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
setTreeData(data);
};
useEffect(() => {
dictValue && getData();
getData();
}, [dictValue]);
return (

View File

@ -18,6 +18,8 @@ function DictionaryLeftTree(props) {
const [treeData, setTreeData] = useState([]);
const getData = async () => {
setTreeData([]);
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
console.error(`【DictionaryLeftTree】 传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中,当前传入的 appKey 是 ${appKey}`);
return;
@ -28,13 +30,12 @@ function DictionaryLeftTree(props) {
return;
}
setTreeData([]);
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
setTreeData(data);
};
useEffect(() => {
dictValue && getData();
getData();
}, [dictValue]);
return (

View File

@ -18,6 +18,8 @@ function DictionarySelect(props) {
const [data, setData] = useState([]);
const getData = async () => {
setData([]);
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
console.error(`【DictionarySelect】 传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中,当前传入的 appKey 是 ${appKey}`);
return;
@ -28,13 +30,12 @@ function DictionarySelect(props) {
return;
}
setData([]);
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
setData(data);
};
useEffect(() => {
dictValue && getData();
getData();
}, [dictValue]);
return (

View File

@ -27,6 +27,21 @@ function PersonnelSelect(props) {
const [data, setData] = useState([]);
const getData = async () => {
setData([]);
if (!isNeedCorpInfoId && !isNeedDepartmentId && !isNeedPostId) {
console.error("【PersonnelSelect】 请至少传入一个参数");
return;
}
// 根据参数决定是否发送请求
if (isNeedCorpInfoId && (!params.corpinfoId || typeof params.corpinfoId !== 'string'))
return;
if (isNeedDepartmentId && (!params.departmentId || typeof params.departmentId !== 'string'))
return;
if (isNeedPostId && (!params.postId || typeof params.postId !== 'string'))
return;
const actualExtraParams = { ...defaultExtraParams, ...extraParams };
// 生成缓存键
@ -38,19 +53,6 @@ function PersonnelSelect(props) {
return;
}
setData([]);
// 根据参数决定是否发送请求
if (isNeedCorpInfoId && !params.corpinfoId)
return;
if (isNeedDepartmentId && !params.departmentId)
return;
if (isNeedPostId && !params.postId)
return;
if (!isNeedCorpInfoId && !isNeedDepartmentId && !isNeedPostId) {
console.error("【PersonnelSelect】 请至少传入一个参数");
return;
}
const { data } = await request("/basicInfo/user/listAll", "get", { ...params, ...actualExtraParams, time: new Date().getTime() });
// 存入缓存

View File

@ -21,6 +21,8 @@ function DepartmentSelectTree(props) {
const [treeData, setTreeData] = useState([]);
const getData = async () => {
setTreeData([]);
// 生成缓存键
const paramsStr = JSON.stringify(params);
const cacheKey = `${searchType}_${paramsStr}`;
@ -31,8 +33,6 @@ function DepartmentSelectTree(props) {
return;
}
setTreeData([]);
if (searchType === "current") {
if (isNeedCorpInfoId && !params.eqCorpinfoId)
return;

View File

@ -18,6 +18,8 @@ function DictionarySelectTree(props) {
const [treeData, setTreeData] = useState([]);
const getData = async () => {
setTreeData([]);
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
console.error(`【DictionarySelectTree】 传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中,当前传入的 appKey 是 ${appKey}`);
return;
@ -28,13 +30,12 @@ function DictionarySelectTree(props) {
return;
}
setTreeData([]);
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
setTreeData(data);
};
useEffect(() => {
dictValue && getData();
getData();
}, [dictValue]);
return (

View File

@ -53,6 +53,7 @@ function HiddenLevelSelectTree(props) {
const getData = async () => {
setTreeData([]);
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey: DICTIONARY_APP_KEY_ENUM.GWJ, dictValue: "hiddenLevel" });
const filterData = filterTreeData(data);
setTreeData(filterData);