fix: anti double submit in form

This commit is contained in:
jialin
2026-06-11 20:02:27 +08:00
committed by jialin
parent 1218c6d096
commit a7b33a928b
23 changed files with 246 additions and 93 deletions
+16 -3
View File
@@ -65,6 +65,7 @@ interface ProviderFormProps {
routeTargets?: RouteTargetFormItem[];
}; // Used when action is EDIT
onFinish: (values: FormData) => Promise<void>;
onFinishFailed?: (errorInfo: any) => void;
onFallbackChange?: (changed: boolean) => void;
}
@@ -86,8 +87,15 @@ const requiredFields = {
const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
const intl = useIntl();
const { action, realAction, currentData, open, onFinish, onFallbackChange } =
props;
const {
action,
realAction,
currentData,
open,
onFinish,
onFinishFailed,
onFallbackChange
} = props;
const { getScrollElementScrollableHeight } = useWrapperContext();
const [form] = Form.useForm();
const scrollTabsRef = useRef<any>(null);
@@ -238,6 +246,11 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
updateActiveKey
});
const handleFinishFailed = (errorInfo: any) => {
handleOnFinishFailed(errorInfo);
onFinishFailed?.(errorInfo);
};
useImperativeHandle(ref, () => ({
submit: () => {
form.submit();
@@ -266,7 +279,7 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
<Form
form={form}
onFinish={handleOnFinish}
onFinishFailed={handleOnFinishFailed}
onFinishFailed={handleFinishFailed}
initialValues={{
categories: [modelCategoriesMap.llm],
meta: {}