树形部门选择组件

This commit is contained in:
禺狨
2023-03-03 18:27:47 +08:00
parent 1491af0ccd
commit 426713b661
5 changed files with 229 additions and 111 deletions

View File

@@ -0,0 +1,37 @@
import { Button, Input, message, Tree } from "antd";
import { useState, useEffect } from "react";
import { department } from "../../api/index";
interface PropInterface {
defaultExpandedKeys: any;
defaultSelectedKeys: any;
defaultCheckedKeys: any;
onUpdate: () => void;
}
export const TreeDepartment = (props: PropInterface) => {
const [treeData, setTreeData] = useState<any>([]);
const [loading, setLoading] = useState<boolean>(true);
useEffect(() => {
setLoading(true);
department.departmentList().then((res: any) => {
setTreeData(res.data);
setTimeout(() => {
setLoading(false);
}, 1000);
});
}, []);
const onSelect = () => {};
const onCheck = () => {};
return (
<Tree
checkable
defaultExpandedKeys={props.defaultExpandedKeys}
defaultSelectedKeys={props.defaultSelectedKeys}
defaultCheckedKeys={props.defaultCheckedKeys}
onSelect={onSelect}
onCheck={onCheck}
treeData={treeData}
/>
);
};