import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, TreeSelect, Space, Checkbox, Col, Row,  Switch,DatePicker } from 'antd';
import moment from 'moment';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import record from '@/pages/crm/coupon/coupon-Batch/components/ShowRecord';
const { TextArea } = Input;

const CommonRuleForm = (props) => {
    return (
        <Modal
            width={840}
            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="ruleType" initialValue={props.Data.ruleType} hidden={true} >
                    <Input />
                </Form.Item>
                <Form.Item label={'消费金额'} name='thresholdPriceKey' hidden={props.Data.type == 'price' ? false : true}  >
                    <Input />
                </Form.Item>
                <Form.Item label={'积分取整'} name="OpenUnFloor" initialValue={props.values.isUnFloor==1} hidden={props.Data.type == 'price' ? false : true} valuePropName="checked">
                    <Switch />
                </Form.Item>
                <Form.Item label={'出品数量'} name='thresholdNumberKey' hidden={props.Data.type == 'number' ? false : true}>
                    <Input />
                </Form.Item>
                <Form.Item label={'用餐人数'} name='thresholdPersonsKey' hidden={props.Data.type == 'persons' ? false : true} >
                    <Input />
                </Form.Item>
                <Form.Item label={'消费次数'} name='thresholdCountKey' hidden={props.Data.type == 'count' ? false : true} >
                    <Input />
                </Form.Item>
                <Form.Item label={'大类'} name='thresholdBigKey' initialValue={props.values.thresholdBigKey} hidden={props.Data.type == 'big' ? false : true}>
                    <Select>
                        {
                            props.Data.Big.map((item, index) => {
                                return (
                                    <Select.Option typekey={item.typeKey} index={index} value={item.id} key={item.id}>
                                        {item.name}
                                    </Select.Option>
                                );
                            })
                        }
                    </Select>
                </Form.Item>
                <Form.Item label={'小类'} name='thresholdSmallKey' hidden={props.Data.type == 'small' ? false : true}>
                    <Select>
                        {
                            props.Data.Small.map((item, index) => {
                                return (
                                    <Select.Option typekey={item.typeKey} index={index} value={item.id} key={item.id}>
                                        {item.goodsType_Name}
                                    </Select.Option>
                                );
                            })
                        }
                    </Select>
                </Form.Item>
                <Form.Item label={'积分'} name='rulethresholdValue' >
                    <Input />
                </Form.Item>
                <Form.Item label={'生效门槛'} name='thresholds' >
                    <Input />
                </Form.Item>
                <Form.Item label={'规则描述'} name="ruleRemark" >
                    <TextArea />
                </Form.Item>
                
                <Form.Item>
                    <Button type="primary" htmlType="submit" >
                        保存
                    </Button>
                </Form.Item>
            </Form>
        </Modal>
    );
}
export default CommonRuleForm;
