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

import { ProFormCaptcha, ModalForm, ProFormTextArea, ProFormText, ProForm } from '@ant-design/pro-components';
import { useEffect, useRef } from 'react';


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

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

  return (
    <>
      <ModalForm
        title="订单-退单"
        formRef={restFormRef}
        submitter={{
          searchConfig: {
            resetText: '重置',
          },
          resetButtonProps: {
            onClick: () => {
              restFormRef.current?.resetFields();
            },
          },
        }}
        onFinish={onSubmit}
        open={modalOpenState}
        onOpenChange={onModalOpenState}
      >
        <div className='text-red-600	'>
          <div>1.退货：</div>
          <div>已安装设备不支持退货（如有需要请联系客服）</div>
          <div>2.退款：</div>
          <div>订单的支付方式为余额支付，则自动退回余额；如果为微信支付，由财务人工处理（原路返回、转账、增加余额）</div>
          <div>退单失败：</div>
          <div>如果团队有投资人余额不足、设备已安装等。会导致退单失败</div>
        </div>
        <ProForm.Group>
          <ProFormText
            rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="orderId"
            label="订单ID"
            placeholder="请输入"
            disabled
          />
          {/* <ProFormText
            rules={[{ required: true, message: '请输入' }]}
            width="md"
            name="username"
            label="用户名"
            placeholder="请输入"
          /> */}

        </ProForm.Group>
        {/* <ProForm.Group>
          <ProFormCaptcha
            placeholder={'请输入验证码'}
            captchaTextRender={(timing, count) => {
              if (timing) {
                return `${count} ${'获取验证码'}`;
              }
              return '获取验证码';
            }}
            label="验证码"
            name="code"
            rules={[
              {
                required: true,
                message: '请输入验证码！',
              },
            ]}
            onGetCaptcha={async () => {
              const { data } = await smsSendcode();
            }}
          />

        </ProForm.Group> */}
        <ProFormTextArea
          rules={[{ required: true, message: '请输入' }]}
          width="md"
          name="remarks"
          label="退单原因"
          placeholder="请输入"
        />
      </ModalForm>
    </>
  );
};

