import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, Switch } from 'antd';

const CreateRecordForm = (props) => {
    const [isAdd, setisAdd] = useState(false);
    return (
        <Modal
            width={800}
            visible={props.createModalVisible}
            bodyStyle={{ padding: '32px 40px 48px' }}
            footer={null}
            onCancel={() => {
                props.onCancel();
            }}
            destroyOnClose
        >
            <Form
                layout="Vertical"
                labelCol={{ span: 6 }}
                initialValues={props.values}
                onFinish={props.onFinish}
                onCancel={props.onCancel}
            >
                <Form.Item name="id" hidden={true}>
                    <Input />
                </Form.Item>
                <Form.Item label='做法名称' name={'makeName'} >
                    <Input></Input>
                </Form.Item>
                <Form.Item label='做法类别' name={'makeTypeId'} initialValue={props.values.practiceTypeId}>
                    <Select style={{ width: '300px' }}
                    >
                        {
                            (props.TypeList || []).map((item, index) => {
                                return (
                                    <Select.Option index={index} value={item.id} key={item.typeName}>
                                        {item.typeName}
                                    </Select.Option>
                                );
                            })
                        }
                    </Select>
                </Form.Item>
                <Form.Item label='做法编码' name={'code'}   >
                    <Input disabled={props.values.code}></Input>
                </Form.Item>
                <Form.Item label='加价' name={'raise'} initialValue={props.values.raise || 0}>
                <Select style={{ width: '300px' }}>
                        <Select.Option value={0} key={0} index={0} >
                            0
                        </Select.Option>
                        <Select.Option value={1} key={1} index={1} >
                            1
                        </Select.Option>
                    </Select>
                </Form.Item>
                <Form.Item label='加价方式' name={'raiseType'}  initialValue={props.values.raiseType}>
                    <Select style={{ width: '300px' }}>
                        <Select.Option value={1} key={1} index={1} >
                            按出品数量加价
                        </Select.Option>
                        <Select.Option value={2} key={2} index={2} >
                            加价与出品数量无关
                        </Select.Option>
                    </Select>
                </Form.Item>
                <Form.Item>
                    <Button type="primary" htmlType="submit" >
                        保存
                    </Button>
                </Form.Item>
            </Form>
        </Modal>
    );
};

export default CreateRecordForm;
