/**
 * 住院证
 */
import React from 'react'
import { message } from 'antd';
import { Util } from 'tools/index';
import AddHospitalization from './AddHospitalization';
import HospitalizationList from './HospitalizationList';
import '../style/index.less';

var recordData;
class HospitalizationCertificatePage extends React.Component {
    constructor(props) {
        recordData = JSON.parse(sessionStorage.getItem('patientData'));
        if (!recordData) {
            recordData = JSON.parse(sessionStorage.getItem('recordData'));
        }
        super(props);
        this.state = {
            editAdmin: {}, //当前编辑的住院证信息
            reload: false, //是否重新load列表数据
            editFlag: false,
            addchild: undefined,
            listchild: undefined,
        }
    }

    componentDidMount() {
        message.config({ top: 400, duration: 3 });
        if (Util.isEmpty(recordData.patID)) {
            message.warn("未选择患者信息");
        }
    }

    componentWillUnmount() {
        // 组件销毁前将静止让setState修改state的状态
        this.setState = (state, callback) => { return; }
    }

    onListRef = (ref) => {
        this.setState({
            listchild: ref,
        })
    }

    onAddRef = (ref) => {
        this.setState({
            addchild: ref,
        })
    }

    render() {
        return (
            <div style={{ background: '#F5F4F4', height: this.props.modal == "1" ? "70vh" : '100%', width: '100%', padding: '3px', overflow: 'hidden', }}>
                <div style={{ float: 'left', width: '50%', height: '100%', overflow: 'hidden', }}>
                    <AddHospitalization modal={this.props.modal} activeTab={this.props.activeTab} listchild={this.state.listchild} onRef={this.onAddRef} handlerThis={this} editFlag={this.state.editFlag} />
                </div>
                <div style={{ float: 'left', width: '50%', height: '100%', overflow: 'hidden', paddingLeft: '6px' }}>
                    <HospitalizationList modal={this.props.modal} addchild={this.state.addchild} onRef={this.onListRef} reload={this.state.reload} handlerThis={this} />
                </div>
            </div>

        )
    }
}

export default HospitalizationCertificatePage;