import React, { useState, useEffect } from 'react';
import { Modal, Form, Input, Button, Select, Switch, InputNumber } from 'antd';

const AddBomInfo = (props) => {
  const { Option, OptGroup } = Select;
  return (
    <Modal
      title={'添加配方原料'}
      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="BatchingId"
          label="原料名称"
          rules={[{ required: true, message: '请选择原料名称' }]}
        >
          <Select placeholder="请选择原料名称"
            showSearch
            optionFilterProp="children"
            filterOption={(input, option) =>
              option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
            }>
            {props.stockGoodsData.map((item, index) => {
              return (
                <Option index={index} value={item.id} key={item.id}>
                  {item.name}
                </Option>
              );
            })}
          </Select>
        </Form.Item>
        <Form.Item>
          <Button type="primary" htmlType="submit">
            保存
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default AddBomInfo;
