import React from 'react'
import {
    Form, message, Modal, Row, Col, Radio, Tabs, Select, DatePicker, Input, TimePicker, Button, Divider, Checkbox, Table
} from 'antd';
import asyncComponent from '../../routers/AsyncComponent.js';
import './CSS/message.less';
let userData = {}
const ExecuteMessage = Form.create()(
    class extends React.Component {
        constructor(props) {
            super(props);
            userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {};
            this.state = {
                visible: false,//弹框显示状
                activeKey: 'ExecuteMessage',
                handleComponent: '',
                eventCode: '',
            }
        }
        componentDidMount() {
            this.props.onRef(this);
        }

        showModal = (handleComponent, messageData) => {
            this.setState({
                messageID: messageData.id,
                otherInfo: messageData.otherInfo,
                visible: true,
                handleComponent: handleComponent,
                eventCode: messageData.eventCode,
            }, () => {

            });
        };

        close = (e) => {
            this.setState({
                visible: false,
            });
        };
        onRef = (ref) => {
            this.child = ref;
        }
        render() {
            const { eventCode } = this.state;
            const Component = asyncComponent(() => import('../../' + this.state.handleComponent));
            let content = "";
            switch (eventCode) {
                case "2001":
                case "2002":
                case "2003":
                case "2004":
                case "2005":
                case "2006":
                case "2007":
                case "2008":
                case "2009":
                case "2010":
                case "2011":
                case "2012":
                case "2013":
                    content = <Component handlerThis={this} onRef={this.onRef} />;
                    break;
                default: content = (
                    <Modal
                        className='executeMessage'
                        title="消息处理"
                        visible={this.state.visible}
                        onCancel={this.close}
                        footer={null}
                    >
                        {this.state.handleComponent != "" ? <Component handlerThis={this} onRef={this.onRef} /> : ""}
                    </Modal>)
            }
            return content;
        }
    }
)
export default ExecuteMessage