44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
import { useEffect, useState } from "react";
|
|
import BasicLeftTree from "../../Basic";
|
|
|
|
/**
|
|
* 基础下拉树组件(港务局版本)
|
|
*/
|
|
function DepartmentSelectTree(props) {
|
|
const {
|
|
params = {},
|
|
placeholder = "部门",
|
|
isNeedCorpInfoId = false,
|
|
isNeedParentId = false,
|
|
...restProps
|
|
} = props;
|
|
|
|
const [treeData, setTreeData] = useState([]);
|
|
|
|
const getData = async () => {
|
|
setTreeData([]);
|
|
|
|
// 根据参数决定是否发送请求
|
|
if (isNeedCorpInfoId && !params.eqCorpinfoId)
|
|
return;
|
|
if (isNeedParentId && !params.eqParentId)
|
|
return;
|
|
|
|
const { data } = await request("/basic-info/department/listTree", "post", params);
|
|
setTreeData(data);
|
|
};
|
|
|
|
useEffect(() => {
|
|
getData();
|
|
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]);
|
|
|
|
return (
|
|
<BasicLeftTree treeData={treeData} placeholder={placeholder} {...restProps} />
|
|
);
|
|
}
|
|
|
|
DepartmentSelectTree.displayName = "DepartmentSelectTree";
|
|
|
|
export default DepartmentSelectTree;
|