// 本院信息
import React from 'react';
import { Card, Row, Col, Form, DatePicker, Select, Switch, Input } from 'antd';
import Moment from 'moment';

const { Option } = Select;
const FormItem = Form.Item;
const formItemItem = {
    labelCol: { span: 11 },
    wrapperCol: { span: 13 }
};

class OurInformationClass extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            language: JSON.parse(window.sessionStorage.userData),
            userInfo: {},
            ChineseEnglishSize: {},
            SelectData: {},
        }
    }

    componentDidMount() {
        this.props.onRef(this);
    }

    //清空表格内容
    resetFields = () => {
        this.props.form.resetFields();
    };

    setData = () => {
        this.props.form.validateFields((errors, values) => {
            let obj = JSON.parse(JSON.stringify(values));
            this.props.handleThis.setOurInformationData(obj)
        });
    }

    render() {
        const { getFieldDecorator } = this.props.form;
        const SelectData = this.props.SelectData;
        const userInfo = this.props.userInfo;
        const ChineseEnglishSize = this.props.ChineseEnglishSize;

        // 批准文号前缀
        let approvalPrefix = SelectData && SelectData.approvalPrefix && SelectData.approvalPrefix.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 招标名称
        let pubBidList = SelectData && SelectData.pubBidList && SelectData.pubBidList.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 住院收据费用
        let pubBidVendor = SelectData && SelectData.pubBidVendor && SelectData.pubBidVendor.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 会计科目
        let pubBidManf = SelectData && SelectData.pubBidManf && SelectData.pubBidManf.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 门诊收据费用
        let pubBidLevel = SelectData && SelectData.pubBidLevel && SelectData.pubBidLevel.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 病案分类
        let refRetReason = SelectData && SelectData.refRetReason && SelectData.refRetReason.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 收费分类
        let stopReason = SelectData && SelectData.stopReason && SelectData.stopReason.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        });
        // 大包装单位
        let packUnitData = SelectData && SelectData.unit && SelectData.unit.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        });
        return (
            <Card
                type="inner"
                title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.HosMaterialInfoMaintenanceourInformation ? ChineseEnglishSize.HosMaterialInfoMaintenanceourInformation.descripts : '本院信息'}</div>}
                size="small"
            >
                <form>
                    <Row>
                        <Col span={8}>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancepackUnitID ? ChineseEnglishSize.HosMaterialInfoMaintenancepackUnitID.descripts : '大包装单位'}>
                                {getFieldDecorator('packUnitID', {
                                    initialValue: userInfo.packUnitID ? userInfo.packUnitID : undefined,
                                    rules: [{ required: false, message: '大包装单位是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                        style={{ width: '100%' }}
                                    >
                                        {packUnitData}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenanceappPreFixID ? ChineseEnglishSize.HosMaterialInfoMaintenanceappPreFixID.descripts : '批准文号前缀'}>
                                {getFieldDecorator('appPreFixID', {
                                    initialValue: userInfo.appPreFixID ? userInfo.appPreFixID : undefined,
                                    rules: [{ required: false, message: '批准文号前缀是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {approvalPrefix}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancePBLID ? ChineseEnglishSize.HosMaterialInfoMaintenancePBLID.descripts : '招标名称'}>
                                {getFieldDecorator('PBLID', {
                                    initialValue: userInfo.PBLID ? userInfo.PBLID : undefined,
                                    rules: [{ required: false, message: '招标名称是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {pubBidList}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancePBManfID ? ChineseEnglishSize.HosMaterialInfoMaintenancePBManfID.descripts : '招标生产企业'}>
                                {getFieldDecorator('PBManfID', {
                                    initialValue: userInfo.PBManfID ? userInfo.PBManfID : undefined,
                                    rules: [{ required: false, message: '招标生产企业是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {pubBidManf}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate ? ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate.descripts : '生效日期'}>
                                {getFieldDecorator('stockStartDate', {
                                    initialValue: userInfo.stockStartDate ? Moment(userInfo.stockStartDate) : Moment(),
                                    rules: [{ required: true, message: '生效日期是必填项,请选择！' }]
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        style={{ width: '100%' }}
                                        placeholder=' '
                                    >
                                    </DatePicker>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancemedEndDate ? ChineseEnglishSize.HosMaterialInfoMaintenancemedEndDate.descripts : '失效日期'}>
                                {getFieldDecorator('stockEndDate', {
                                    initialValue: userInfo.stockEndDate ? Moment(userInfo.stockEndDate) : undefined,
                                    rules: []
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        style={{ width: '100%' }}
                                        placeholder=' '
                                    >
                                    </DatePicker>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancepackFac ? ChineseEnglishSize.HosMaterialInfoMaintenancepackFac.descripts : '大包装系数'}>
                                {getFieldDecorator('packFac', {
                                    initialValue: userInfo.packFac ? userInfo.packFac : undefined,
                                    rules: [{ required: false, message: '大包装系数是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenanceapprovalNo ? ChineseEnglishSize.HosMaterialInfoMaintenanceapprovalNo.descripts : '批准文号'}>
                                {getFieldDecorator('approvalNo', {
                                    initialValue: userInfo.approvalNo ? userInfo.approvalNo : undefined,
                                    rules: [{ required: false, message: '批准文号是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancePBRp ? ChineseEnglishSize.HosMaterialInfoMaintenancePBRp.descripts : '招标进价'}>
                                {getFieldDecorator('PBRp', {
                                    initialValue: userInfo.PBRp ? userInfo.PBRp : undefined,
                                    rules: [{ required: false, message: '招标进价是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancePBLevID ? ChineseEnglishSize.HosMaterialInfoMaintenancePBLevID.descripts : '招标级别'}>
                                {getFieldDecorator('PBLevID', {
                                    initialValue: userInfo.PBLevID ? userInfo.PBLevID : undefined,
                                    rules: [{ required: false, message: '招标级别是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {pubBidLevel}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancepurPlanCode ? ChineseEnglishSize.HosMaterialInfoMaintenancepurPlanCode.descripts : '采购编码'}>
                                {getFieldDecorator('purPlanCode', {
                                    initialValue: userInfo.purPlanCode ? userInfo.purPlanCode : undefined,
                                    rules: [{ required: false, message: '采购编码是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancestopReaID ? ChineseEnglishSize.HosMaterialInfoMaintenancestopReaID.descripts : '失效原因'}>
                                {getFieldDecorator('stopReaID', {
                                    initialValue: userInfo.stopReaID ? userInfo.stopReaID : undefined,
                                    rules: [{ required: false, message: '失效原因是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {stopReason}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancepackPicPath ? ChineseEnglishSize.HosMaterialInfoMaintenancepackPicPath.descripts : '包装图片路径'}>
                                {getFieldDecorator('packPicPath', {
                                    initialValue: userInfo.packPicPath ? userInfo.packPicPath : undefined,
                                    rules: [{ required: false, message: '包装图片路径是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancestandCode ? ChineseEnglishSize.HosMaterialInfoMaintenancestandCode.descripts : '本位码'}>
                                {getFieldDecorator('standCode', {
                                    initialValue: userInfo.standCode ? userInfo.standCode : undefined,
                                    rules: [{ required: false, message: '本位码是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancePBVendorID ? ChineseEnglishSize.HosMaterialInfoMaintenancePBVendorID.descripts : '招标供应商'}>
                                {getFieldDecorator('PBVendorID', {
                                    initialValue: userInfo.PBVendorID ? userInfo.PBVendorID : undefined,
                                    rules: [{ required: false, message: '招标供应商是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {pubBidVendor}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenancerefRetReaID ? ChineseEnglishSize.HosMaterialInfoMaintenancerefRetReaID.descripts : '不可退原因'}>
                                {getFieldDecorator('refRetReaID', {
                                    initialValue: userInfo.refRetReaID ? userInfo.refRetReaID : undefined,
                                    rules: [{ required: false, message: '不可退原因是必填项,请选择！' }]
                                })(
                                    <Select
                                        allowClear={true}
                                        showSearch
                                        optionFilterProp="seatchprop"
                                        style={{ width: '100%' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        {refRetReason}
                                    </Select>
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenanceinMedBasis ? ChineseEnglishSize.HosMaterialInfoMaintenanceinMedBasis.descripts : '进药依据'}>
                                {getFieldDecorator('inMedBasis', {
                                    initialValue: userInfo.inMedBasis ? userInfo.inMedBasis : undefined,
                                    rules: [{ required: false, message: '进药依据是必填项,请选择！' }]
                                })(
                                    <Input />
                                )}
                            </FormItem>
                            <FormItem {...formItemItem} label={ChineseEnglishSize.HosMaterialInfoMaintenanceisHospFlag ? ChineseEnglishSize.HosMaterialInfoMaintenanceisHospFlag.descripts : '院内目录'}>
                                {getFieldDecorator('isHospFlag', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.isHospFlag === 'Y' ? true : false,
                                })(
                                    this.state.language.language == "EN" ? <Switch checkedChildren="yes" unCheckedChildren="no" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                </form>
            </Card>
        )
    }
};
let OurInformation = Form.create()(OurInformationClass);
export default OurInformation;