import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, InputNumber } from 'antd';
const CreateForm = (props) => {
  const { Option, OptGroup } = Select;
  return (
    <Modal
      title={props.values.id ? '编辑' : '新建'}
      width={640}
      visible={props.createModalVisible}
      bodyStyle={{ padding: '32px 40px 48px' }}
      footer={null}
      onCancel={() => {
        props.onCancel();
      }}
      destroyOnClose
      maskClosable={false}
    >
      <Form
        layout="vertical"
        preserve={false}
        form={props.form}
        initialValues={props.values}
        onFinish={props.onFinish}
      >
        <Form.Item name="id" hidden={true}>
          <Input />
        </Form.Item>
        <Form.Item name="name" label="标签名称" rules={[{ required: true, max: 65,whitespace:true }]}>
          <Input placeholder="请输入标签名称" />
        </Form.Item>
        <Form.Item
          name="platformType"
          label="平台"
          defaultValue={props.values.status}
          rules={[{ required: true, message: '请选择平台' }]}
        >
          <Select placeholder="请选择平台">
            <OptGroup>
              <Select.Option value="0">默认</Select.Option>
              <Select.Option value="1">微信</Select.Option>
              <Select.Option value="2">支付宝</Select.Option>
              <Select.Option value="3">POS</Select.Option>
              <Select.Option value="4">储值卡</Select.Option>
            </OptGroup>
          </Select>
        </Form.Item>
        {/* <Form.Item name="sort" label="排序">
          <InputNumber min={1} placeholder="请选择排序" />
        </Form.Item> */}


        {/* <Form.Item
          noStyle
          shouldUpdate={(prevValues, currentValues) =>
            prevValues.mode !== currentValues.mode
          }  >
          {({ getFieldValue }) =>
            (props.values.id) ? (
              <Form.Item
                name="status"
                label="状态"
                defaultValue={props.values.status}
                rules={[{ required: true, message: '请选择状态' }]}
              >
                <Select placeholder="请选择状态">
                  <OptGroup>
                    <Select.Option value="0">正常</Select.Option>
                    <Select.Option value="1">停用</Select.Option>
                  </OptGroup>
                </Select>
              </Form.Item>
            ) : null
          }
        </Form.Item> */}


        <Form.Item>
          {/* <Button type="primary" htmlType="submit">
            保存
          </Button> */}
           <Button type="primary" htmlType="submit" style={{ float: 'right', left: 10 }}  >
            确认
          </Button>
          <Button htmlType="button" style={{ float: 'right' }} onClick={props.onCancel} >
            取消
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default CreateForm;
