// 需关注
import React from 'react';
import { Row, Col, Button } from 'antd';
import PatientList from '../Patient/PatientList';
import NeedAtentiontable from './NeedAtentiontable';
import PatientInfo from '../Patient/PatientInfo';
import './index.less';
import { Util } from 'tools/index';
import store from 'store';

export default class NeedAtention extends React.Component {
    constructor(props) {
        super(props);
        var patientData = JSON.parse(sessionStorage.getItem('patientData'))
        this.state = {
            leftspan: 5,
            rightspan: 19,
            patient: '',
            patientData: patientData,
            iconType: "double-left",
            patType: 'ward',
        }

    }
    componentDidMount() {

    }
    onBtnClick = () => {
        this.setState({
            leftspan: 5 - this.state.leftspan,
        });
    }
    onClose = () => {
        this.setState({
            visible: true,
        });
    }
    updateState = (patientObj) => {
        let admId = patientObj.patient;
        if (admId.length === 0) return
        this.setState({
            patient: admId[0],
        });
    }
    //点击按钮切换
    onChangeBtnClick = (patType) => {
        if (patType == "trans") {
            this.child.loadTransLoc();
        } else {
            this.child.getPatients();
        }
    }
    onRef = (ref) => {
        this.child = ref;
    }

    render() {
        const tableNeedHeight = store.getState().tableHeight.y - 160;
        let patient = this.state.patient;
        let patientData = sessionStorage.getItem('patientData');
        if ((!Util.isEmpty(patientData)) && (Util.isEmpty(patient))) {
            patientData = JSON.parse(patientData);
            patient = patientData.admID;
        }
        return (
            <div className='needAttion' style={{ border: "1px solid #dddddd", width: '100%', height: '100%', overflow: 'hidden' }}>
                <Col span={this.state.leftspan} style={{ border: this.state.iconType == "double-left" ? "1px solid #cccccc" : "0px", height: "100%", overflowY: 'hidden', background: '#ffffff', boxSizing: 'border-box' }}>
                    {/* <div style={{ height: '36px', width: '100%' }}>
                        <Button style={{ width: '50%', height: '36px' }} className={this.state.patType == "ward" ? "selectedBtn" : "unSelectedBtn"} onClick={this.onChangeBtnClick.bind(this, "ward")}>本病区本人</Button>
                        <Button style={{ width: '50%', height: '36px' }} className={this.state.patType == "trans" ? "selectedBtn" : "unSelectedBtn"} onClick={this.onChangeBtnClick.bind(this, "trans")}>转出未出院病人</Button>
                    </div> */}
                    <div style={{ height: 'calc(100% - 36px)', width: '100%' }}>
                        <PatientList onRef={this.onRef} heights={tableNeedHeight} patType={this.state.patType} type="radio" updateState={this.updateState} iconType={this.state.iconType} />
                    </div>
                </Col>
                <Col span={this.state.rightspan} style={{height:'100%'}}>
                    <Row style={{ border: "1px solid #cccccc", height: '45px', textAlign: 'left', lineHeight: '45px' }}>
                        <PatientInfo ref="PatientInfo" admID={patient} />
                    </Row>
                    <Row style={{ border: "1px solid #cccccc", height: "95%" }}>
                        <NeedAtentiontable
                            updateState={this.updateState}
                            patient={this.state.patient}
                            admID={patient}
                        />
                    </Row>
                </Col>
            </div>

        )
    }
}
