diff --git a/src/components/Form/FullForm.tsx b/src/components/Form/FullForm.tsx index eab1cce..7d34497 100644 --- a/src/components/Form/FullForm.tsx +++ b/src/components/Form/FullForm.tsx @@ -1,4 +1,4 @@ -import { useState, useRef, useImperativeHandle } from 'react'; +import { useImperativeHandle, useRef, useState } from 'react'; import type { FormStatus } from './typings'; import type { ProFormInstance } from '@ant-design/pro-form'; import ProForm from '@ant-design/pro-form'; @@ -43,14 +43,16 @@ const FullForm = (props: FullFormProps) => { setTitle(undefined); return; } - // 清空数据 - formRef.current?.resetFields(); - // 如果需要回填数据 - if (data !== undefined && data !== null) { - formRef.current?.setFieldsValue(data); - } setTitle(`${defautlTitle[st]}${titleSuffix}`); setHidden(false); + setTimeout(() => { + // 清空数据 + formRef.current?.resetFields(); + // 如果需要回填数据 + if (data !== undefined && data !== null) { + formRef.current?.setFieldsValue(data); + } + }); }; const submit = async ( diff --git a/src/components/Form/ModalForm.tsx b/src/components/Form/ModalForm.tsx index d595d2f..2900201 100644 --- a/src/components/Form/ModalForm.tsx +++ b/src/components/Form/ModalForm.tsx @@ -1,5 +1,5 @@ -import { useState, useRef, useImperativeHandle } from 'react'; -import type { ModalFormProps, FormStatus } from './typings'; +import { useImperativeHandle, useRef, useState } from 'react'; +import type { FormStatus, ModalFormProps } from './typings'; import type { ProFormInstance } from '@ant-design/pro-form'; import { ModalForm as AntdModalForm } from '@ant-design/pro-form'; import type { R } from '@/typings'; @@ -58,14 +58,16 @@ const ModalForm = (props: ModalFormProps) => { setModalTitle(undefined); return; } - // 清空数据 - formRef.current?.resetFields(); - // 如果需要回填数据 - if (data !== undefined && data !== null) { - formRef.current?.setFieldsValue(data); - } setModalTitle(`${defautlTitle[st]}${titleSuffix}`); setVisible(true); + setTimeout(() => { + // 清空数据 + formRef.current?.resetFields(); + // 如果需要回填数据 + if (data !== undefined && data !== null) { + formRef.current?.setFieldsValue(data); + } + }); }; useImperativeHandle(currencyRef, () => ({