2025-11-03 16:50:34 +08:00
|
|
|
|
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
|
|
|
|
import { useEffect, useState } from "react";
|
2025-11-06 14:31:25 +08:00
|
|
|
|
import BasicSelectTree from "../../Basic";
|
2025-11-03 16:50:34 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-06 14:31:25 +08:00
|
|
|
|
* 部门下拉树组件(港务局版本)
|
2025-11-03 16:50:34 +08:00
|
|
|
|
*/
|
|
|
|
|
|
function DepartmentSelectTree(props) {
|
|
|
|
|
|
const {
|
|
|
|
|
|
params = {},
|
2025-11-06 09:38:23 +08:00
|
|
|
|
placeholder = "部门",
|
|
|
|
|
|
isNeedCorpInfoId = false,
|
|
|
|
|
|
isNeedParentId = false,
|
2025-11-03 16:50:34 +08:00
|
|
|
|
...restProps
|
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
2025-11-04 17:41:15 +08:00
|
|
|
|
const [treeData, setTreeData] = useState([]);
|
2025-11-03 16:50:34 +08:00
|
|
|
|
|
|
|
|
|
|
const getData = async () => {
|
2025-11-06 09:38:23 +08:00
|
|
|
|
setTreeData([]);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据参数决定是否发送请求
|
|
|
|
|
|
if (isNeedCorpInfoId && !params.eqCorpinfoId)
|
|
|
|
|
|
return;
|
|
|
|
|
|
if (isNeedParentId && !params.eqParentId)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2025-11-03 16:50:34 +08:00
|
|
|
|
const { data } = await request("/basic-info/department/listTree", "post", params);
|
|
|
|
|
|
setTreeData(data);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
getData();
|
2025-11-06 09:38:23 +08:00
|
|
|
|
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]);
|
2025-11-03 16:50:34 +08:00
|
|
|
|
|
|
|
|
|
|
return (
|
2025-11-06 14:31:25 +08:00
|
|
|
|
<BasicSelectTree treeData={treeData} placeholder={placeholder} {...restProps} />
|
2025-11-03 16:50:34 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DepartmentSelectTree.displayName = "DepartmentSelectTree";
|
|
|
|
|
|
|
|
|
|
|
|
export default DepartmentSelectTree;
|