// 手术申请
import React, { Component } from 'react';
import { Row, Col, Table, Select, Button, Divider, message, Checkbox, Input, Icon, Tooltip, TimePicker } from 'antd';
import { $http } from '../../../containers/config/https';
import moment from 'moment';
import { Util } from 'tools/index';
import DoctorDiag from './DoctorDiag.jsx'
import OutpatientStationTabs from 'pages/workstation/OutPatientStationTabs';
import store from 'store';
import asyncComponent from '../../../routers/AsyncComponent.js';
import './style/OperationSearch.less';
import Apply from './Apply.jsx'

export default class ApplicationList extends Component {
    constructor(props) {
        super(props);
        this.ComponentName = "";
        var patientData = window.sessionStorage.patientData ? JSON.parse(window.sessionStorage.patientData) : {};
        this.state = {
            leftspan: 5,
            rightspan: 19,
            patient: "",
            admID: "",
            patID: "",
            patientData: patientData,
            iconType: "double-left",
        }

    }
    //组件渲染完成前触发事件
    componentWillMount() {
        if (this.props.location) {
            if (this.props.location.state.ComponentName) {
                this.ComponentName = this.props.location.state.ComponentName ? this.props.location.state.ComponentName : "";
            }
        } else {
            this.ComponentName = this.props.paras.ComponentName ? this.props.paras.ComponentName : "";
        }
        if (this.ComponentName === "") return
    }
    onBtnClick = () => {
        this.setState({
            leftspan: 5 - this.state.leftspan,
        });
    }

    updateState = (state) => {
        this.setState(state);
    }
    onClose = () => {
        this.setState({
            visible: true,
        });
    }
    onRef = (ref) => {
        this.child = ref;
    }
    render() {
       //console.log(this.ComponentName)
       const Component = asyncComponent(() => import( ''+ this.ComponentName ));
        return (
            <div style={{ height: "100%" }} className="operationSearch">
                <Row style={{ border: "2px solid #cccccc", height: "100%", width: "100%", overflowY: "hidden" }}>
                    <Col className={this.state.iconType == "double-left" ? "" : "visibleIcon"} span={this.state.leftspan}
                        style={{ border: this.state.iconType == "double-left" ? "1px solid #cccccc" : "0px", height: "100%", overflowY: 'hidden', background: '#ffffff', boxSizing: 'border-box' }}>
                        <Component child={this.child}  updateState={this.updateState} iconType={this.state.iconType} />
                    </Col>
                    <Col span={this.state.rightspan} style={{ height: '100%' }}>
                        <OutpatientStationTabs
                            iconType={this.state.iconType}
                            patient={this.state.patient}
                            updateState={this.updateState}
                            admID={this.state.admID}
                            onRef={this.onRef}
                        />
                    </Col>
                </Row>

            </div>
        )
    }



}