DepartmentSelectTree新增查询所有企业部门

master
LiuJiaNan 2025-11-19 17:38:56 +08:00
parent dee87f2e6d
commit 822ea88f64
2 changed files with 12 additions and 7 deletions

View File

@ -14,6 +14,8 @@ export interface DepartmentSelectTreeProps extends Omit<BasicSelectTreeProps, "t
isNeedCorpInfoId?: boolean; isNeedCorpInfoId?: boolean;
/** 是否需要父级部门id默认 false */ /** 是否需要父级部门id默认 false */
isNeedParentId?: boolean; isNeedParentId?: boolean;
/** 查询当前登陆人部门还是所有企业部门all 的话 isNeedCorpInfoId、isNeedParentId、params 不生效 */
searchType?: "current" | "all";
} }
/** /**

View File

@ -11,6 +11,7 @@ function DepartmentSelectTree(props) {
placeholder = "部门", placeholder = "部门",
isNeedCorpInfoId = false, isNeedCorpInfoId = false,
isNeedParentId = false, isNeedParentId = false,
searchType = "current",
...restProps ...restProps
} = props; } = props;
@ -19,19 +20,21 @@ function DepartmentSelectTree(props) {
const getData = async () => { const getData = async () => {
setTreeData([]); setTreeData([]);
if (searchType === "all") {
// 根据参数决定是否发送请求 // 根据参数决定是否发送请求
if (isNeedCorpInfoId && !params.eqCorpinfoId) if (isNeedCorpInfoId && !params.eqCorpinfoId)
return; return;
if (isNeedParentId && !params.eqParentId) if (isNeedParentId && !params.eqParentId)
return; return;
}
const { data } = await request("/basic-info/department/listTree", "post", params); const { data } = await request(searchType === "current" ? "/basic-info/department/listTree" : "/basic-info/department/listAllTree", "post", params);
setTreeData(data); setTreeData(data);
}; };
useEffect(() => { useEffect(() => {
getData(); getData();
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]); }, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId, searchType]);
return ( return (
<BasicSelectTree treeData={treeData} placeholder={placeholder} childrenKey="childrenList" {...restProps} /> <BasicSelectTree treeData={treeData} placeholder={placeholder} childrenKey="childrenList" {...restProps} />