import React, { Component } from "react"; import { Modal, Icon, message } from "antd"; import SelectUser from "../SelectUser"; import "./index.less"; /** 选择人员弹窗 */ class PartmentSelect extends Component { constructor(props, context) { super(props, context); this.state = { checkedkeys: this.props.value || [], // checkedkeys: [], visible: this.props.visible, arrayObj: [] }; } componentWillReceiveProps(nextprops) { this.setState({ visible: nextprops.visible // checkedkeys: nextprops.value || [] }); } handleCancel = () => { this.setState({ visible: false, checkedkeys: [], arrayObj:[] }); this.props.handleCancel(); }; handleOk = () => { if(this.state.checkedkeys.length === 0){ return message.error("请至少选择一个人员"); } this.setState({ visible: false }); this.props.onCheck( this.state.checkedkeys, this.state.arrayObj ); //之后初始化选择框的数据 this.setState({ checkedkeys: [], arrayObj:[] }); }; // 该函数貌似没什么作用 // showModal = e => { // const targetClass = e.target.className; // console.log(targetClass, e.target) // if ( // targetClass === "ant-select-selection__rendered" || // targetClass === "ant-select-selection__placeholder" || // targetClass.indexOf("ant-select-selection--multiple") !== -1 // ) { // this.setState({ visible: true }); // } // }; render() { let { arrayObj } = this.state; const selectedList = () => { return arrayObj.map((val, i) => { return (