/**
 * 处理医嘱清单
 */
import React from 'react';
import { Modal, Row, Col, Select, DatePicker, TimePicker } from 'antd';
import { Util, dayFormat, timeFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import '../style/index.less';
import moment from 'moment';

class ShowExecListModal extends React.Component {

    constructor(props) {
        super(props);
        var userData = JSON.parse(sessionStorage.getItem('userData'));
        this.state = {
            userData: userData,
        }
    }
    componentWillReceiveProps(nextProp) {
        if (nextProp.isShow === true) {
            this.loadDateTime()
        } else if (this.props.isShow === false) {

        }
    }

    loadDateTime() {
        var params = {
            params: [{}]
        }
        $http.post('urlS', this, {
            code: '04030004',
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        dateFrom: res.date,
                        timeFrom: res.time,
                    })
                }
            }
        })
    }


    closeModal(name) {
        let { onHide } = this.props;
        onHide && onHide();
    }

    changeDate(e) {
        this.setState({
            dateFrom: e ? moment(e).format(dayFormat) : ''
        })
    }

    changeTime(e,time) {
        this.setState({
            timeFrom: time
        })
    }

    onSubmit() {
        var { dateFrom, timeFrom, type } = this.state;
        var { onSubmit } = this.props;
        onSubmit && onSubmit('F',dateFrom, timeFrom)
    }

    render() {
        return <div>
            <Modal
                title={'执行'}
                maskClosable={false}
                visible={this.props.isShow}
                onOk={this.onSubmit.bind(this)}
                onCancel={this.closeModal.bind(this)}>
                <div style={{ textAlign: 'center' }}>
                    <Col style={{ marginTop: 5 }}>
                        处理日期：<DatePicker value={this.state.dateFrom ? moment(this.state.dateFrom, dayFormat) : ''} style={{ width: '20vh' }}
                            onChange={this.changeDate.bind(this)} />
                    </Col>
                    <Col style={{ marginTop: 5 }}>
                        处理时间：<TimePicker value={this.state.timeFrom ? moment(this.state.timeFrom, timeFormat) : ''} style={{ width: '20vh' }}
                            onChange={this.changeTime.bind(this)} />
                    </Col>
                </div>
            </Modal>
        </div>
    }
}

export default ShowExecListModal;