From 87bb9ed9eb622b5429493c58da37ca794394bbd7 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Fri, 6 Feb 2026 15:52:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Cascader/Dictionary/index.js | 5 ++-- src/components/LeftTree/Dictionary/index.js | 5 ++-- src/components/Select/Dictionary/index.js | 5 ++-- src/components/Select/Personnel/Gwj/index.js | 28 ++++++++++--------- .../SelectTree/Department/Gwj/index.js | 4 +-- src/components/SelectTree/Dictionary/index.js | 5 ++-- .../SelectTree/HiddenLevel/Gwj/index.js | 1 + 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/components/Cascader/Dictionary/index.js b/src/components/Cascader/Dictionary/index.js index 4c08580..5e982b0 100644 --- a/src/components/Cascader/Dictionary/index.js +++ b/src/components/Cascader/Dictionary/index.js @@ -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 ( diff --git a/src/components/LeftTree/Dictionary/index.js b/src/components/LeftTree/Dictionary/index.js index 111b348..2cc1088 100644 --- a/src/components/LeftTree/Dictionary/index.js +++ b/src/components/LeftTree/Dictionary/index.js @@ -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 ( diff --git a/src/components/Select/Dictionary/index.js b/src/components/Select/Dictionary/index.js index 6c20929..21b41b1 100644 --- a/src/components/Select/Dictionary/index.js +++ b/src/components/Select/Dictionary/index.js @@ -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 ( diff --git a/src/components/Select/Personnel/Gwj/index.js b/src/components/Select/Personnel/Gwj/index.js index 15a918e..e07b44d 100644 --- a/src/components/Select/Personnel/Gwj/index.js +++ b/src/components/Select/Personnel/Gwj/index.js @@ -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() }); // 存入缓存 diff --git a/src/components/SelectTree/Department/Gwj/index.js b/src/components/SelectTree/Department/Gwj/index.js index f33b180..068ac56 100644 --- a/src/components/SelectTree/Department/Gwj/index.js +++ b/src/components/SelectTree/Department/Gwj/index.js @@ -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; diff --git a/src/components/SelectTree/Dictionary/index.js b/src/components/SelectTree/Dictionary/index.js index cad6563..569d641 100644 --- a/src/components/SelectTree/Dictionary/index.js +++ b/src/components/SelectTree/Dictionary/index.js @@ -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 ( diff --git a/src/components/SelectTree/HiddenLevel/Gwj/index.js b/src/components/SelectTree/HiddenLevel/Gwj/index.js index 113d91e..e25ba0e 100644 --- a/src/components/SelectTree/HiddenLevel/Gwj/index.js +++ b/src/components/SelectTree/HiddenLevel/Gwj/index.js @@ -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);