// 医疗注册审核
import React from 'react';
import { Link } from 'react-router-dom'
import {
    Layout, Form, Carousel, Input, Button, Row, Col, Steps, Select, DatePicker, Modal, Icon, Card
} from 'antd';
import moment from "moment"
import '../../assets/css/login.css'
import { $http } from '../../containers/config/https';
import { httpConfig } from '../../containers/config/httpConfig'
import { Aes, Keup } from '../../tools/index';
import 'assets/css/common.css';


class MedicalRegistrationReview extends React.Component {
    constructor(props) {
        super(props)
        this.state = {

            //注册页面初始值
            sexData: [], // 性别集合
            credtypeData: [], // 证件类型集合
            languageData: [], // 语言集合
            hospitalData: [], // 医院集合
            groupData: [], // 岗位集合
            experiseData: [], // 专长集合
            titleData: [], // 职称集合
            DeptDrData: [{ id: 0, descripts: "" }], // 科室集合
            contentH: '',  //content高度
            StartDate: undefined,  // //开始日期
            EndDate: undefined,  // //结束日期
            languageCode: 'CN',// 国际化标识
            languageData2: {}, // 国际化语言包
            language: {},   // 国际化语言
        }
    }

    componentDidMount() {
        Keup.UnTab(["title", "post", "passWord2"]);   //禁用组件tab脚本 UnTab([id1,id2,id3])

        this.contentHeight();   // 获取content的高度

        this.CNEN() // 国际化
    }


    //点击切换中英文
    handleLanguage = (languageCode) => {
        this.setState({
            languageCode: languageCode === "CN" ? "EN" : "CN",
        }, () => {
            this.LanCNEN(this.state.languageCode)
        })
    }


    // 国际化
    CNEN = () => {
        var data = {
            params: [{
                "reactCode": ['Register'],
                "compontName": "Register",
                "type": "C"
            }]
        }

        $http.post('urlDeault', this, {
            code: "01040073",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        languageData2: res.result.language || {},  // 国际化语言包
                    }, () => {
                        this.LanCNEN(this.state.languageCode)
                    })
                }
            }
        });
    }

    LanCNEN = (code) => {
        let { languageData2 } = this.state
        this.setState({
            language: languageData2[code]
        })
    }

    startChange(date) {
        this.setState({
            StartDate: date,
        })
    }

    endChange(date) {
        this.setState({
            EndDate: date,
        })
    }




    //  上一步
    prevBtn = () => {
        this.refs.setCarouselRef.prev();
    }

    //  下一步
    nextBtn = () => {
        let num = this.state.current
        switch (num) {
            case 0:
                this.props.form.validateFields(['descripts', 'sex', 'credType', 'credNo', 'birthdate', 'mobile', 'title', 'identifyCode'], (err, values) => { //'descripts', 'sex', 'credType', 'credNo', 'birthdate', 'mobile', 'title','identifyCode'
                    if (!err) {
                        this.refs.setCarouselRef.next();
                    } else {
                        return false;
                    }
                });
                break;
            case 1:
                this.props.form.validateFields(['hospDr', 'defaultDeptDr', 'post'], (err, values) => {   //'hospDr', 'defaultDeptDr', 'post'
                    if (!err) {
                        this.refs.setCarouselRef.next();
                    } else {
                        return false;
                    }
                });
                break;
            default:
                break;
        }
    }



    // 获取content的高度
    contentHeight = (e) => {
        let contenth = parseInt(document.body.clientHeight) - 160;
        this.setState({
            contentH: contenth
        })
    }

    //  注册账号表单提交
    handleSubmit = (e) => {
        e.preventDefault();

        this.props.form.validateFields((err, values) => {
            if (!err) {
                let data = {
                    "params": [{
                        "userDesc": values.descripts,
                        "userSexID": values.sex,
                        "userMobile": values.mobile,
                        "identifyCode": values.identifyCode,
                        "userPassword": Aes.Encrypt(values.passWord2),
                        "userDOB": values.birthdate ? moment(values.birthdate).utcOffset(480).format('YYYY-MM-DD') : '',
                        "userTitleID": values.title,
                        "userLogonLocID": values.defaultDeptDr,
                        "userPostID": values.post,
                        "userLogonHospID": values.hospDr,
                        "userCredTypeID": values.credType,
                        "userCredNo": values.credNo,
                        'userCode': values.userCode,
                        'requestFlag': 'R',
                    }]
                };
                $http.post('urlDeault', this, {
                    code: "01040070",
                    data: data,
                    success: function (res) {
                        let errorCode = res.errorCode;
                        if (errorCode === '0') {

                        }
                    }
                });
            }
        });
    }

    render() {
        let { languageCode, language, current } = this.state;
        const { Content, } = Layout;

        return (
            <div>
                <Layout>
                    <Content style={{ height: this.state.contentH }} className="loginContent regContent">
                        <div style={{ position: 'absolute', right: '20px', top: '10px', zIndex: '999' }}>
                            <Button type="primary" className="mR20" >通过</Button>
                            <Button type="danger">拒绝</Button>
                        </div>
                        <Card
                            title={<div className="card-title-left-icon"><div></div>基本资料</div>}
                            style={{ outline: 'none', fontSize: '16px' }}
                        >
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >机构名称： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >联系电话：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >注册申请日期： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >地址：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                        </Card>
                        <Card
                            title={<div className="card-title-left-icon"><div></div>提交资质</div>}
                            style={{ outline: 'none', fontSize: '16px' }}
                        >
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >主要负责人： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >法定代表人：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >登记号： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >经营性质：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >机构级别： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >机构类别：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >发证机关： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >发证日期：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                            <Row className='mB15'>
                                <Col span={12}>
                                    <Col span={8} className="textR" >机构申请日期： </Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                                <Col span={12}>
                                    <Col span={8} className="textR" >有效日期：</Col>
                                    <Col span={16}> XX</Col>
                                </Col>
                            </Row>
                        </Card>
                        <Card
                            title={<div className="card-title-left-icon"><div></div>提交文件</div>}
                            style={{ outline: 'none', fontSize: '16px' }}
                        >
                            <Row className='mB15'>
                                <Col span={8}>

                                </Col>
                                <Col span={8}>

                                </Col>
                                <Col span={8}>

                                </Col>
                            </Row>

                        </Card>
                    </Content>
                </Layout>
            </div >
        );
    }
}

export default MedicalRegistrationReview