DepartmentSelectTree新增查询所有企业部门
parent
dee87f2e6d
commit
822ea88f64
|
|
@ -14,6 +14,8 @@ export interface DepartmentSelectTreeProps extends Omit<BasicSelectTreeProps, "t
|
|||
isNeedCorpInfoId?: boolean;
|
||||
/** 是否需要父级部门id,默认 false */
|
||||
isNeedParentId?: boolean;
|
||||
/** 查询当前登陆人部门还是所有企业部门,all 的话 isNeedCorpInfoId、isNeedParentId、params 不生效 */
|
||||
searchType?: "current" | "all";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 (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} />
|
||||
|
|
|
|||
Loading…
Reference in New Issue