/**
 * 生命体征明细
 */
import React from 'react'
import PatientList from '../Patient/PatientList';
import PatientInfo from '../Patient/PatientInfo';
import {
    Row, Col, Divider, Button, DatePicker, message, Table, Input, Select, Tag, Switch
} from 'antd';
import { $http } from '../../../containers/config/https';
import store from '../../../store';
import Moment from 'moment';
import PubilcTablePagination from '../../common/PubilcTablePagination.jsx'; // 公共table组件
import fetchJsonp from 'fetch-jsonp';
import { temperature } from 'tools/index';
import VitalSignsDetailComponent from './VitalSignsDetailComponent'

import './CSS/VitalSigns.less';
class VitalSignsDetail extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            patient: [],
            stDate: "",
            endDate: "",
            column: [],
            dataSource: [],
            clickCol: "",
            saveData: {},
            errorList: [],
            toDay: "",
            total: 0,
            page: 1,
            pageSize: 14,
            needFlag: false,
            iconType: "double-left",
            leftspan: 5,
            rightspan: 19,
            header0ffHeight: 0,
        }
    }
    componentDidMount() {
        message.config({ top: 400, duration: 3 }); 
        var box = document.querySelector(".VitalSignsSingle colors");
		if(box){ //此处在加一层判断，更加严密，如果box存在的情况下获取
			this.setState({header0ffHeight: box.offsetHeight})
		}
    }
    componentWillUnmount() {
        this.setState = (state, callback) => {
            return
        }
    }
    //更新组件状态,提供给子组件
    updateState = (state) => {
        this.setState(state, () => { 
            this.detailComponentRef.updateState(state)
        });
    }
    onRef=(ref)=>{ 
        this.detailComponentRef=ref;
    }
         
    render() { 
        const columns = this.state.column.map((col, colIndex) => {
            return {
                ...col,
                render: this.renderColItem.bind(this, col, colIndex),
                onCell: this.onCell.bind(this, colIndex),
            };
        }); 
         
        return (
            <div style={{ width: '100%', height: '100%', overflowY: 'hidden' }} className="VitalSignsSingle colors">
                <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' }}>
                    <PatientList updateState={this.updateState} iconType={this.state.iconType} type="radio" />
                </Col>
                <Col span={this.state.rightspan} style={{ height: '100%' }} >
                    <Row style={{ width: '100%', height: '36px', lineHeight: '36px', textAlign: "left" }}>
                        <PatientInfo admID={this.state.patient.length === 0 ? sessionStorage.admID : this.state.patient[0]} />
                    </Row>
                    <Divider />
                    <div style={{ width: '100%', height: 'calc(100% - 45px)'}}>
                        <VitalSignsDetailComponent onRef={this.onRef} header0ffHeight={this.state.header0ffHeight} /> 
                    </div>
                </Col>
            </div>
        )
    }

}
export default VitalSignsDetail;