/*
* 待处理异常
* */

import React, { Component } from 'react';
import {
    Input, Form, Select, Modal, Button, Progress, Upload, message, Icon, Divider,
    Card, Row, Col, DatePicker, Popconfirm, Checkbox, Radio, Tooltip
} from 'antd';
import { Util, dayFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import RangeDatePicker from 'components/rangePicker/index';
import '../style/index.less';
import moment from 'moment';

const Option = Select.Option;
const Search = Input.Search;
const FormItem = Form.Item;
const { TextArea } = Input;

class ShowCommonInformationPage extends Component {

    constructor(props) {
        super(props);
        var date = new Date();
        var userData = JSON.parse(sessionStorage.getItem('userData'));
        var patID = JSON.parse(sessionStorage.getItem('patID'))
        this.state = {
            leftData: [],
            rightData: [],
            userData: userData,
            patID: patID
        }
    }
    componentWillReceiveProps(nextProp) {
        if (!Util.isEmpty(nextProp.patID) && nextProp.patID !== this.state.patID) {
            this.setState({
                patID: nextProp.patID
            }, () => {
                this.loadData()
            })
        }
    }

    componentDidMount() {
        this.props.onRef(this)
        this.loadData()
    }

    loadData() {
        var params = {
            params: [{
                patID: this.props.patID ? this.props.patID : this.state.patID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "03070028",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        titleData: res.result[0],
                    })
                }
            }
        });
    }

    render() {

        return <div className='common-information-body'>
            <div style={{ width: '100%', display: 'flex', float: 'left' }}>
                <div className={this.state.titleData && this.state.titleData.patSexCode == '1' ?
                    'splice-boy' : (this.state.titleData && this.state.titleData.patSexCode == '2' ? 'splice-girl' : 'splice-other')}></div>
                <div style={{ height: 79, borderRight: '1px solid #EEEEEE' }}></div>
                {!Util.isEmpty(this.state.titleData) ? <div>
                    <div style={{ padding: '0px 0 0 20px' }}>
                        <span style={{ color: '#333333', fontWeight: 'bold', cursor: 'pointer', fontSize: '16px' }}>
                            {this.state.titleData ? this.state.titleData.patName || '--' : '--'}</span><Divider type="vertical" />
                        <span>{this.state.titleData ? this.state.titleData.patSexDesc || '--' : '--'}</span><Divider type="vertical" />
                        <span>{this.state.titleData ? this.state.titleData.patAge || '--' : '--'}</span><Divider type="vertical" />
                        <span>{this.state.titleData ? this.state.titleData.patNo || '--' : '--'}</span><Divider type="vertical" />
                        <span>{this.state.titleData ? this.state.titleData.payType || '--' : '--'}</span><Divider type="vertical" />
                        <span>{this.state.titleData ? this.state.titleData.patMobile || '--' : '--'}</span>
                    </div>
                    <div style={{
                        fontWeight: 400, color: '#666666', padding: '5px 0 0 20px', width: '65vh', overflow: 'hidden',
                        textOverflow: 'ellipsis', whiteSpace: 'nowrap'
                    }}>
                        <Tooltip title={this.state.titleData ? this.state.titleData.presentAddress : ''}>
                            <span style={{ fontWeight: 'bold', color: '#333333' }}>现住址：{this.state.titleData ? this.state.titleData.presentAddress || '--' : '--'}</span>
                        </Tooltip>
                    </div>

                    <div style={{ fontWeight: 400, color: '#666666', padding: '5px 0 0 20px', display: 'flex' }}>
                        <div style={{ fontWeight: 'bold', color: '#333333' }}>签约医生：{this.state.titleData ? this.state.titleData.docDesc || '--' : '--'}</div>
                        {this.state.titleData && !Util.isEmpty(this.state.titleData.signing) ?
                            <div className='sign-style' style={{ background: '#f5222d' }}>签约</div> : null}

                        {this.state.titleData && !Util.isEmpty(this.state.titleData.hypertension) ?
                            <div className='signs-style' style={{ background: '#fa541c' }}>高</div> : null}

                        {this.state.titleData && !Util.isEmpty(this.state.titleData.diabetes) ?
                            <div className='signs-style' style={{ background: '#d4b106' }}>糖</div> : null}

                        {this.state.titleData && !Util.isEmpty(this.state.titleData.hyperlipoidemia) ?
                            <div className='signs-style' style={{ background: '#fa8c16' }}>脂</div> : null}
                    </div>
                </div> : <span style={{ color: '#999999', lineHeight: '79px', marginLeft: '20%' }}>{'暂无病人信息~'}</span>}
            </div>
        </div>
    }
}

export default Form.create()(ShowCommonInformationPage);