diff --git a/libs/cmdb-instances/src/model-attribute-form/ModelAttributeForm.tsx b/libs/cmdb-instances/src/model-attribute-form/ModelAttributeForm.tsx index 855f0a5fa..a2f9a5fc5 100644 --- a/libs/cmdb-instances/src/model-attribute-form/ModelAttributeForm.tsx +++ b/libs/cmdb-instances/src/model-attribute-form/ModelAttributeForm.tsx @@ -90,6 +90,8 @@ interface ModelAttributeFormProps extends FormComponentProps { }; isResetInstanceNameWhenSaveAndContinueToAddInstance?: boolean; uploadConfig?: UploadConfig; + useManualVerification?: boolean; + ref?: any; } export type attributesFieldsByTag = [string, ModifiedModelObjectField[]]; @@ -102,6 +104,7 @@ interface ModelAttributeFormState { showError?: Record; fixedStyle?: Record; defaultValueTemplateIndex?: number; + useManualVerification?: boolean; } export class ModelAttributeForm extends Component< @@ -399,8 +402,12 @@ export class ModelAttributeForm extends Component< } }; /* istanbul ignore next */ - handleSubmit = (e: FormEvent, type?: string) => { - e.preventDefault(); + public handleSubmit = (e?: FormEvent, type?: string) => { + // 允许不传入 event 参数 + if (e) { + e.preventDefault(); + } + this.props.scrollToFirstError ? this.props.form.validateFieldsAndScroll( { @@ -655,16 +662,17 @@ export class ModelAttributeForm extends Component< label={ {attribute.name} - {attribute.description && attribute.description !== "" && ( - - - - )} + {attribute.description && + attribute.description !== "" && ( + + + + )} } key={attribute.name} @@ -827,7 +835,7 @@ export class ModelAttributeForm extends Component< return (
{collapse} - {submitContainer} + {!this.props.useManualVerification && submitContainer}
); } @@ -835,3 +843,14 @@ export class ModelAttributeForm extends Component< export const InstanceModelAttributeForm = Form.create()(ModelAttributeForm); + +export const InstanceModelAttributeFormRef = React.forwardRef< + ModelAttributeForm, + ModelAttributeFormProps +>((props, ref) => { + const WrappedForm = Form.create()( + ModelAttributeForm + ) as any; + return ; +}); +InstanceModelAttributeFormRef.displayName = "InstanceModelAttributeFormRef";