// 库存项---存储条件 
import React from 'react';
import {Form, Button, Input, Row, Col, Switch, Card} from 'antd';

const FormItem = Form.Item;

class AIIStorageCondition extends React.Component {
    componentDidMount() {
        this.props.onRef(this);
    }

    handleValidateFields = () => {
        const { form: { validateFields } } = this.props;
        validateFields((errors, values) => {
            // 验证成功
            if (errors === null) {
                let obj = JSON.parse(JSON.stringify(values));
                obj.commonTemp = obj.commonTemp ? 'Y' : 'N';
                obj.radiation = obj.radiation ? 'Y' : 'N';
                obj.coldST = obj.coldST ? 'Y' : 'N';
                obj.dry = obj.dry ? 'Y' : 'N';
                obj.seal = obj.seal ? 'Y' : 'N';
                obj.freeze = obj.freeze ? 'Y' : 'N';
                obj.airtight = obj.airtight ? 'Y' : 'N';
                obj.gloomyCool = obj.gloomyCool ? 'Y' : 'N';
                obj.dampProof = obj.dampProof ? 'Y' : 'N';
                obj.dark = obj.dark ? 'Y' : 'N';
                obj.meltPack = obj.meltPack ? 'Y' : 'N';
                obj.shade = obj.shade ? 'Y' : 'N';
                this.props.receiveSubcomponentsValue(obj, 'storageCondition')
            }
        })
    }

    // 重置数据
    resetFields = () => {
        this.props.form.resetFields();
    }

    render() {
        const { getFieldDecorator } = this.props.form;
        const formItemItem  = {
            labelCol: {span: 12},
            wrapperCol: {span: 12}
        };
        const formItemCheckbox  = {
            labelCol: {span: 14},
            wrapperCol: {span: 10}
        };
        let userInfo = this.props.userInfo;
        let ChineseEnglishSize = this.props.ChineseEnglishSize;
        let language = JSON.parse(window.sessionStorage.userData);
        return (
            <Card
                type="inner"
                title={ChineseEnglishSize.DrugMaintenancestorageCondition ? ChineseEnglishSize.DrugMaintenancestorageCondition.descripts:'存储条件'}
                size="small"
            >
                <Form style={{padding: '0 12px'}}>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenanceminTemp ? ChineseEnglishSize.DrugMaintenanceminTemp.descripts:'最低温度(°C)'} {...formItemItem}>
                                {getFieldDecorator('minTemp', {
                                    initialValue: userInfo.minTemp ? userInfo.minTemp : undefined,
                                })(
                                    <Input style={{width: '100%'}} type="number" className="input-number" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancecommonTemp ? ChineseEnglishSize.DrugMaintenancecommonTemp.descripts:'常温'} {...formItemCheckbox}>
                                {getFieldDecorator('commonTemp', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.commonTemp === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenanceradiation ? ChineseEnglishSize.DrugMaintenanceradiation.descripts:'防辐射'} {...formItemCheckbox}>
                                {getFieldDecorator('radiation', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.radiation === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancecoldST ? ChineseEnglishSize.DrugMaintenancecoldST.descripts:'冷藏'} {...formItemCheckbox}>
                                {getFieldDecorator('coldST', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.coldST === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancemaxTemp ? ChineseEnglishSize.DrugMaintenancemaxTemp.descripts:'最高温度(°C)'} {...formItemItem}>
                                {getFieldDecorator('maxTemp', {
                                    initialValue: userInfo.maxTemp ? userInfo.maxTemp : undefined,
                                })(
                                    <Input style={{width: '100%'}} type="number" className="input-number" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancedry ? ChineseEnglishSize.DrugMaintenancedry.descripts:'干燥'} {...formItemCheckbox}>
                                {getFieldDecorator('dry', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.dry === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenanceseal ? ChineseEnglishSize.DrugMaintenanceseal.descripts:'熔封'} {...formItemCheckbox}>
                                {getFieldDecorator('seal', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.seal === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancefreeze ? ChineseEnglishSize.DrugMaintenancefreeze.descripts:'冷冻'} {...formItemCheckbox}>
                                {getFieldDecorator('freeze', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.freeze === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenanceminHumidity ? ChineseEnglishSize.DrugMaintenanceminHumidity.descripts:'最低湿度'} {...formItemItem}>
                                {getFieldDecorator('minHumidity', {
                                    initialValue: userInfo.minHumidity ? userInfo.minHumidity : undefined,
                                })(
                                    <Input style={{width: '100%'}} type="number" className="input-number" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenanceairtight ? ChineseEnglishSize.DrugMaintenanceairtight.descripts:'封闭'} {...formItemCheckbox}>
                                {getFieldDecorator('airtight', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.airtight === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancegloomyCool ? ChineseEnglishSize.DrugMaintenancegloomyCool.descripts:'凉暗'} {...formItemCheckbox}>
                                {getFieldDecorator('gloomyCool', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.gloomyCool === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancedampProof ? ChineseEnglishSize.DrugMaintenancedampProof.descripts:'防潮'} {...formItemCheckbox}>
                                {getFieldDecorator('dampProof', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.dampProof === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span={8}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancemaxHumidity ? ChineseEnglishSize.DrugMaintenancemaxHumidity.descripts:'最高湿度'} {...formItemItem}>
                                {getFieldDecorator('maxHumidity', {
                                    initialValue: userInfo.maxHumidity ? userInfo.maxHumidity : undefined,
                                })(
                                    <Input style={{width: '100%'}} type="number" className="input-number" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancedark ? ChineseEnglishSize.DrugMaintenancedark.descripts:'遮光'} {...formItemCheckbox}>
                                {getFieldDecorator('dark', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.dark === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenancemeltPack ? ChineseEnglishSize.DrugMaintenancemeltPack.descripts:'密封'} {...formItemCheckbox}>
                                {getFieldDecorator('meltPack', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.meltPack === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                        <Col span={5}>
                            <FormItem label={ChineseEnglishSize.DrugMaintenanceshade ? ChineseEnglishSize.DrugMaintenanceshade.descripts:'阴凉'} {...formItemCheckbox}>
                                {getFieldDecorator('shade', {
                                    valuePropName: 'checked',
                                    initialValue: userInfo.shade === 'Y' ? true : false,
                                })(
                                    language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否" />
                                )}
                            </FormItem>
                        </Col>
                    </Row>
                </Form>
            </Card>
        )
    }
};
let AIIStorageConditionForm = Form.create()(AIIStorageCondition);
export default AIIStorageConditionForm;