import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, InputNumber, message } from 'antd';
import { getGoods } from '../services';

const CreateForm = (props) => {
  const { Option, OptGroup } = Select;
  const [CokingWorks, setCokingWorks] = useState([]);

  const [goods, setGoods] = useState([]);

  return (
    <Modal
      title={props.values.id ? '编辑' : '新建'}
      width={640}
      visible={props.createModalVisible}
      bodyStyle={{ padding: '32px 40px 48px' }}
      footer={null}
      onCancel={() => {
        props.onCancel();
      }}
      destroyOnClose
    >
      <Form
        layout="vertical"
        preserve={false}
        initialValues={props.values}
        onFinish={props.onFinish}
      >
        <Form.Item name="id" hidden={true}>
          <Input />
        </Form.Item>
        <Form.Item label={'价格'} name="price" rules={[{ required: true }]}>
          <InputNumber placeholder="价格" min={0} />
        </Form.Item>
        <Form.Item label={'会员价格'} name="vipPrice" rules={[{ required: true }]}>
          <InputNumber placeholder="价格" min={0} />
        </Form.Item>

        <Form.Item label={'状态'} name="status" rules={[{ required: true }]}>
          <Select placeholder="状态">
            <Option value={1}>下架</Option>
            <Option value={0}>上架</Option>
          </Select>
        </Form.Item>
        <Form.Item>
          <Button type="primary" htmlType="submit">
            保存
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default CreateForm;
