/**
 * 
 * 检查医嘱项tabs
 */
import React from 'react';
import {
    Card, Tabs, Divider
} from 'antd';
import CommonOrderListPage from './checkComponent/CheckOrderListPage.jsx';
import './style/index.less';

import Attention from './checkComponent/Attention.jsx'; // 关联检查注意事项
import OtherItem from './checkComponent/OtherItem.jsx'; // 关联其他输入项目
import ProcessMethod from './checkComponent/ProcessMethod.jsx'; // 关联处理方法
import Position from './checkComponent/Position.jsx'; // 关联检查体位
import PartAndFee from './checkComponent/PartAndFee.jsx'; // 关联检查体位

const TabPane = Tabs.TabPane;

class OrderListTabs 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) {
        if (this.state.medID&&(this.state.medID!==data)){
            console.log(this.state.medID);
            this.clearTabInput();
        }
        this.setState({
            medID: data
        })
    }

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

    clearTabInput=()=>{
        if (this.AttentionRef) {
            this.AttentionRef.resetFields();
        }
        if (this.OtherItemRef) {
            this.OtherItemRef.resetFields();
        }
        if (this.ProcessMethodRef) {
            this.ProcessMethodRef.resetFields();
        }
        if (this.PositionRef) {
            this.PositionRef.resetFields();
        }
        if (this.PartAndFeeRef) {
            this.PartAndFeeRef.resetFields();
        }
    }

    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.medCode ? medID.medCode : '--'}
                <Divider type="vertical" style={{ color: '#1999db' }} />
                {medID && medID.medDesc ? medID.medDesc : '--'}
                <Divider type="vertical" style={{ color: '#1999db' }} />
                {medID && medID.subCatDesc ? medID.subCatDesc : '--'}
                <Divider type="vertical" style={{ color: '#1999db' }} />
                {medID && medID.subCatID ? medID.subCatID : '--'}
            </div>
        )
        return <div className='outpatient-station-body' style={{ height: '100%' }}>
            <Card style={{ width: '35%', float: 'left' }} className='outpatient-station-card' title='检查医嘱项列表'>
                <CommonOrderListPage ref={ref => this.refs = ref} loadCommonMedId={this.loadCommonMedId.bind(this)}
                    loadDetailMsg={this.loadDetailMsg.bind(this)}></CommonOrderListPage>
            </Card>

            <Card style={{ width: '64.8%', float: 'right' }} title={'关联其它'}>
                <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="2">
                    {rowDataDom}
                    <OLAssociatedCharges medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span><Icon className={this.state.activeTab == '3'?'medicine-box':'medicine-box-disable'} />关联医院</span>} key="3">
                    {rowDataDom}
                    <OLAssociatedHospital medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span><Icon type='file-search' />项目执行科室</span>} key="4">
                    {rowDataDom}
                    <OLExecutiveDepartments medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span><Icon type='exception' />检查部位</span>} key="5">
                    {rowDataDom}
                    <CheckBodyPartsTabPane medData={this.state.medID}/>
                </TabPane>
                <TabPane tab={<span><Icon type='usergroup-add' />剂量单位转换</span>} key="6">
                    {rowDataDom}
                    <OLDoseConversionUnit medData={this.state.medID} />
                </TabPane>
                <TabPane tab={<span><Icon className={this.state.activeTab == '7'?'patient-table':'patient-table-disable'} />医嘱标本</span>} key="7">
                    {rowDataDom}
                    <OLSpecimensDoctorAdvice medData={this.state.medID} />
                </TabPane> */}
                    <TabPane tab={<span>关联检查注意事项</span>} key="1">
                        {rowDataDom}
                        <Attention wrappedComponentRef={(el)=>this.AttentionRef=el} medData={this.state.medID} />
                    </TabPane>
                    <TabPane tab={<span>关联其它输入项目</span>} key="2">
                        {rowDataDom}
                        <OtherItem wrappedComponentRef={(el)=>this.OtherItemRef=el} medData={this.state.medID} />
                    </TabPane>
                    <TabPane tab={<span>关联处理方法</span>} key="3">
                        {rowDataDom}
                        <ProcessMethod wrappedComponentRef={(el)=>this.ProcessMethodRef=el} medData={this.state.medID} />
                    </TabPane>
                    <TabPane tab={<span>关联检查体位</span>} key="4">
                        {rowDataDom}
                        <Position wrappedComponentRef={(el)=>this.PositionRef=el} medData={this.state.medID} />
                    </TabPane>
                    <TabPane tab={<span>关联部位及收费项</span>} key="5">
                        {rowDataDom}
                        <PartAndFee wrappedComponentRef={(el)=>this.PartAndFeeRef=el} medData={this.state.medID} />
                    </TabPane>
                </Tabs>
            </Card>
        </div>
    }

}
export default OrderListTabs;