// 收费项信息
import React from 'react';
import {Card, Row, Col, Form, DatePicker, Select, Checkbox, Switch, Input } from 'antd';
import { $http } from 'containers/config/https';
import { Util } from 'tools/index';
import Moment from 'moment';
const { Option } = Select;
const FormItem = Form.Item;
const formItemItem  = {
    labelCol: {span: 11},
    wrapperCol: {span: 13}
};
class FeeInformationClass 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.setFeeInformationData(obj)
        });
    }
    render() {
        const { getFieldDecorator } = this.props.form;
        const SelectData = this.props.SelectData;
        const userInfo = this.props.userInfo;
        const ChineseEnglishSize = this.props.ChineseEnglishSize;
        const stateEsit = this.props.value == 'common' ? true : false

        // 物价分类
        let itemPCIDOption = SelectData&&SelectData.PC&&SelectData.PC.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 核算项目分类
        let itemECIDOption = SelectData&&SelectData.EC&&SelectData.EC.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 住院收据费用
        let itemICIDOption = SelectData&&SelectData.OC&&SelectData.OC.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 会计科目
        let itemACIDOption = SelectData&&SelectData.AC&&SelectData.AC.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 门诊收据费用
        let itemOCIDOption = SelectData&&SelectData.IC&&SelectData.IC.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 病案分类
        let itemMCIDOption = SelectData&&SelectData.MC&&SelectData.MC.map((item, index) => {
            return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
        })
        // 收费分类
        let itemTCIDOption = SelectData&&SelectData.TC&&SelectData.TC.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.HosMaterialInfoMaintenanceCharges ? ChineseEnglishSize.HosMaterialInfoMaintenanceCharges.descripts:'收费项'}</div>}
                size="small"
            >
                <form>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceitemPCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemPCDesc.descripts:'物价分类：'} {...formItemItem}>
                                {getFieldDecorator('itemPCID', {
                                    initialValue: userInfo.itemPCID ? userInfo.itemPCID : undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceitemPCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemPCDesc.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceitemPCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemPCDesc.message:'请选择物价分类'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear disabled={stateEsit}>
                                        {itemPCIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceitemECDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemECDesc.descripts:'核算项目分类：'} {...formItemItem}>
                                {getFieldDecorator('itemECID', {
                                    initialValue: userInfo.itemECID ? userInfo.itemECID : undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceitemECDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemECDesc.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceitemECDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemECDesc.message:'请选择核算项目分类'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear  disabled={stateEsit}>
                                        {itemECIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceitemCode ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemCode.descripts:'收费项代码：'} {...formItemItem}>
                                {getFieldDecorator('itemCode', {
                                    initialValue:  userInfo.itemCode ? userInfo.itemCode : undefined,
                                })(
                                    <Input style={{width: '100%'}} disabled />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceHospitalRceipt ? ChineseEnglishSize.HosMaterialInfoMaintenanceHospitalRceipt.descripts:'住院收据费用：'} {...formItemItem}>
                                {getFieldDecorator('itemICID', {
                                    initialValue: userInfo.itemICID ? userInfo.itemICID : undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceHospitalRceipt ? ChineseEnglishSize.HosMaterialInfoMaintenanceHospitalRceipt.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceHospitalRceipt ? ChineseEnglishSize.HosMaterialInfoMaintenanceHospitalRceipt.message:'请选择住院收据费用'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear  disabled={stateEsit}>
                                        {itemICIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceSubjects ? ChineseEnglishSize.HosMaterialInfoMaintenanceSubjects.descripts:'会计科目：'} {...formItemItem}>
                                {getFieldDecorator('itemACID', {
                                    initialValue:  userInfo.itemACID ? userInfo.itemACID : undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceSubjects ? ChineseEnglishSize.HosMaterialInfoMaintenanceSubjects.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceSubjects ? ChineseEnglishSize.HosMaterialInfoMaintenanceSubjects.message:'请选择会计科目'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear  disabled={stateEsit}>
                                        {itemACIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceitemDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemDesc.descripts:'收费项描述：'} {...formItemItem}>
                                {getFieldDecorator('itemDesc', {
                                    initialValue: userInfo.itemDesc ? userInfo.itemDesc: undefined,
                                })(
                                    <Input style={{width: '100%'}} disabled />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceOutpatientReceipt  ? ChineseEnglishSize.HosMaterialInfoMaintenanceOutpatientReceipt.descripts:'门诊收据费用：'} {...formItemItem}>
                                {getFieldDecorator('itemOCID', {
                                    initialValue:  userInfo.itemOCID ? userInfo.itemOCID: undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceOutpatientReceipt ? ChineseEnglishSize.HosMaterialInfoMaintenanceOutpatientReceipt.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceOutpatientReceipt ? ChineseEnglishSize.HosMaterialInfoMaintenanceOutpatientReceipt.message:'请选择门诊收据费用'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear  disabled={stateEsit}>
                                        {itemOCIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceitemMCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemMCDesc.descripts:'病案分类：'} {...formItemItem}>
                                {getFieldDecorator('itemMCID', {
                                    initialValue: userInfo.itemMCID ? userInfo.itemMCID : undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceitemMCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemMCDesc.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceitemMCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemMCDesc.message:'请输入病案分类'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear  disabled={stateEsit}>
                                        {itemMCIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenanceitemTCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemTCDesc.descripts:'收费分类：'} {...formItemItem}>
                                {getFieldDecorator('itemTCID', {
                                    initialValue:  userInfo.itemTCID ? userInfo.itemTCID : undefined,
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenanceitemTCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemTCDesc.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenanceitemTCDesc ? ChineseEnglishSize.HosMaterialInfoMaintenanceitemTCDesc.message:'请输入收费分类'}]
                                })(
                                    <Select style={{width: '100%'}} showSearch optionFilterProp="seatchprop" allowClear  disabled={stateEsit}>
                                        {itemTCIDOption}
                                    </Select>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate ? ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate.descripts:'生效日期：'} {...formItemItem}>
                                {getFieldDecorator('itemStDate', {
                                    initialValue:  userInfo.itemStartDate ? Moment(userInfo.itemStartDate) : Moment(),
                                    rules:[{ required : ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate ? ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate.required =='Y'? true:false: false, message: ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate ? ChineseEnglishSize.HosMaterialInfoMaintenancestockStartDate.message:'请选择生效日期'}]
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        style={{width:'100%'}}
                                        disabled={stateEsit}
                                        placeholder=' '
                                    >
                                    </DatePicker>
                                )}
                            </FormItem>
                        </Col>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.HosMaterialInfoMaintenancemedEndDate ? ChineseEnglishSize.HosMaterialInfoMaintenancemedEndDate.descripts:'失效日期：'} {...formItemItem}>
                                {getFieldDecorator('itemEndDate', {
                                    initialValue:   userInfo.itemEndDate ? Moment(userInfo.itemEndDate) : undefined,
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        style={{width:'100%'}}
                                        disabled={stateEsit}
                                        placeholder=' '
                                    >
                                    </DatePicker>
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                </form>
            </Card>
        )
    }
};
let FeeInformation = Form.create()(FeeInformationClass);
export default FeeInformation;