zy-react-library/components/SelectTree/Department/Gwj/index.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

import { request } from "@cqsjjb/jjb-common-lib/http";
import { useEffect, useState } from "react";
import BasicLeftTree from "../../Basic";
/**
2025-11-06 09:38:23 +08:00
* 基础下拉树组件港务局版本
*/
function DepartmentSelectTree(props) {
const {
params = {},
2025-11-06 09:38:23 +08:00
placeholder = "部门",
isNeedCorpInfoId = false,
isNeedParentId = false,
...restProps
} = props;
2025-11-04 17:41:15 +08:00
const [treeData, setTreeData] = useState([]);
const getData = async () => {
2025-11-06 09:38:23 +08:00
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();
2025-11-06 09:38:23 +08:00
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]);
return (
2025-11-06 09:38:23 +08:00
<BasicLeftTree treeData={treeData} placeholder={placeholder} {...restProps} />
);
}
DepartmentSelectTree.displayName = "DepartmentSelectTree";
export default DepartmentSelectTree;