zy-react-library/src/components/LeftTree/Department/Gwj/index.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

2026-01-06 15:24:18 +08:00
import { request } from "@cqsjjb/jjb-common-lib/http.js";
import { useEffect, useState } from "react";
import BasicLeftTree from "../../Basic";
/**
* 部门左侧树组件港务局版本
*/
function DepartmentLeftTree(props) {
const {
params = {},
2026-01-26 14:50:23 +08:00
searchType = "current",
...restProps
} = props;
const [treeData, setTreeData] = useState([]);
const getData = async () => {
2026-01-26 14:50:23 +08:00
let requestUrl = "";
const actualParams = { ...params, time: new Date().getTime() };
if (searchType === "current") {
requestUrl = "/basicInfo/department/listTree";
actualParams.inType = undefined;
actualParams.enterpriseType = undefined;
}
if (searchType === "all") {
requestUrl = "/basicInfo/department/listAllTree";
actualParams.inType = undefined;
actualParams.enterpriseType = undefined;
actualParams.eqCorpinfoId = undefined;
actualParams.eqParentId = undefined;
}
if (searchType === "inType") {
requestUrl = "/basicInfo/department/listAllTreeByCorpType";
actualParams.eqCorpinfoId = undefined;
actualParams.eqParentId = undefined;
if (actualParams.enterpriseType && !Array.isArray(actualParams.enterpriseType)) {
actualParams.enterpriseType = [actualParams.enterpriseType];
}
}
const { data } = await request(requestUrl, "post", actualParams);
setTreeData(data);
};
useEffect(() => {
getData();
}, []);
return (
<BasicLeftTree treeData={treeData} childrenKey="childrenList" {...restProps} />
);
}
DepartmentLeftTree.displayName = "DepartmentLeftTree";
export default DepartmentLeftTree;