/**
 * 基本信息设置
 */
import React from 'react';
import { Input, Form, Select, Row, Col, Switch, DatePicker, Button, message } from 'antd';
import { Util, dayFormat } from 'tools/index';
import { $http } from 'containers/config/https';
import moment from 'moment';
import store from 'store';
import '../style/index.less';
import FormDataDifferenceComparison from 'pages/common/FormDataDifferenceComparison'; // 表单数据差异比对公共弹窗

const Option = Select.Option;
const FormItem = Form.Item;

class BasicInformationTabPane 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,
            rowData: {},
            formData: [], // 表单数据
            extSubCat: [], // 扩展子类
            extSubCatID: undefined,
        };
    }

    static getDerivedStateFromProps(nextProps, prevState) {
        //该方法内禁止访问this
        if (JSON.stringify(nextProps.detailData) !== JSON.stringify(prevState.rowData)) {
            //通过对比nextProps和prevState，返回一个用于更新状态的对象
            return {
                medSubCatID: nextProps?.detailData?.medSubCatID,//医嘱子类
                extSubCatID: nextProps?.detailData?.extSubCatID,//医嘱子类
                medCode: nextProps?.detailData?.medCode,//医嘱代码
                medDesc: nextProps?.detailData?.medDesc,//医嘱描述
                medShortDesc: nextProps?.detailData?.medShortDesc,//医嘱简称
                medPriorityID: nextProps?.detailData?.medPriorityID,//医嘱优先级
                medUnitID: nextProps?.detailData?.medUnitID,//计价单位
                medMessage: nextProps?.detailData?.medMessage,//提示信息
                medSexID: nextProps?.detailData?.medSexID,//性别
                medAgeFrom: nextProps?.detailData?.medAgeFrom,//年龄范围
                medAgeTo: nextProps?.detailData?.medAgeTo,//年龄范围
                medMaxDose: nextProps?.detailData?.medMaxDose,//单次最大量
                medQdMaxQty: nextProps?.detailData?.medQdMaxQty,//单日最大量
                medFreqID: nextProps?.detailData?.medFreqID,//默认频次
                medUsageID: nextProps?.detailData?.medUsageID,//默认用法
                medDurQty: nextProps?.detailData?.medDurQty,//默认疗程数
                medDurationID: nextProps?.detailData?.medDurationID,//默认疗程单位
                medSpec: nextProps?.detailData?.medSpec,//计量规格
                startDate: nextProps?.detailData?.startDate,//生效日期
                stopDate: nextProps?.detailData?.stopDate,//失效日期
                createDate: nextProps?.detailData?.createDate,//创建日期
                createUser: nextProps?.detailData?.createUser,//创建人
                medNoAloneOrder: nextProps?.detailData?.medNoAloneOrder,//非独立医嘱
                medMergeUseFlag: nextProps?.detailData?.medMergeUseFlag,//合并用药
                medNoStockFlag: nextProps?.detailData?.medNoStockFlag,//不判库存
                medNoChangeFlag: nextProps?.detailData?.medNoChangeFlag,//不收费
                medToalCountO: nextProps?.detailData?.medToalCountO,//门诊按总量计算
                medToalCountI: nextProps?.detailData?.medToalCountI,//住院按总量计算
                medEMFlag: nextProps?.detailData?.medEMFlag,//加急标志
                medPrivateFlag: nextProps?.detailData?.medPrivateFlag,//私有标志
                medSkinTestFlag: nextProps?.detailData?.medSkinTestFlag,//皮试
                medCustomPriceFlag: nextProps?.detailData?.medCustomPriceFlag, // 自定义价格标志
                medENDesc: nextProps?.detailData?.medENDesc,//英文描述
                rowData: nextProps?.detailData || {}
            }
        }
        //不需要更新状态，返回null
        return null
    }

    componentDidMount() {
        this.loadSelectData()
    }

    loadSelectData() {
        var params = {
            params: [{
                logonHospID: this.state.userData.hospID,
                logonGroupID: this.state.userData.groupID,
                subCatFlag: 'Y',
                hospFlag: 'Y',
                priorityFlag: 'Y',
                unitFlag: 'Y',
                freFlag: 'Y',
                usageFlag: 'Y',
                durationFlag: 'Y',
                sexFlag: 'Y',
                extSubCatFlag: 'Y', // 扩展子类
            }]
        }
        $http.post('urlDeault', this, {
            code: "03010037",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.setState({
                        subCat: res.result.subCat,
                        hosp: res.result.hosp,
                        priority: res.result.priority,
                        unit: res.result.unit,
                        fre: res.result.fre,
                        usage: res.result.usage,
                        duration: res.result.duration,
                        sex: res.result.sex,
                        extSubCat: res?.result?.extSubCat || [], // 扩展子类
                    }, () => {
                        this.getFormData()
                    })
                }
            }
        });
    }

    // 获取表单数据
    getFormData = () => {
        let { subCat, priority, unit, fre, usage, duration, sex, extSubCat } = this.state;
        // 表单数据
        let formData = [{
            dataIndex: 'medSubCatID',
            title: '医嘱子类',
            typeCode: 'Select',
            detailItem: Array.isArray(subCat) ? subCat : []
        }, {
            dataIndex: 'extSubCatID',
            title: '扩展子类',
            typeCode: 'Select',
            detailItem: Array.isArray(extSubCat) ? extSubCat : []
        }, {
            dataIndex: 'medCode',
            title: '医嘱代码',
            typeCode: 'Input'
        }, {
            dataIndex: 'medDesc',
            title: '医嘱描述',
            typeCode: 'Input'
        }, {
            dataIndex: 'medENDesc',
            title: '英文描述',
            typeCode: 'Input'
        }, {
            dataIndex: 'medShortDesc',
            title: '医嘱简称',
            typeCode: 'Input'
        }, {
            dataIndex: 'medPriorityID',
            title: '医嘱优先级',
            typeCode: 'Select',
            detailItem: Array.isArray(priority) ? priority : []
        }, {
            dataIndex: 'medUnitID',
            title: '计价单位',
            typeCode: 'Select',
            detailItem: Array.isArray(unit) ? unit : []
        }, {
            dataIndex: 'medMessage',
            title: '提示信息',
            typeCode: 'Input'
        }, {
            dataIndex: 'medSexID',
            title: '性别',
            typeCode: 'Select',
            detailItem: Array.isArray(sex) ? sex : []
        }, {
            dataIndex: 'medAgeFrom',
            title: '年龄范围（从）',
            typeCode: 'Input'
        }, {
            dataIndex: 'medAgeTo',
            title: '年龄范围（到）',
            typeCode: 'Input'
        }, {
            dataIndex: 'medMaxDose',
            title: '单次最大量',
            typeCode: 'Input'
        }, {
            dataIndex: 'medQdMaxQty',
            title: '单日最大量',
            typeCode: 'Input'
        }, {
            dataIndex: 'medFreqID',
            title: '默认频次',
            typeCode: 'Select',
            detailItem: Array.isArray(fre) ? fre : []
        }, {
            dataIndex: 'medUsageID',
            title: '默认用法',
            typeCode: 'Select',
            detailItem: Array.isArray(usage) ? usage : []
        }, {
            dataIndex: 'medDurQty',
            title: '默认疗程数',
            typeCode: 'Input'
        }, {
            dataIndex: 'medDurationID',
            title: '默认疗程单位',
            typeCode: 'Select',
            detailItem: Array.isArray(duration) ? duration : []
        }, {
            dataIndex: 'medSpec',
            title: '剂量规格',
            typeCode: 'Input'
        }, {
            dataIndex: 'startDate',
            title: '生效日期',
            typeCode: 'Date'
        }, {
            dataIndex: 'stopDate',
            title: '失效日期',
            typeCode: 'Date'
        }, {
            dataIndex: 'createDate',
            title: '创建日期',
            typeCode: 'Date'
        }, {
            dataIndex: 'createUser',
            title: '创建人',
            typeCode: 'Date'
        }, {
            dataIndex: 'medNoAloneOrder',
            title: '非独立医嘱',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medMergeUseFlag',
            title: '合并用药',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medNoStockFlag',
            title: '不判库存',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medNoChangeFlag',
            title: '不收费',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medToalCountO',
            title: '门诊按总量计算',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medToalCountI',
            title: '住院按总量计算',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medEMFlag',
            title: '加急标志',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medPrivateFlag',
            title: '私有标志',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medSkinTestFlag',
            title: '皮试',
            typeCode: 'Switch'
        }, {
            dataIndex: 'medCustomPriceFlag',
            title: '自定义价格标志',
            typeCode: 'Switch'
        }];
        this.setState({ formData })
    }

    changeCommonDate(name, e) {
        this.setState({
            [name]: e ? moment(e).format(dayFormat) : ''
        })
    }

    //保存之前的校验  createBY:DYK
    saveBeforeFun = () => {
        let { validateFields } = this.props.form;
        let { rowData, formData, medNoAloneOrder, medMergeUseFlag, medNoStockFlag, medNoChangeFlag, medToalCountO, medToalCountI, medSkinTestFlag, medCustomPriceFlag, medPrivateFlag, medEMFlag } = this.state;
        let diffData = [];
        validateFields({ force: true }, (err, params) => {
            if (err) {
                return;
            }
            params.startDate = params.startDate ? moment(params.startDate).format(dayFormat) : '';
            params.stopDate = params.stopDate ? moment(params.stopDate).format(dayFormat) : '';
            params.createDate = params.createDate ? moment(params.createDate).format(dayFormat) : '';
            params['medNoAloneOrder'] = medNoAloneOrder;
            params['medMergeUseFlag'] = medMergeUseFlag;
            params['medNoStockFlag'] = medNoStockFlag;
            params['medNoChangeFlag'] = medNoChangeFlag;
            params['medToalCountO'] = medToalCountO;
            params['medToalCountI'] = medToalCountI;
            params['medSkinTestFlag'] = medSkinTestFlag;
            /**
             * @ByShizi: 添加自定义价格标志
             * Create 2021-10-10
             * */
            params['medCustomPriceFlag'] = medCustomPriceFlag;
            params['medPrivateFlag'] = medPrivateFlag;
            params['medEMFlag'] = medEMFlag;
            for (var keys in params) {
                for (var rowKeys in rowData) {
                    if (keys === rowKeys && params[keys] !== rowData[rowKeys]) {
                        if (!(params[keys] === undefined && rowData[rowKeys] === '')) {
                            let formItemData = Util.returnDataCccordingToAttributes(formData, keys, 'dataIndex');
                            let detailItem = formItemData?.detailItem;
                            let typeCode = formItemData?.typeCode;
                            diffData.push({
                                dataIndex: keys,
                                title: formItemData?.title,
                                new: typeCode === 'Select' && params[keys] && detailItem ? Util.returnDataCccordingToAttributes(detailItem, params[keys]).descripts : params[keys],
                                old: typeCode === 'Select' && rowData[rowKeys] && detailItem ? Util.returnDataCccordingToAttributes(detailItem, rowData[rowKeys]).descripts : rowData[rowKeys]
                            })
                        }
                    }
                }
            }
            /**
            * @ByShizi: 收费项医嘱项修改保存时须展示原信息
            * 需求 #521
            * Create 2022-04-19
            */
            if (diffData && diffData.length > 0) {
                this.diffChild.modifyVisible && this.diffChild.modifyVisible(true, diffData);
            } else {
                message.error("没有修改的数据需要保存。")
            }
        })
    };

    //保存医嘱项信息
    saveBasicMessage() {
        let { validateFields } = this.props.form;
        var date = new Date()
        var rthis = this;
        validateFields((err, params) => {
            if (err) {
                return;
            }
            params['medID'] = rthis.props.params ? rthis.props.params.medID : ''
            params['medNoAloneOrder'] = rthis.state.medNoAloneOrder
            params['medMergeUseFlag'] = rthis.state.medMergeUseFlag
            params['medNoStockFlag'] = rthis.state.medNoStockFlag
            params['medNoChangeFlag'] = rthis.state.medNoChangeFlag
            params['medToalCountO'] = rthis.state.medToalCountO
            params['medToalCountI'] = rthis.state.medToalCountI
            params['medSkinTestFlag'] = rthis.state.medSkinTestFlag
            params['medCustomPriceFlag'] = rthis.state.medCustomPriceFlag
            params['medPrivateFlag'] = rthis.state.medPrivateFlag
            params['medEMFlag'] = rthis.state.medEMFlag
            params['medAgeFrom'] = rthis.state.medAgeFrom
            params['medAgeTo'] = rthis.state.medAgeTo
            params['startDate'] = rthis.state.startDate ? rthis.state.startDate : moment(date).format(dayFormat)
            // params['stopDate'] = rthis.state.stopDate
            params['stopDate'] = params.stopDate ? moment(params.stopDate).format(dayFormat) : ''

            var data = {
                params: [params]
            }
            $http.post('urlDeault', this, {
                code: "02020010",
                data: data,
                success: function (res) {
                    if (res.errorCode == '0') {
                        message.success('保存成功！')
                        rthis.clearInput()
                        var { loadLeftData } = this.props;
                        loadLeftData && loadLeftData()
                    }
                    this.diffChild.modifyVisible && this.diffChild.modifyVisible(false);
                }
            });
        });
    }

    clearInput() {
        this.props.form.resetFields();
        this.setState({
            medCode: undefined,
            medDesc: undefined,
            medShortDesc: undefined,
            medSubCatID: undefined,
            extSubCatID: undefined,
            medPriorityID: undefined,
            medUnitID: undefined,
            medMessage: undefined,
            medMaxDose: undefined,
            medQdMaxQty: undefined,
            medSexID: undefined,
            medAgeFrom: undefined,
            medAgeTo: undefined,
            medUsageID: undefined,
            medFreqID: undefined,
            medDurQty: undefined,
            medDurationID: undefined,
            startDate: undefined,
            stopDate: '',
            medSpec: undefined,
            medNoAloneOrder: undefined,
            medNoStockFlag: undefined,
            medEMFlag: undefined,
            medPrivateFlag: undefined,
            medMergeUseFlag: undefined,
            medNoChangeFlag: undefined,
            medToalCountO: undefined,
            medToalCountI: undefined,
            medSkinTestFlag: undefined,
            medCustomPriceFlag: 'N', // 自定义价格标志
            medENDesc: undefined
        })
        var { clearInput } = this.props;
        clearInput && clearInput()
    }

    changeSwitch(name, e) {
        this.setState({
            [name]: e ? 'Y' : 'N'
        })
    }

    render() {
        let { getFieldDecorator } = this.props.form;
        let { params } = this.props;
        var date = new Date()

        let formItemLayout = {
            labelCol: { span: 9 },
            wrapperCol: { span: 21 }
        };

        let formItemSexLayout = {
            labelCol: { span: 5 },
            wrapperCol: { span: 21 }
        };

        let searchColConfig = {
            xs: { span: 24 },
            sm: { span: 12 },
            md: { span: 8 },
            lg: { span: 6 }
        }

        var { subCat, priority, unit, fre, usage, duration, sex, extSubCat } = this.state;

        //医嘱子类
        var subCatOption = [];
        subCat && subCat.map((item, index) => {
            subCatOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //医嘱优先级
        var priorityOption = []
        priority && priority.map((item, index) => {
            priorityOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //计价单位
        var unitOption = []
        unit && unit.map((item, index) => {
            unitOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //频次
        var freOption = []
        fre && fre.map((item, index) => {
            freOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //用法
        var usageOption = []
        usage && usage.map((item, index) => {
            usageOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //疗程
        var durationOption = []
        duration && duration.map((item, index) => {
            durationOption.push(<Option key={index} value={item.id} code={item.descriptsSPCode}>{item.descripts}</Option>)
        })

        //性别
        var sexOption = []
        sex && sex.map((item, index) => {
            sexOption.push(<Option key={index} value={item.id}>{item.descripts}</Option>)
        })

        return <div className='basic-message-body' style={{ height: store.getState().tableHeight.y + 82 + 'px' }}>
            <Form>
                <Row gutter={40}>
                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="医嘱子类">
                            {getFieldDecorator('medSubCatID', {
                                initialValue: this.state.medSubCatID,
                                rules: [{ required: true, message: '医嘱子类不能为空' }],
                            })(
                                <Select placeholder="请选择医嘱子类" onChange={Util.handleSelectChange.bind(this, 'medSubCatID')}
                                    filterOption={(input, option) =>
                                        option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                        || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    }
                                    allowClear showSearch
                                    getPopupContainer={triggerNode => triggerNode.parentNode}>
                                    {subCatOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="扩展子类">
                            {getFieldDecorator('extSubCatID', {
                                initialValue: this.state.extSubCatID,
                            })(
                                <Select
                                    allowClear
                                    showSearch
                                    optionFilterProp="search"
                                    placeholder="请选择扩展子类"
                                    onChange={Util.handleSelectChange.bind(this, 'extSubCatID')}
                                >
                                    {React.$SelectOptions(extSubCat)}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="医嘱代码">
                            {getFieldDecorator('medCode', {
                                initialValue: this.state.medCode,
                                rules: [{ required: true, message: '医嘱代码不能为空' }],
                            })(
                                <Input placeholder='请输入医嘱代码' onChange={Util.commonInputChange.bind(this, 'medCode')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="医嘱描述">
                            {getFieldDecorator('medDesc', {
                                initialValue: this.state.medDesc,
                                rules: [{ required: true, message: '医嘱描述不能为空' }],
                            })(
                                <Input placeholder='请输入医嘱描述' onChange={Util.commonInputChange.bind(this, 'medDesc')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="英文描述">
                            {getFieldDecorator('medENDesc', {
                                initialValue: this.state.medENDesc,
                                // rules: [{ required: true, message: '英文描述不能为空' }],
                            })(
                                <Input placeholder='请输入英文描述' onChange={Util.commonInputChange.bind(this, 'medENDesc')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="医嘱简称">
                            {getFieldDecorator('medShortDesc', {
                                initialValue: this.state.medShortDesc,
                                rules: [{ required: true, message: '医嘱简称不能为空' }],
                            })(
                                <Input placeholder='请输入医嘱简称' onChange={Util.commonInputChange.bind(this, 'medShortDesc')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="医嘱优先级">
                            {getFieldDecorator('medPriorityID', {
                                initialValue: this.state.medPriorityID,
                            })(
                                <Select placeholder='请选择医嘱优先级' filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                } onChange={Util.handleSelectChange.bind(this, 'medPriorityID')}
                                    allowClear showSearch>
                                    {priorityOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="计价单位">
                            {getFieldDecorator('medUnitID', {
                                initialValue: this.state.medUnitID,
                                rules: [{ required: true, message: '计价单位不能为空' }],
                            })(
                                <Select placeholder='请选择计价单位' filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                }
                                    onChange={Util.handleSelectChange.bind(this, 'medUnitID')}
                                    allowClear showSearch>
                                    {unitOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="提示信息">
                            {getFieldDecorator('medMessage', {
                                initialValue: this.state.medMessage,
                            })(
                                <Input placeholder='请输入提示信息' onChange={Util.commonInputChange.bind(this, 'medMessage')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemSexLayout} label="性别">
                            {getFieldDecorator('medSexID', {
                                initialValue: this.state.medSexID,
                            })(
                                <Select placeholder='请选择性别' allowClear
                                    onChange={Util.handleSelectChange.bind(this, 'medSexID')}>
                                    {sexOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="年龄范围">
                            {getFieldDecorator('medAgeFrom', {
                            })(
                                <div style={{ display: 'flex' }}>
                                    <Input value={this.state.medAgeFrom}
                                        onChange={Util.commonInputChange.bind(this, 'medAgeFrom')} />
                                    <span style={{ margin: '0 5px' }}>到</span>
                                    <Input value={this.state.medAgeTo}
                                        onChange={Util.commonInputChange.bind(this, 'medAgeTo')} />
                                </div>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="单次最大量">
                            {getFieldDecorator('medMaxDose', {
                                initialValue: this.state.medMaxDose,
                            })(
                                <Input placeholder='请输入单次最大量' onChange={Util.commonInputChange.bind(this, 'medMaxDose')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="单日最大量">
                            {getFieldDecorator('medQdMaxQty', {
                                initialValue: this.state.medQdMaxQty,
                            })(
                                <Input placeholder='请输入单日最大量' onChange={Util.commonInputChange.bind(this, 'medQdMaxQty')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="默认频次">
                            {getFieldDecorator('medFreqID', {
                                initialValue: this.state.medFreqID,
                            })(
                                <Select placeholder='请选择频次' filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                } onChange={Util.handleSelectChange.bind(this, 'medFreqID')}
                                    allowClear showSearch>
                                    {freOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="默认用法">
                            {getFieldDecorator('medUsageID', {
                                initialValue: this.state.medUsageID,
                            })(
                                <Select placeholder='请选择用法' filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                } onChange={Util.handleSelectChange.bind(this, 'medUsageID')}
                                    allowClear showSearch>
                                    {usageOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="默认疗程数">
                            {getFieldDecorator('medDurQty', {
                                initialValue: this.state.medDurQty,
                            })(
                                <Input placeholder='请输入疗程数' onChange={Util.commonInputChange.bind(this, 'medDurQty')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="默认疗程单位">
                            {getFieldDecorator('medDurationID', {
                                initialValue: this.state.medDurationID,
                            })(
                                <Select placeholder='请选择疗程单位' filterOption={(input, option) =>
                                    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                    || option.props.code.toLowerCase().indexOf(input.toLowerCase()) >= 0
                                } onChange={Util.handleSelectChange.bind(this, 'medDurationID')}
                                    allowClear showSearch>
                                    {durationOption}
                                </Select>
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="剂量规格">
                            {getFieldDecorator('medSpec', {
                                initialValue: this.state.medSpec,
                                // rules: [{ required: true, message: '剂量规格不能为空' }],
                            })(
                                <Input placeholder='请输入剂量规格' onChange={Util.commonInputChange.bind(this, 'medSpec')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="生效日期">
                            {getFieldDecorator('startDate', {
                                initialValue: this.state.startDate ? moment(this.state.startDate, dayFormat) : moment(date, dayFormat),
                                rules: [{ required: true, message: '生效日期不能为空' }],
                            })(
                                <DatePicker onChange={this.changeCommonDate.bind(this, 'startDate')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="失效日期">
                            {getFieldDecorator('stopDate', {
                                initialValue: this.state.stopDate ? moment(this.state.stopDate, dayFormat) : '',
                            })(
                                <DatePicker onChange={this.changeCommonDate.bind(this, 'stopDate')} />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="创建日期">
                            {getFieldDecorator('createDate', {
                                initialValue: this.state.createDate ? moment(this.state.createDate, dayFormat) : '',
                            })(
                                <DatePicker disabled={true} format="YYYY-MM-DD" />
                            )}
                        </FormItem>
                    </Col>

                    <Col {...searchColConfig}>
                        <FormItem {...formItemLayout} label="创建人">
                            {getFieldDecorator('createUser', {
                                initialValue: this.state.createUser,
                            })(
                                <Input placeholder='请输入创建人' disabled={true} onChange={Util.commonInputChange.bind(this, 'createUser')} />
                            )}
                        </FormItem>
                    </Col>
                </Row>
                <div style={{ display: 'flex' }}>
                    <div>
                        <div>非独立医嘱</div>
                        <Switch checked={this.state.medNoAloneOrder == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medNoAloneOrder')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>合并用药</div>
                        <Switch checked={this.state.medMergeUseFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medMergeUseFlag')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>不判库存</div>
                        <Switch checked={this.state.medNoStockFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medNoStockFlag')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>不收费</div>
                        <Switch checked={this.state.medNoChangeFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medNoChangeFlag')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>门诊按总量计算</div>
                        <Switch checked={this.state.medToalCountO == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medToalCountO')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>住院按总量计算</div>
                        <Switch checked={this.state.medToalCountI == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medToalCountI')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>加急标志</div>
                        <Switch checked={this.state.medEMFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medEMFlag')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>私有标志</div>
                        <Switch checked={this.state.medPrivateFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medPrivateFlag')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>皮试</div>
                        <Switch checked={this.state.medSkinTestFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medSkinTestFlag')} />
                    </div>
                    <div style={{ marginLeft: 10 }}>
                        <div>自定义价格标志</div>
                        <Switch checked={this.state.medCustomPriceFlag == 'Y' ? true : false}
                            onChange={this.changeSwitch.bind(this, 'medCustomPriceFlag')} />
                    </div>
                    <Button style={{ marginLeft: 20 }} onClick={this.clearInput.bind(this)}>{!Util.isEmpty(this.props.detailData) ? '取消' : '清空'}</Button>
                    {/*changeBY:DYK  saveBeforeFun*/}
                    <Button
                        type='primary'
                        style={{ marginLeft: 10 }}
                        onClick={params && 'medID' in params && params.medID ? this.saveBeforeFun.bind(this) : this.saveBasicMessage.bind(this)}
                    >保存</Button>
                </div>

                {/*修改时差异提醒*/}
                <FormDataDifferenceComparison onRef={ref => this.diffChild = ref} onOk={this.saveBasicMessage.bind(this)} />
            </Form>
        </div>
    }

}
export default Form.create()(BasicInformationTabPane);