import React, {Component} from "react"; import {Menu, Dropdown, Icon, Input, Checkbox} from "antd"; import {getImageUrl} from 'educoder'; const {Search} = Input; class Dropdownbox extends Component { constructor(props) { super(props); this.state = { activeKey: '1', visible: false, onSearchvalue: undefined, checkedValues: [] } } componentDidMount() { let {group_ids} = this.props; if (group_ids) { this.setState({ checkedValues: group_ids }) } } componentDidUpdate = (prevProps) => { if (prevProps != this.props) { let {group_ids} = this.props; if (group_ids) { this.setState({ checkedValues: group_ids }) } } } SaveChange = () => { this.props.postwork_scoredata(this.state.checkedValues) } handleVisibleChange = flag => { this.setState({visible: flag}); }; CheckboxonChange = (checkedValues) => { this.setState({ checkedValues: checkedValues }) } unCheckboxonChange = () => { this.setState({ checkedValues: [], onSearchvalue: undefined }) } onSearch = (value) => { this.setState({ onSearchvalue: value }) } onSearchonChange = (e) => { this.setState({ onSearchvalue: e.target.value }) } render() { let {course_groups} = this.props; const menu = ( this.CheckboxonChange(checkedValues)}>
  • {course_groups && course_groups.length > 10 ? this.onSearch(value)} onChange={(e) => this.onSearchonChange(e)} value={this.state.onSearchvalue} style={{width: 200}} /> : ""}
  • {course_groups && course_groups.map((item, key) => { if (this.state.onSearchvalue) { if (item.name.indexOf(this.state.onSearchvalue) != -1) { return ( {item.name} ) } } else { return ( {item.name} ) } })}
  • this.SaveChange()} className={"ant-btn-link"}>确定 this.unCheckboxonChange()}>重置
  • ); return ( 分班 ) } } export default Dropdownbox;