// 医嘱项维护
import React from 'react';
import MedItemDose from './MedItemDose';
import MedItemAlias from './MedItemAlias';
import MedItemAut from './MedItemAut';
import { Modal, Form, Input, Row ,Col ,message ,Select ,Tabs ,Icon ,Checkbox ,DatePicker } from 'antd';
import { $http } from '../../../containers/config/https';
import '../druginfo/Maintenance.css'
import moment from 'moment'
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
const Option = Select.Option;
const TabPane = Tabs.TabPane;
const FormItem = Form.Item;

class MedItemSave extends React.Component {
        constructor(props) {
            super(props)
            this.state = { 
                index:1,
                visible: false,
                priorityData:[],
                genericData:[],
                formData:[],
                sexData:[],
                usageData:[],
                uomData:[],
                durationData:[],
                freqData:[],
                poisonData:[],
                criticalData:[],
                ordSubCatData:[],
            };
        }
        componentDidMount() {
            this.props.onRef(this);
            this.loadInfo(); //获取下拉框信息
        }

        // 调用子组件的连接事件
        onRef = (ref) => {
            this.child = ref
        }

        // 调用子组件的连接事件
        onRefAlias = (ref) => {
            this.childAlias = ref
        }

        // 调用子组件的连接事件
        onRefAut = (ref) => {
            this.childAut = ref
        }

