/**
 * 诊间预约
 */
import React from 'react'
import {
    Card, message
} from 'antd';
import { $http } from 'containers/config/https';
import ClinicTemplate from './ClinicTemplate';
import AppointmentList from './AppointmentList';
import { Util, dayFormat } from 'tools/index';
import moment from 'moment';
import '../style/index.less';
var recordData;
class Appointment extends React.Component {
    constructor(props) {
        recordData = JSON.parse(sessionStorage.getItem('patientData'));
        if (!recordData) {
            recordData = JSON.parse(sessionStorage.getItem('recordData'));
        }
        super(props);
        this.state = {
            date: "",
            resDetailID: "",
            selectTimeRange: "无",
            reload: false,
        }
    }
    componentDidMount() {
        message.config({ top: 400, duration: 3 });
        if (Util.isEmpty(recordData.patID)) {
            message.warn("未选择患者信息");
        }
    }
    componentWillUnmount() {
        // 组件销毁前将静止让setState修改state的状态
        this.setState = (state, callback) => { return; }
    }
    onLeftRef = (ref) => {
        this.left = ref;
    }
    onRightRef = (ref) => {
        this.right = ref;
    }
    render() {
        return (
            <div className="appointment" style={{ height: this.props.modal == "1" ? "70vh" : '100%', width: '100%', padding: '3px', overflow: 'hidden', }}>
                <div style={{ float: 'left', width: '55%', height: '100%', overflow: 'hidden', }}>
                    <ClinicTemplate
                        hanlderThis={this}
                        onLeftRef={this.onLeftRef}
                        right={this.right}
                        modal={this.props.modal} />
                </div>
                <div style={{ float: 'left', width: '45%', height: '100%', overflow: 'hidden', paddingLeft: '6px', background: 'rgba(246,246,246,1)' }}>
                    <AppointmentList hanlderThis={this}
                        selectTimeRange={this.state.selectTimeRange}
                        resDetailID={this.state.resDetailID}
                        reload={this.state.reload}
                        date={this.state.date}
                        onRightRef={this.onRightRef}
                        left={this.left}
                        modal={this.props.modal}
                    />
                </div>
            </div>
        )
    }
}
export default Appointment;