From 3dfcc4a7690d80e56055bdfb37e76956c42d68eb Mon Sep 17 00:00:00 2001 From: lingting Date: Tue, 2 Aug 2022 18:22:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=9B=9E=E5=A1=AB=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/FullForm.tsx | 16 +++++++++------- src/components/Form/ModalForm.tsx | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) 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, () => ({