import React, { useState } from 'react';
import { Modal, Form, Input, Button, Select } 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}
        initialValues={props?.values}
        onFinish={props?.onFinish}
      >
        <Form.Item name="id" hidden={true}>
          <Input />
        </Form.Item>
        <Form.Item name="name" label="配方类型名称" rules={[{ required: true, max: 64, whitespace: true }]}>
          <Input placeholder="请输入配方类型名称" />
        </Form.Item>
        <Form.Item
          name="pertain"
          label="归属"
          defaultValue={props?.values?.pertain}
          rules={[{ required: true, message: '请选择类型归属' }]}  >
          <Select placeholder="请选择类型归属">
            <Option value="1">无</Option>
            <Option value="2">TMC </Option>
          </Select>
        </Form.Item>
        <Form.Item
          name="status"
          label="状态"
          defaultValue={props?.values?.status}
          rules={[{ required: true, message: '请选择状态' }]}
        >
          <Select placeholder="请选择状态">
            <Option value="0">正常</Option>
            <Option value="1">停用</Option>
          </Select>
        </Form.Item>
        <Form.Item>
          <Button type="primary" htmlType="submit">
            保存
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default CreateForm;
