import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, InputNumber } from 'antd';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';

const CreateForm = (props) => {

  console.log(props.values);
  console.log(props.orgArray);

  return (
    <Modal
      title={'修改库存'}
      width={600}
      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 name="orgId" label={'选择机构'} rules={[{ required: true }]}>
          <Select disabled={props.values.id ? true : false}>
            {props.orgArray.map((item, index) => {
              return (
                <Select.Option index={index} value={item.id} key={item.id}>
                  {item.text}
                </Select.Option>
              );
            })}
          </Select>
        </Form.Item>

        <Form.Item name="productId" label={'选择物料'} rules={[{ required: true }]}>
          <Select disabled={props.values.id ? true : false}>
            {props.productArray.map((item, index) => {
              return (
                <Select.Option index={index} value={item.stockUint} key={item.id}>
                  {item.text}
                </Select.Option>
              );
            })}
          </Select>
        </Form.Item>

        <Form.Item name="stockQty" label="库存数量" rules={[{ required: true }]}>
          <InputNumber step={1} min={0} max={1000} style={{ width: 150 }} />
        </Form.Item>

        <Form.Item name="code" label="物料编码" rules={[{ required: true, max: 64 }]}>
          <Input placeholder="物料条码" />
        </Form.Item>

        <Form.Item>
          <Button type="primary" htmlType="submit">
            保存
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default CreateForm;
