优化DepartmentLeftTree
parent
4aa92f7414
commit
e7f1c5329d
|
|
@ -9,6 +9,10 @@ export interface Params {
|
||||||
eqCorpinfoId?: string;
|
eqCorpinfoId?: string;
|
||||||
/** 父级部门id */
|
/** 父级部门id */
|
||||||
eqParentId?: string;
|
eqParentId?: string;
|
||||||
|
/** 企业类型 */
|
||||||
|
inType?: number[];
|
||||||
|
/** 企业类型 */
|
||||||
|
enterpriseType?: number[] | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,6 +21,8 @@ export interface Params {
|
||||||
export interface DepartmentLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey"> {
|
export interface DepartmentLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey"> {
|
||||||
/** 请求参数 */
|
/** 请求参数 */
|
||||||
params?: Params;
|
params?: Params;
|
||||||
|
/** 查询的企业类型,默认current,current 接收 eqCorpinfoId 或者 eqParentId,all 不接受任何参数,inType 接收 inType 或者 enterpriseType */
|
||||||
|
searchType?: "current" | "all" | "inType";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,37 @@ import BasicLeftTree from "../../Basic";
|
||||||
function DepartmentLeftTree(props) {
|
function DepartmentLeftTree(props) {
|
||||||
const {
|
const {
|
||||||
params = {},
|
params = {},
|
||||||
|
searchType = "current",
|
||||||
...restProps
|
...restProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [treeData, setTreeData] = useState([]);
|
const [treeData, setTreeData] = useState([]);
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const { data } = await request("/basicInfo/department/listTree", "post", params);
|
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);
|
setTreeData(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue