import React, { Component } from 'react';

import { Tabs, Form, Row, Col, Checkbox, Select, Switch, Table, Icon } from 'antd';

const Option = Select.Option;
const DoctorOrderForm = Form.create()(
    class DoctorOrderConfig extends Component {

        constructor(props) {
            super(props);
            this.state = {
                DateType: "",
                TimeType: "",
                DiscardFlag: false,
                CancelFlag: false,
                TransLocLine: false,
                TransLocPage: false,
                ReformLine: false,
                ReformPage: false,
                DeliverLine: false,
                DeliverPage: false,
                // DeliverLinkOrd: "",
                OprationLine: false,
                OprationPage: false,
                // OprationLinkOrd: "",
            }
        }
        componentDidMount() {
            this.props.onRef(this);
        }
        componentWillUnmount() {
            this.setState = (state, callback) => {
                return
            }
        }
        componentWillReceiveProps(nextProps) {

        }
        // 重置表单
        resetFields() {
            this.props.form.resetFields();
        }
        /** 快捷筛选 */
        filterOption = (input, option) => {
            return ((option.props.title.toLowerCase().indexOf(input.toLowerCase()) >= 0) || (option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0))
        }
        normalizeAll = (value, prevValue = []) => {
            return value;
        };
        render() {
            const { getFieldDecorator } = this.props.form;

            let propsData = this.props.FromData;
            const formItemInput = {
                labelCol: { span: 9 },
                wrapperCol: { span: 15 }
            };
            const formItemSelect = {
                labelCol: { span: 4 },
                wrapperCol: { span: 20 }
            };


            return (
                <Form layout="horizontal" style={{ padding: '0 50px', height: "100%" }} labelalign="left" >
                    <Row gutter={16}>
                        <Col span={5}>
                            <Form.Item label="日期格式" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("DateType", {
                                    initialValue: propsData.DateType === undefined ? "3" : propsData.DateType + "",
                                })(
                                    <Select>
                                        <Option value="3">YYYY-MM-DD</Option>
                                        <Option value="1">MM/DD/YYY</Option>
                                        <Option value="2">MM-DD</Option>
                                        <Option value="4">DD/MM</Option>
                                    </Select>
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="时间格式" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("TimeType", {
                                    initialValue: propsData.TimeType === undefined ? "2" : propsData.TimeType + "",
                                })(
                                    <Select>
                                        <Option value="1">HH:mm:ss</Option>
                                        <Option value="2">HH:mm</Option>
                                    </Select>
                                )
                                }
                            </Form.Item>
                        </Col>
                    </Row>

                    <Row gutter={16}>
                        <Col span={5}>
                            <Form.Item label="显示作废医嘱" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("DiscardFlag", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.DiscardFlag === "Y") && (propsData.DiscardFlag)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="显示撤销医嘱" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("CancelFlag", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.CancelFlag === "Y") && (propsData.CancelFlag)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="转科划线" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("TransLocLine", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.TransLocLine === "Y") && (propsData.TransLocLine)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="转科换页" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("TransLocPage", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.TransLocPage === "Y") && (propsData.TransLocPage)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                    </Row>

                    <Row gutter={16}>
                        <Col span={5}>
                            <Form.Item label="重整划线" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("ReformLine", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.ReformLine === "Y") && (propsData.ReformLine)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="重整换页" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("ReformPage", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.ReformPage === "Y") && (propsData.ReformPage)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="分娩划线" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("DeliverLine", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.DeliverLine === "Y") && (propsData.DeliverLine)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="分娩换页" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("DeliverPage", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.DeliverPage === "Y") && (propsData.DeliverPage)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        {/* <Col span={12}>
                            <Form.Item label="分娩关联医嘱" style={{ height: '40px' }} {...formItemSelect}>
                                {getFieldDecorator("DeliverLinkOrd", {
                                    initialValue: ((propsData.DeliverLinkOrd === undefined) || (propsData.DeliverLinkOrd === "")) ? [] : propsData.DeliverLinkOrd,

                                })(
                                    <Select mode="multiple" filterOption={this.filterOption } >
                                        {
                                            this.props.MedItem.map((itemData) => {
                                                return (
                                                    <Option key={itemData.id} value={itemData.id}  title={itemData.descriptsSPCode} >{itemData.descripts}</Option>
                                                )
                                            })
                                        }
                                    </Select>
                                )
                                }
                            </Form.Item>
                        </Col> */}
                    </Row>

                    <Row gutter={16}>
                        <Col span={5}>
                            <Form.Item label="手术划线" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("OprationLine", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.OprationLine === "Y") && (propsData.OprationLine)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        <Col span={5}>
                            <Form.Item label="手术换页" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("OprationPage", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.OprationPage === "Y") && (propsData.OprationPage)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                        {/* <Col span={12}>
                            <Form.Item label="手术关联医嘱" style={{ height: '40px' }} {...formItemSelect}>
                                {getFieldDecorator("OprationLinkOrd", {
                                    initialValue: ((propsData.OprationLinkOrd === undefined) || (propsData.OprationLinkOrd === "")) ? [] : propsData.OprationLinkOrd,
                                })(

                                    <Select mode="multiple" filterOption={this.filterOption } >
                                        {
                                            this.props.MedItem.map((itemData) => {
                                                return (
                                                    <Option key={itemData.id} value={itemData.id} title={itemData.descriptsSPCode}>{itemData.descripts}</Option>
                                                )
                                            })
                                        }
                                    </Select>

                                )
                                }
                            </Form.Item>
                        </Col> */}
                        <Col span={5}>
                            <Form.Item label="显示收费项" style={{ height: '40px' }} {...formItemInput}>
                                {getFieldDecorator("chargeItem", {
                                    valuePropName: 'checked',
                                    initialValue: ((propsData.chargeItem === "Y") && (propsData.chargeItem)) ? true : false,
                                })(
                                    <Switch checkedChildren="是" unCheckedChildren="否" />
                                )
                                }
                            </Form.Item>
                        </Col>
                    </Row>


                </Form>

            );
        }

    });

export default DoctorOrderForm;