/*
 * @Note:
 * @Author: 2058827620@qq.com
 * @Date: 2022-04-03 17:02:15
 */

import { ProForm, ModalForm, ProFormSelect, ProFormText, ProFormTextArea, ProFormInstance } from '@ant-design/pro-components';
import { Tree } from 'antd';
import { useEffect, useRef } from 'react';
import FilesManager from '@/components/FilesManage/index';
import { userlevelPage } from '@/services/user/grade'


export default ({ modalOpenState, onModalOpenState, onSubmit }) => {
  const restFormRef = useRef<ProFormInstance>();


  return (
    <>
      <ModalForm
        title="投资人-等级"
        formRef={restFormRef}
        submitter={{
          searchConfig: {
            resetText: '重置',
          },
          resetButtonProps: {
            onClick: () => {
              restFormRef.current?.resetFields();
            },
          },
        }}
        onFinish={async (e) => {
          await onSubmit(e)
          restFormRef.current?.resetFields();
        }}
        open={modalOpenState}
        onOpenChange={onModalOpenState}
      >
        <ProFormText hidden={true} width="md" name="id" />
        <ProForm.Group>
          <ProFormSelect
            rules={[{ required: true, message: '请输入' }]}
            name="level"
            label="等级"
            fieldProps={{
              fieldNames: {
                label: "level",
                value: "level"
              },
            }}
            request={async (param) => {
              const { success, data } = await userlevelPage({});
              return data.records;
            }}
            placeholder="请选择"
          />
        </ProForm.Group>
        <ProForm.Group>
          <ProFormText
            rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="userName"
            label="用户名"
            placeholder="请输入"
          />
          <ProFormText
            rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="phone"
            label="手机号"
            placeholder="请输入"
          />
        </ProForm.Group>
        <ProFormTextArea
          rules={[{ required: true, message: '请输入' }]}
          width="md"
          name="remark"
          label="备注"
          placeholder="请输入"
        />
      </ModalForm>
    </>
  );
};

