import React, { Component } from "react";
import { Modal, Tree, Input, Icon, Select } from "antd";
import "./index.less";
import { getTreeperBydepart } from "../../services/api";
const { TreeNode } = Tree;
const { Search } = Input;
const { Option } = Select;
const children = [];
class PartmentSelect extends Component {
constructor(props, context) {
super(props, context);
this.state = {
checkable: this.props.checkable || true,
treeData: [],
checkedkeys: [],
visible: true,
searchValue: "",
autoExpandParent: true,
expandedKeys: ["0-0-0", "0-0-1"],
checkedKeys: ["0-0-0"],
selectedKeys: []
};
}
componentDidMount() {
getTreeperBydepart({}).then(
response => {
this.setState({ treeData: response.data });
},
err => {
console.log(err, "getTreeperBydepart-err");
}
);
}
onChange = e => {
const { value } = e.target;
this.setState({
expandedKeys,
searchValue: value,
autoExpandParent: true
});
};
onExpand = expandedKeys => {
this.setState({
expandedKeys,
autoExpandParent: false
});
};
onCheck = (checkedKeys, e) => {
this.setState({ checkedKeys });
};
handleCancel = e => {
this.setState({
visible: false
});
};
handleOk = e => {
this.setState({
visible: false
});
this.props.onCheck(this.state.checkedkeys);
};
showModal = e => {
const targetClass = e.target.className;
if (
targetClass === "ant-select-selection__rendered" ||
targetClass === "ant-select-selection__placeholder" ||
targetClass.indexOf("ant-select-selection--multiple") !== -1
) {
this.setState({ visible: true });
}
/* this.setState({
visible: true,
}); */
};
renderTreeNodes = () => {
return this.state.treeData.map(item => {
if (item.children) {
return (