/*
 * Creator:     ML
 * CreatDate:   2020-02-28
 * descripts：  抗菌药物 tabs
 * */
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 AntimicrobialListSearch from './component/AntimicrobialListSearch';
import './style/index.less';
import moment from 'moment';

import AntimicrobialTabInformation  from './component/AntimicrobialTabInformation.jsx'; // 抗菌药物信息维护
import AntimicrobialTabDosage  from './component/AntimicrobialTabDosage.jsx'; // 抗菌药物用量维护
import AntimicrobialTabUsage from './component/AntimicrobialTabUsage.jsx'; // 抗菌药物用法维护
import AntimicrobialTabIndications from './component/AntimicrobialTabIndications.jsx'; // 抗菌药物适应证


const { RangePicker } = DatePicker;
const Search = Input.Search;
const Option = Select.Option;
const TabPane = Tabs.TabPane;
const confirm = Modal.confirm;

class AntimicrobialListTabs extends React.Component {
    constructor(props) {
        super(props)
        var userData = JSON.parse(sessionStorage.getItem('userData'))
        this.state = {
            dataSource: [],
            total: 0,
            page: 1,
            pageSize: 10,
            userData: userData,
        }
    }

    componentDidMount() {

    }


    //获取公共的medID
    loadCommonMedId(data){
        this.setState({
            medID:data
        })
    }

    loadDetailMsg(data){
        this.setState({
            detailData:data
        })
    }

    changeTabs(e){
        this.setState({
            activeTab:e
        })
    }

    loadLeftData(){
        this.refs.loadData(1)
    }
    //清除基本信息的编辑信息
    clearInput(){
        this.setState({
            detailData:{},
            medID:''
        })
        this.refs.clearInput()
    }
    render() {
        let {medID} = this.state;
        let rowDataDom = (
            <div style={{color: '#1999db', fontWeight: '700', fontSize: '14px', height: '32px', lineHeight: '32px'}}>
                【当前已选择抗菌药物】
                {medID&&medID.medItemCode ? medID.medItemCode : '--'}
                <Divider type="vertical" style={{color: '#1999db'}} />
                {medID&&medID.medItemDesc ? medID.medItemDesc : '--'}
                {/* <Divider type="vertical" style={{color: '#1999db'}} />
                {medID&&medID.subCatDesc ? medID.subCatDesc : '--'}
                <Divider type="vertical" style={{color: '#1999db'}} />
                {medID&&medID.statusDesc ? medID.statusDesc : '--'} */}
            </div>
        )
        return <div className='outpatient-station-body' style={{ height: '100%'}}>
            <Card style={{width:'35%',float:'left', }} className='outpatient-station-card' title='抗菌药物列表'>
            <AntimicrobialListSearch  ref={ref =>this.refs = ref} loadCommonMedId={this.loadCommonMedId.bind(this)}
                loadDetailMsg={this.loadDetailMsg.bind(this)}></AntimicrobialListSearch>
            </Card>

            <Card style={{ width:'64.8%',float:'right' }} title={this.state.medID?'编辑抗菌药物':'添加抗菌药物'}>
            <Tabs type="card" className='patient-tab-body' size='small' onChange={this.changeTabs.bind(this)}>
                {/* <TabPane tab={<span><Icon type='medicine-box' />基本信息</span>} key="1">
                <BasicInformationTabPane params={this.state.medID} loadLeftData={this.loadLeftData.bind(this)}
                    clearInput={this.clearInput.bind(this)}
                        detailData={this.state.detailData}></BasicInformationTabPane>
                </TabPane> */}
                <TabPane tab={<span>
                    {/* <Icon type='warning' /> */}
                    抗菌药物信息维护</span>} key="1">
                    {rowDataDom}
                    <AntimicrobialTabInformation  medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span>
                    {/* <Icon type='warning' /> */}
                    抗菌药物用量维护</span>} key="2">
                    {rowDataDom}
                    <AntimicrobialTabDosage medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span>
                    {/* <Icon className={this.state.activeTab == '3'?'medicine-box':'medicine-box-disable'} /> */}
                    抗菌药物用法维护</span>} key="3">
                    {rowDataDom}
                    <AntimicrobialTabUsage medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span>
                    {/* <Icon type='file-search' />  */}
                    抗菌药物适应证</span>} key="4">
                    {rowDataDom}
                    <AntimicrobialTabIndications medData={this.state.medID} />
                </TabPane>
            </Tabs>
            </Card>
        </div>
    }

}
export default AntimicrobialListTabs;