/** 
 * Creator:     JYW
 * CreatDate:   2019-04-04
 * descripts：  转科记录组件
 * 
*/
import React from 'react';
import { Timeline, message, Row, Col, Divider, Icon } from 'antd';
import { $http } from '../../../containers/config/https';

import '../BedChart/CSS/bedchart.less'

const TimeItem = Timeline.Item;
class TransRecord extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            transRecord: [],
        }
    }
    componentWillReceiveProps(nextProps) {

        if (nextProps.admID !== "") {
            this.getTransRecord(nextProps.admID);
        }

    }
    getTransRecord = (admID) => {
        let data = {
            params: [{
                admID: admID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "04020009",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    this.setState({ transRecord: res.result });
                } else {
                    message.error('获取转移记录失败！' + e.errorMessage);
                }
            }
        })
    }
    render() {

        return (
            <Row className="transRecord">
                <Col className="transRecord title">转科记录</Col>

                <Col className="transRecord timeLine">
                    <Timeline mode="left">
                        {
                            this.state.transRecord.map(
                                (item, index) => {
                                    return (
                                        <TimeItem key={item.id}
                                            dot={
                                                <span>
                                                    <span style={{ fontSize: '14px', fontFamily: 'SourceHanSerifSC-ExtraLight', color: '#595959', paddingRight: '3px' }}>
                                                        {item.transTypeDesc}
                                                    </span>
                                                    {
                                                        index === (this.state.transRecord.length - 1) ?
                                                            <Icon type="swap-right" style={{ color: item.transTypeID === "0" ? "red" : (item.transTypeID === "1" ? "blue" : "green") }} />
                                                            :
                                                            <Icon type="swap" style={{ color: item.transTypeID === "0" ? "red" : (item.transTypeID === "1" ? "blue" : "green") }} />
                                                    }

                                                </span>}

                                        >
                                            <Row>
                                                <Col span={24} style={{ align: "center", fontSize: '14px' }}>
                                                    {item.transTypeID === "0" ? (item.inLocDesc + "→") : item.transTypeID === "1" ? item.inLocDesc + "→" + item.outLocDesc : item.inWardDesc + "→" + item.outWardDesc}
                                                </Col>
                                            </Row>
                                            <Row>
                                                <Col span={15} style={{ fontSize: '12px' }}>
                                                    {item.inDate}&nbsp;&nbsp;{item.inTime}
                                                </Col>
                                                <Col span={9} style={{ color: '#595959', fontSize: '13px' }}>
                                                    {item.inUserName}
                                                </Col>
                                            </Row>
                                        </TimeItem>
                                    );
                                }
                            )
                        }
                    </Timeline>
                </Col>
            </Row>
        );
    }
}
export default TransRecord;