        //获取下拉框信息
        loadInfo(){
            var params = [{}]
            $http.post('urlS', this, {
                code: "02020009",
                data: params,
                success: function (res) {
                    //console.log(res)
                    if (res.errorCode === '0') {
                        var j=0
                        for(j = 0; j < res.priority.length; j++) {
                            this.state.priorityData.push(<Option value={res.priority[j].id}  title={res.priority[j].descripts} key={j}>{res.priority[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.form.length; j++) {
                            this.state.formData.push(<Option value={res.form[j].id} title={res.form[j].descripts} key={j}>{res.form[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.generic.length; j++) {
                            this.state.genericData.push(<Option value={res.generic[j].id} title={res.generic[j].descripts} key={j}>{res.generic[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.sex.length; j++) {
                            this.state.sexData.push(<Option value={res.sex[j].id} title={res.sex[j].descripts} key={j}>{res.sex[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.usage.length; j++) {
                            this.state.usageData.push(<Option value={res.usage[j].id} title={res.usage[j].descripts} key={j}>{res.usage[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.uom.length; j++) {
                            this.state.uomData.push(<Option value={res.uom[j].id} title={res.uom[j].descripts} key={j}>{res.uom[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.duration.length; j++) {
                            this.state.durationData.push(<Option value={res.duration[j].id} title={res.duration[j].descripts} key={j}>{res.duration[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.freq.length; j++) {
                            this.state.freqData.push(<Option value={res.freq[j].id} title={res.freq[j].descripts} key={j}>{res.freq[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.poison.length; j++) {
                            this.state.poisonData.push(<Option value={res.poison[j].id} title={res.poison[j].descripts} key={j}>{res.poison[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.critical.length; j++) {
                            this.state.criticalData.push(<Option value={res.critical[j].id} title={res.critical[j].descripts} key={j}>{res.critical[j].descripts}</Option>)
                        }
                        for(j = 0; j < res.ordSubCat.length; j++) {
                            this.state.ordSubCatData.push(<Option value={res.ordSubCat[j].id} title={res.ordSubCat[j].descripts} key={j}>{res.ordSubCat[j].descripts}</Option>)
                        }
                    }else{
                        
                    }
                }
            });
        }
        
        // 加载医嘱子类数据集
        loadOrdSubCatInfo(medItemID){
            let data = {}
            data = {
                params: [{
                    medItemID: medItemID,
                }],
            }
            $http.post('urlS', this, {
                code: "02020072",
                data: data,
                success: function (res) {
                    if (res.errorCode === '0') {
                        if (res.ordSubCat.length>0){
                            this.setState({
                                ordSubCatData:[],
                            },()=>{
                                for(var j = 0; j < res.ordSubCat.length; j++) {
                                    this.state.ordSubCatData.push(<Option value={res.ordSubCat[j].id} title={res.ordSubCat[j].descripts} key={j}>{res.ordSubCat[j].descripts}</Option>)
                                }
                            })
                        }
                    }
                }
            })
        }
        // 生效时间
        onChangeStartDate = (date, dateString)=> {
            this.setState({
                startDate: dateString,
            })
        }
        
        // 失效时间
        onChangeStopDate = (date, dateString)=>{
            this.setState({
                stopDate: dateString,
            })
        }

        //处理多个input的公共方法
        onChangeInput(name, e){
            this.setState({
                [name]: e.target.value
            })
        }

        //处理多个checkbox的公共方法
        onChangeCheckbox(name, e){
            this.setState({
                [name]: e.target.checked
            })
        }

        ///处理多个select下拉的公共方法
        selectOnChange=(name,value,option)=>{
            if(value){
                this.setState({
                    [name]:value,
                },()=>{
                    if(name==='generID'){
                        this.GetFormByGenerID(value);
                    }
                })
            }else{
                this.setState({
                    [name]:'',
                },()=>{
                    if(name==='generID'){
                        this.setState({
                            medFormID:'',
                        })
                    }
                })
            }
        }

        /// 取剂型
        GetFormByGenerID = (generID) =>{
            let data = {}
            data = {
                params: [{
                    generID: generID,
                }],
            }
            $http.post('urlS', this, {
                code: "02020205",
                data: data,
                success: function (res) {
                    if (res.errorCode === '0') {
                        this.setState({
                            medFormID:res.result.formID,
                        })
                    }
                }
            })
        }

        // 显示弹出层
        showModal = () => {
            this.setState({
                visible: true,
            });
        }
        // 重置表单
        resetFields(){
            // console.log("触发了")
            this.props.form.resetFields(); //清空所有
            this.setState({
                medID:'',
                medCode:'',
                medDesc:'',
                medShortDesc:'',
                medSubCatID:'',
                medPriorityID:'',
                generID:'',
                medUnitID:'',
                medMessage:'',
                startDate:moment(new Date()).utcOffset(480).format('YYYY-MM-DD'),
                medMaxDose:'',
                medQdMaxQty:'',
                medSexID:'',
                medAgeFrom:'',
                medAgeTo:'',
                medDurQty:'',
                medDurationID:'',
                stopDate:null,
                medNoAloneOrder:false,
                medNoStockFlag:false,
                medNoChangeFlag:false,
                medMergeUseFlag:false,
                medEMFlag:false,
                medPrivateFlag:false,
                medToalCountO:false,
                medToalCountI:false,
                medSpec:'',
                medUsageID:'',
                medFreqID:'',
                tradeName:'',
                poisonID:'',
                criLevID:'',
                antidFlag:false,
                countryFlag:false,
                provFlag:false,
                cityFlag:false,
                monitFlag:false,
                medSkinTestFlag:false,
                medFormID:'',
            })
        }

        // 取消
        handleCancel = () => {
            this.resetFields();
            this.setState({
                visible: false,
                index:1,
            });
            if (this.childAut) {
                this.childAut.setState({
                    findFlag:'0' ,
                })
            }
            if (this.child) {
                this.child.setState({
                    findFlag:'0' ,
                })
            }
        }
        
        // 确定
        handleCreate = () => {
            let doseUnit = [];
            if (this.child) {
                for (var i=0;i<this.child.state.data.length;i++){
                    let obj= {
                        doseQty : this.child.state.data[i].doseQty,
                        doseUnitID :　this.child.state.data[i].doseUomDr,
                        defaultQty : this.child.state.data[i].defaultQty,
                    }
                    doseUnit.push(obj);
                }
            }
            let medAut = [];
            if (this.childAut) {
                for (var i=0;i<this.childAut.state.data.length;i++){
                    console.log(this.childAut.state.data[i])
                    let obj= {
                        levelID : this.childAut.state.data[i].levelDr,
                        operTypeID :　this.childAut.state.data[i].operTypeDr,
                        operateID : this.childAut.state.data[i].operateDr,
                        pointerID : this.childAut.state.data[i].pointerDr,
                    }
                    medAut.push(obj);
                }
            }
            let data = {}
            let { flag } = this.props;
            if ((flag === 'addMedItem')||(flag === 'saveAsMedItem')) {
                data={
                    params: [{
                        medID:'',
                        medCode:this.state.medCode,
                        medDesc:this.state.medDesc,
                        medShortDesc:this.state.medShortDesc,
                        medSubCatID:this.state.medSubCatID,
                        medPriorityID:this.state.medPriorityID,
                        generID:this.state.generID,
                        medUnitID:this.state.medUnitID,
                        medMessage:this.state.medMessage,
                        startDate:this.state.startDate?this.state.startDate:moment(new Date()).utcOffset(480).format('YYYY-MM-DD'),
                        medMaxDose:this.state.medMaxDose,
                        medQdMaxQty:this.state.medQdMaxQty,
                        medSexID:this.state.medSexID, 
                        medAgeFrom :this.state.medAgeFrom,
                        medAgeTo:this.state.medAgeTo,
                        medDurQty:this.state.medDurQty,
                        medDurationID:this.state.medDurationID,
                        stopDate:this.state.stopDate?this.state.stopDate:null,
                        medNoAloneOrder:this.state.medNoAloneOrder?'Y':'N',
                        medNoStockFlag:this.state.medNoStockFlag?'Y':'N',
                        medNoChangeFlag:this.state.medNoChangeFlag?'Y':'N',
                        medMergeUseFlag:this.state.medMergeUseFlag?'Y':'N',
                        medEMFlag:this.state.medEMFlag?'Y':'N',
                        medPrivateFlag:this.state.medPrivateFlag?'Y':'N',
                        medToalCountO:this.state.medToalCountO?'Y':'N',
                        medToalCountI:this.state.medToalCountI?'Y':'N',
                        medSpec:this.state.medSpec,
                        medUsageID:this.state.medUsageID,
                        medFreqID:this.state.medFreqID,
                        tradeName:this.state.tradeName,
                        poisonID:this.state.poisonID,
                        criLevID:this.state.criLevID,
                        antidFlag:this.state.antidFlag?'Y':'N',
                        countryFlag:this.state.countryFlag?'Y':'N',
                        provFlag:this.state.provFlag?'Y':'N',
                        cityFlag:this.state.cityFlag?'Y':'N',
                        monitFlag:this.state.monitFlag?'Y':'N',
                        medSkinTestFlag:this.state.medSkinTestFlag?'Y':'N',
                        doseUnit:doseUnit,
                        medAut:medAut,
                    }]
                }
                this.handleSave(data);
            }
            if (flag === 'modifyMedItem') {
                data={
                    params: [{
                        medID:this.state.medID,
                        medCode:this.state.medCode,
                        medDesc:this.state.medDesc,
                        medShortDesc:this.state.medShortDesc,
                        medSubCatID:this.state.medSubCatID,
                        medPriorityID:this.state.medPriorityID,
                        generID:this.state.generID,
                        medUnitID:this.state.medUnitID,
                        medMessage:this.state.medMessage,
                        startDate:this.state.startDate?this.state.startDate:moment(new Date()).utcOffset(480).format('YYYY-MM-DD'),
                        medMaxDose:this.state.medMaxDose,
                        medQdMaxQty:this.state.medQdMaxQty,
                        medSexID:this.state.medSexID, 
                        medAgeFrom :this.state.medAgeFrom,
                        medAgeTo:this.state.medAgeTo,
                        medDurQty:this.state.medDurQty,
                        medDurationID:this.state.medDurationID,
                        stopDate:this.state.stopDate?this.state.stopDate:null,
                        medNoAloneOrder:this.state.medNoAloneOrder?'Y':'N',
                        medNoStockFlag:this.state.medNoStockFlag?'Y':'N',
                        medNoChangeFlag:this.state.medNoChangeFlag?'Y':'N',
                        medMergeUseFlag:this.state.medMergeUseFlag?'Y':'N',
                        medEMFlag:this.state.medEMFlag?'Y':'N',
                        medPrivateFlag:this.state.medPrivateFlag?'Y':'N',
                        medToalCountO:this.state.medToalCountO?'Y':'N',
                        medToalCountI:this.state.medToalCountI?'Y':'N',
                        medSpec:this.state.medSpec,
                        medUsageID:this.state.medUsageID,
                        medFreqID:this.state.medFreqID,
                        tradeName:this.state.tradeName,
                        poisonID:this.state.poisonID,
                        criLevID:this.state.criLevID,
                        antidFlag:this.state.antidFlag?'Y':'N',
                        countryFlag:this.state.countryFlag?'Y':'N',
                        provFlag:this.state.provFlag?'Y':'N',
                        cityFlag:this.state.cityFlag?'Y':'N',
                        monitFlag:this.state.monitFlag?'Y':'N',
                        medSkinTestFlag:this.state.medSkinTestFlag?'Y':'N',
                    }]
                }
                this.handleSave(data);
            }
        }
        
        // 保存数据
        handleSave = (data) => {
            //console.log(data)
            $http.post('url', this, {
                code: '02020010',
                data: data,
                success: function (res) {   
                    //console.log(res)
                    if (+res.errorCode === 0 ) {
                        message.success('保存成功');
                        // 新增或编辑成功重置form表单
                        this.resetFields();
                        // 关闭弹框
                        this.handleCancel();
                        // 刷新列表数据
                        this.props.handelThis.handleAllQuery();
                    } else {
                        
                    }
                }
            })
        }

        // 切换页签
        onChangeTabs = (key) => {
            this.setState({ 
                index:key,
            },()=>{

            });
            if(Number(key)===3){
                setTimeout(() => {this.handleDoseQuery()},100)  //延时调用子组件方法
            }

            if(Number(key)===4){
                setTimeout(() => {this.handleAliasQuery()},100)  //延时调用子组件方法
            }

            if(Number(key)===5){
                setTimeout(() => {this.handleAutQuery()},100)  //延时调用子组件方法
            }
        }

        //延时调用子组件方法
        handleDoseQuery = () => {
            if(this.props.flag==="modifyMedItem"){
                this.child.setState({
                    medItemID:this.state.medID,
                },()=>{
                    this.child.handleQuery();
                })
            }else if (this.props.flag==="saveAsMedItem"){
                this.child.setState({
                    medItemID:'' ,
                    saveAsMedID:this.state.medID,
                },()=>{
                    if (this.child.state.findFlag!='1') {
                        this.child.handleQuery();
                    }
                })
            }else{
                this.child.setState({
                    medItemID:'',
                    savaAsMedID:'',
                })
                this.child.Clear();
                if (this.child.state.findFlag!='1') {
                    this.child.setState({
                        data:[],
                    })
                }
            }
        }

        //延时调用子组件方法
        handleAliasQuery = () => {
            if(this.props.flag==="modifyMedItem"){
                this.childAlias.setState({
                    medItemID:this.state.medID,
                },()=>{
                    this.childAlias.handleQuery();
                })
            }else{
                this.childAlias.setState({
                    medItemID:'',
                    selectID:'',
                    data:[],
                    alias:'',
                })
            }
        }

        //延时调用子组件方法
        handleAutQuery = () => {
            if(this.props.flag==="modifyMedItem"){
                this.childAut.setState({
                    medItemID:this.state.medID,
                },()=>{
                    this.childAut.handleQuery();
                })
            }else if (this.props.flag==="saveAsMedItem"){
                this.childAut.setState({
                    medItemID:'' ,
                    saveAsMedID:this.state.medID,
                },()=>{
                    if (this.childAut.state.findFlag!='1') {
                        this.childAut.handleQuery();
                    }
                })
            }else{
                this.childAut.setState({
                    medItemID:'',
                    savaAsMedID:'',
                })
                this.childAut.Clear();
                if (this.childAut.state.findFlag!='1') {
                    this.childAut.setState({
                        data:[],
                    })
                }
            }
        }

        render() {
            const { getFieldDecorator } = this.props.form;
            let formItemLayout = {
                labelCol: { span: 9 },
                wrapperCol: { span: 15 }
            };
            let formItemCheckBoxLayout = {
                labelCol: { span: 14 },
                wrapperCol: { span: 10 }
            };
            return (
                <Modal
                    visible={this.state.visible}
                    title={this.props.title}
                    okText="保存"
                    onCancel={this.handleCancel}
                    onOk={this.handleCreate}
                    width="900px"
                    maskClosable={false}
                    centered={true}
                >
                    <div style={{height:'510px'}}>
                            <Tabs 
                                defaultActiveKey="1"
                                activeKey={String(this.state.index)} 
                                onChange={this.onChangeTabs}
                            >
                                <TabPane tab={<span><Icon type="chrome" />基本信息</span>} key="1" >
                                    <div style={{paddingTop:'8px'}}>
                                        <Form>
                                            <Col span={8}>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='医嘱项代码'>
                                                        {getFieldDecorator('medCode', {
                                                            initialValue:this.state.medCode,
                                                            rules: [{ required: true, message: '医嘱项代码是必填项,请选择！' }]
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medCode")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='医嘱项描述'>
                                                        {getFieldDecorator('medDesc', {
                                                            initialValue:this.state.medDesc,
                                                            rules: [{ required: true, message: '医嘱项描述是必填项,请选择！' }]
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medDesc")}
                                                                    title={this.state.medDesc}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='简称'>
                                                        {getFieldDecorator('medShortDesc', {
                                                            initialValue:this.state.medShortDesc,
                                                            rules: [{ required: true, message: '简称是必填项,请选择！' }]
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medShortDesc")}
                                                                    title={this.state.medShortDesc}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='医嘱子类'>
                                                        {getFieldDecorator('medSubCatID', {
                                                            initialValue:this.state.medSubCatID,
                                                            rules: [{ required: true, message: '医嘱子类是必填项,请选择！' }]
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medSubCatID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.ordSubCatData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='医嘱优先级'>
                                                        {getFieldDecorator('medPriorityID', {
                                                            initialValue:this.state.medPriorityID,
                                                            rules: [{ required: false, message: '医嘱优先级是必填项,请选择！' }]
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medPriorityID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.priorityData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                    <FormItem {...formItemLayout} label='处方通用名'>
                                                        {getFieldDecorator('generID', {
                                                            initialValue:this.state.generID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"generID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.genericData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                    <FormItem {...formItemLayout} label='计价单位'>
                                                        {getFieldDecorator('medUnitID', {
                                                            initialValue:this.state.medUnitID,
                                                            rules: [{ required: true, message: '计价单位是必填项,请选择！' }]
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medUnitID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.uomData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='生效日期'>
                                                        {getFieldDecorator('startDate', {
                                                            initialValue:this.state.startDate?moment(this.state.startDate, 'YYYY-MM-DD'):moment(new Date(), 'YYYY-MM-DD'),
                                                            rules: [{ required: true, message: '生效日期是必填项,请选择！' }]
                                                            })(
                                                                <DatePicker
                                                                    onChange={this.onChangeStartDate}
                                                                    format="YYYY-MM-DD" 
                                                                    style={{width:'100%'}}
                                                                >
                                                                </DatePicker>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='失效日期'>
                                                        {getFieldDecorator('StopDate', {
                                                            initialValue:this.state.stopDate && this.state.stopDate!==''?moment(this.state.stopDate, 'YYYY-MM-DD'):null,
                                                            rules: []
                                                            })(
                                                                <DatePicker
                                                                    onChange={this.onChangeStopDate}
                                                                    format="YYYY-MM-DD"
                                                                    style={{width:'100%'}}
                                                                >
                                                                </DatePicker>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                            </Col>
                                            <Col span={8} style={{marginLeft:'30px'}}>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='单次最大剂量'>
                                                        {getFieldDecorator('medMaxDose', {
                                                            initialValue:this.state.medMaxDose,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medMaxDose")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='每天最大剂量'>
                                                        {getFieldDecorator('medQdMaxQty', {
                                                            initialValue:this.state.medQdMaxQty,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medQdMaxQty")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='性别'>
                                                        {getFieldDecorator('medSexID', {
                                                            initialValue:this.state.medSexID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medSexID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.sexData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='年龄从'>
                                                        {getFieldDecorator('medAgeFrom', {
                                                            initialValue:this.state.medAgeFrom,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medAgeFrom")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='年龄到'>
                                                        {getFieldDecorator('medAgeTo', {
                                                            initialValue:this.state.medAgeTo,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medAgeTo")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='疗程数'>
                                                        {getFieldDecorator('medDurQty', {
                                                            initialValue:this.state.medDurQty,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medDurQty")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='最大疗程单位'>
                                                        {getFieldDecorator('medDurationID', {
                                                            initialValue:this.state.medDurationID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medDurationID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.durationData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='医嘱提示'>
                                                        {getFieldDecorator('medMessage', {
                                                            initialValue:this.state.medMessage,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medMessage")}
                                                                    title={this.state.medMessage}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                            </Col>
                                            <Col span={6} style={{marginLeft:'20px'}}>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='独立医嘱'>
                                                        {getFieldDecorator('medNoAloneOrder', {
                                                            initialValue:this.state.medNoAloneOrder,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medNoAloneOrder")}
                                                                    checked={this.state.medNoAloneOrder}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='无库存医嘱'>
                                                        {getFieldDecorator('medNoStockFlag', {
                                                            initialValue:this.state.medNoStockFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medNoStockFlag")}
                                                                    checked={this.state.medNoStockFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='不收费'>
                                                        {getFieldDecorator('medNoChangeFlag', {
                                                            initialValue:this.state.medNoChangeFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medNoChangeFlag")}
                                                                    checked={this.state.medNoChangeFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='合并用药'>
                                                        {getFieldDecorator('medMergeUseFlag', {
                                                            initialValue:this.state.medMergeUseFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medMergeUseFlag")}
                                                                    checked={this.state.medMergeUseFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='加急标志'>
                                                        {getFieldDecorator('medEMFlag', {
                                                            initialValue:this.state.medEMFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medEMFlag")}
                                                                    checked={this.state.medEMFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='私有标志'>
                                                        {getFieldDecorator('medPrivateFlag', {
                                                            initialValue:this.state.medPrivateFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medPrivateFlag")}
                                                                    checked={this.state.medPrivateFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='是否需要皮试'>
                                                        {getFieldDecorator('medSkinTestFlag', {
                                                            initialValue:this.state.medSkinTestFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medSkinTestFlag")}
                                                                    checked={this.state.medSkinTestFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='门诊按总量'>
                                                        {getFieldDecorator('medToalCountO', {
                                                            initialValue:this.state.medToalCountO,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medToalCountO")}
                                                                    checked={this.state.medToalCountO}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemCheckBoxLayout} label='住院按总量'>
                                                        {getFieldDecorator('medToalCountI', {
                                                            initialValue:this.state.medToalCountI,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"medToalCountI")}
                                                                    checked={this.state.medToalCountI}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                            </Col>
                                        </Form>
                                    </div>
                                </TabPane>
                                <TabPane tab={<span><Icon type="chrome" />药学相关信息</span>} key="2">
                                    <div style={{paddingTop:'8px'}}>
                                        <Form>
                                            <Col span={2}></Col>
                                            <Col span={8}>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='含量规格'>
                                                        {getFieldDecorator('medSpec', {
                                                            initialValue:this.state.medSpec,
                                                            rules: [{ required: true, message: '含量规格是必填项,请选择！' }]
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"medSpec")}
                                                                    title={this.state.medSpec}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='用法'>
                                                        {getFieldDecorator('medUsageID', {
                                                            initialValue:this.state.medUsageID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medUsageID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.usageData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='频次'>
                                                        {getFieldDecorator('medFreqID', {
                                                            initialValue:this.state.medFreqID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medFreqID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.freqData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='剂型'>
                                                        {getFieldDecorator('medFormID', {
                                                            initialValue:this.state.medFormID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    disabled={true}
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"medFormID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.formData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='商品名'>
                                                        {getFieldDecorator('tradeName', {
                                                            initialValue:this.state.tradeName,
                                                            rules: []
                                                            })(
                                                                <Input 
                                                                    onChange={this.onChangeInput.bind(this,"tradeName")}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='管制分类'>
                                                        {getFieldDecorator('poisonID', {
                                                            initialValue:this.state.poisonID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"poisonID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.poisonData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='危重级别'>
                                                        {getFieldDecorator('criLevID', {
                                                            initialValue:this.state.criLevID,
                                                            rules: []
                                                            })(
                                                                <Select
                                                                    allowClear={true}
                                                                    showSearch 
                                                                    optionFilterProp="children" 
                                                                    onChange={this.selectOnChange.bind(this,"criLevID")}
                                                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                                                >
                                                                {this.state.criticalData}
                                                                </Select>
                                                            )}
                                                    </FormItem>
                                                </Row>
                                            </Col>
                                            <Col span={2}></Col>
                                            <Col span={10} style={{marginLeft:'30px'}}>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='抗菌药物标志'>
                                                        {getFieldDecorator('antidFlag', {
                                                            initialValue:this.state.antidFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"antidFlag")}
                                                                    checked={this.state.antidFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='国家基本药物'>
                                                        {getFieldDecorator('countryFlag', {
                                                            initialValue:this.state.countryFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"countryFlag")}
                                                                    checked={this.state.countryFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                
                                                <Row>
                                                    <FormItem {...formItemLayout} label='省级基本药物'>
                                                        {getFieldDecorator('provFlag', {
                                                            initialValue:this.state.provFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"provFlag")}
                                                                    checked={this.state.provFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='市级基本药物'>
                                                        {getFieldDecorator('cityFlag', {
                                                            initialValue:this.state.cityFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"cityFlag")}
                                                                    checked={this.state.cityFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                                <Row>
                                                    <FormItem {...formItemLayout} label='重点监控标志'>
                                                        {getFieldDecorator('monitFlag', {
                                                            initialValue:this.state.monitFlag,
                                                            rules: []
                                                            })(
                                                                <Checkbox 
                                                                    onChange={this.onChangeCheckbox.bind(this,"monitFlag")}
                                                                    checked={this.state.monitFlag}
                                                                />
                                                            )}
                                                    </FormItem>
                                                </Row>
                                            </Col>
                                        </Form>
                                    </div>
                                </TabPane>
                                <TabPane tab={<span><Icon type="chrome" />等效单位</span>} key="3">
                                    <MedItemDose 
                                        onRef={this.onRef} 
                                        handelThis={this}>
                                    </MedItemDose>
                                </TabPane>
                                <TabPane tab={<span><Icon type="chrome" />医嘱项别名</span>} key="4">
                                    <MedItemAlias 
                                        onRef={this.onRefAlias} 
                                        handelThis={this}>
                                    </MedItemAlias>
                                </TabPane>
                                <TabPane tab={<span><Icon type="chrome" />限制用药</span>} key="5">
                                    <MedItemAut 
                                        onRef={this.onRefAut} 
                                        handelThis={this}>
                                    </MedItemAut>
                                </TabPane>
                            </Tabs>
                    </div>
                </Modal>
            )
        }
    }
export default Form.create()(MedItemSave);