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;
/** 是否需要父级部门id默认 false */
isNeedParentId?: boolean;
/** 查询当前登陆人部门还是所有企业部门all 的话 isNeedCorpInfoId、isNeedParentId、params 不生效 */
searchType?: "current" | "all";
}
/**

View File

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