import React, { useEffect, useState } from 'react';
import {
  ProForm,
  ProFormDigit,
  ProFormText,
  ProFormRadio,
  ProFormSelect,
  ProFormCascader,
  ProFormTextArea,
  EditableProTable
} from '@ant-design/pro-components';
import { Form, Modal, Input } from 'antd';
import { useIntl, FormattedMessage } from '@umijs/max';
import { getMerchantSelect, getSiteTypeSelect, getMerchantSelectDevice, getStationSelect } from '@/services/merchant/index'





const UserForm: React.FC = (props: any) => {

  const [form] = Form.useForm();

  const { values } = props;

  useEffect(() => {
    form.resetFields();
    form.setFieldsValue(values);
  }, [form, props]);

  const intl = useIntl();
  const handleOk = () => {
    form.submit();
  };
  const handleCancel = () => {
    props.onCancel();
  };
  const handleFinish = async (values: any) => {
    props.onSubmit(values);
  };

  return (
    <Modal
      width={800}
      title={'分类信息'}
      open={props.open}
      forceRender
      destroyOnClose
      onOk={handleOk}
      onCancel={handleCancel}
    >
      <ProForm
        form={form}
        grid={true}
        submitter={false}
        layout="horizontal"
        onFinish={handleFinish}>
        <ProFormDigit
          name="id"
          label={'ID'}
          disabled
          hidden={true}
        />

        <ProForm.Group>

          <ProFormText
            name="name"
            label={'分类名称'}
            colProps={{ md: 12, xl: 12 }}
            placeholder="请输入分类名称"
          />

        </ProForm.Group>

        <ProForm.Group>
          <ProFormText
            name="sort"
            label={'排序'}
            colProps={{ md: 8, xl: 8 }}
            placeholder="请输入排序"
          />
        </ProForm.Group>

      </ProForm>
    </Modal>
  );
};

export default UserForm;
