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

import { ProForm, ModalForm, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { Divider } from 'antd';
import { useEffect, useRef } from 'react';
import FilesManager from '@/components/FilesManage/index';
// import services from '@/services/admin';

// const { shopLevelItems } = services.ShopLevelController;

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

  useEffect(() => {
    restFormRef.current?.setFieldsValue(values);
  }, [values]);

  const handleFinish = async (formValues) => {
    await onSubmit(formValues); 
    restFormRef.current?.resetFields(); 
  };

  return (
    <>
      <ModalForm
        title="投资人-转挂"
        formRef={restFormRef}
        submitter={{
          searchConfig: {
            resetText: '重置',
          },
          resetButtonProps: {
            onClick: () => {
              restFormRef.current?.resetFields();
            },
          },
        }}
        initialValues={values}
        onFinish={handleFinish}
        open={modalOpenState}
        onOpenChange={onModalOpenState}
      >
        <div className='text-red-600	'>
          <div>A：需要转挂的投资人</div>
          <div>B：转挂该投资人名下</div>
          <div>该操作把A转挂到B名下</div>
        </div>
        <Divider>A：需要转挂的投资人</Divider>
        <ProForm.Group>
          <ProFormText
            rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="username"
            label="用户名(A)"
            placeholder="请输入"
          />
          <ProFormText
            rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="mobile"
            label="手机号(A)"
            placeholder="请输入"
          />
        </ProForm.Group>
        <Divider>B：把A转挂该投资人名下</Divider>
        <ProForm.Group>
          <ProFormText
            // rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="usernameToChange"
            label="用户名(B)"
            placeholder="请输入"
          />
          <ProFormText
            // rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="mobileToChange"
            label="手机号(B)"
            placeholder="请输入"
          />
        </ProForm.Group>
        <ProFormTextArea
          // rules={[{ required: true, message: '请输入' }]}
          width="md"
          name="adminNote"
          label="备注"
          placeholder="请输入"
        />
      </ModalForm>
    </>
  );
};

