/*
 * Creator:     ML
 * CreatDate:   2020-04-09
 * descripts：  ADC评分 / ADC评分报告
 * */
import React from 'react';
import {
    Card, Table, Input, Form, Select, Row, Col, Checkbox, Tabs,
    DatePicker, Button, Popconfirm, Icon, Divider, message, Modal,
} from 'antd';
import { Util, dayFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import AssessmentADC from './AssessmentADC';
import AssessmentADCReport from './AssessmentADCReport';
import store from 'store';
import moment from 'moment';
import '../style/assessment.less';

const { RangePicker } = DatePicker;
const Option = Select.Option;
const Search = Input.Search;
const TabPane = Tabs.TabPane;
const confirm = Modal.confirm;
class AssessmentADCTab extends React.Component {
    constructor(props) {
        super(props)
        var userData = JSON.parse(sessionStorage.getItem('userData'))
        this.state = {
            dataSource: [],
            userData: userData,
            activeKey:'1'
        }
    }

    componentDidMount() {
        this.props.onAdcTab(this)
    }
    
    handleSetValue=(id)=>{
        this.childAdc.setValue(id)
    }
    handleClear=(d)=>{
        this.childAdc.clear(d)
    }
    onRef=(ref)=>{
        this.childAdc = ref
    }
    changeActiveKey(e) {
        var that = this;
        if (sessionStorage.getItem("noSave") && JSON.parse(sessionStorage.getItem("noSave")) === true) {
            confirm({
                title: '提示',
                content: '当前页面数据还没保存，确定要切换页面吗？',
                okText:  '确定',
                cancelText: '取消',
                onOk() {
                    window.sessionStorage.setItem("noSave",false);
                    that.setState({
                        activeKey: e
                    })
                },
                onCancel() {
                    return
                }
            })
        } else {
            that.setState({
                activeKey: e
            })
        }
       
    }

    updateHeathList=()=>{
        this.props.updateList()
    }
    render() {

        return <div className="adc-tab-dom">
            <div>
                <div>
                  <div style={{textAlign:"center"}}>
                  <span className={this.state.activeKey!="2"?"tab-active tab-span":"tab-span"}  onClick={()=>this.changeActiveKey("1")}>ADC评分</span>
                   <span  className={this.state.activeKey!="1"?"tab-active tab-span":"tab-span"}  onClick={()=>this.changeActiveKey("2")}>ADC评分报告</span>
                  </div>
                   <p style={{ background: "#f5f4f4", height: "6px", margin: "8px 0" }}>
                    </p>
                     {this.state.activeKey=="1"?<AssessmentADC updateHeathList={this.updateHeathList} onRef={this.onRef}/>:<div><AssessmentADCReport updateHeathList={this.updateHeathList} onRef={this.onRef}/></div>} 
                </div>
            </div>
        </div>
    }

}

export default AssessmentADCTab;
