1- import { FormMeta } from "@/types" ;
1+ import { FormInstanceInterface , FormMeta , NamePath } from "@/types" ;
22import { FormRegistry } from "@/register" ;
33import { FormControl } from "./control" ;
44import { FormPresenter } from "@/presenters" ;
55
6- export class FormInstance {
6+ export class FormInstance implements FormInstanceInterface {
77
88 private readonly instanceList : FormControl [ ] ;
99
1010 private readonly meta : FormMeta ;
1111
12- private presenter : FormPresenter | undefined ;
12+ private presenter : FormPresenter | undefined ;
1313
1414 constructor ( meta : FormMeta ) {
1515 this . meta = meta ;
@@ -67,31 +67,31 @@ export class FormInstance {
6767 return this . getFormControl ( formCode ) ?. getProxyTarget ( ) ;
6868 }
6969
70- public getFieldValue ( name : string , formCode ?: string ) {
70+ public getFieldValue ( name : NamePath , formCode ?: string ) {
7171 this . getFormControl ( formCode ) ?. getFieldValue ( name ) ;
7272 }
7373
7474 public getFieldsValue ( formCode ?: string ) {
7575 return this . getFormControl ( formCode ) ?. getFieldsValue ( ) ;
7676 }
7777
78- public resetFields ( nameList ?: string [ ] , formCode ?: string ) {
78+ public resetFields ( nameList ?: NamePath [ ] | NamePath , formCode ?: string ) {
7979 this . getFormControl ( formCode ) ?. resetFields ( nameList ) ;
8080 }
8181
8282 public setFieldsValue ( values : any , formCode ?: string ) {
8383 this . getFormControl ( formCode ) ?. setFieldsValue ( values ) ;
8484 }
8585
86- public setFieldValue ( name : string , value : any , formCode ?: string ) {
86+ public setFieldValue ( name : NamePath , value : any , formCode ?: string ) {
8787 this . getFormControl ( formCode ) ?. setFieldValue ( name , value ) ;
8888 }
8989
9090 public submit ( formCode ?: string ) {
9191 this . getFormControl ( formCode ) ?. submit ( ) ;
9292 }
9393
94- public validateFields ( nameList ?: string [ ] , formCode ?: string ) {
94+ public validateFields ( nameList ?: NamePath [ ] | NamePath , formCode ?: string ) {
9595 const formControl = this . getFormControl ( formCode ) ;
9696 if ( formControl ) {
9797 return formControl . validateFields ( nameList ) ;
@@ -103,15 +103,15 @@ export class FormInstance {
103103 } ) ;
104104 }
105105
106- public hiddenFields ( hidden : boolean , nameList : string [ ] | string , formCode ?: string ) {
106+ public hiddenFields ( hidden : boolean , nameList : NamePath [ ] | NamePath , formCode ?: string ) {
107107 this . presenter ?. hiddenFields ( hidden , nameList , formCode ) ;
108108 }
109109
110- public requiredFields ( required : boolean , nameList : string [ ] | string , formCode ?: string ) {
110+ public requiredFields ( required : boolean , nameList : NamePath [ ] | NamePath , formCode ?: string ) {
111111 this . presenter ?. requiredFields ( required , nameList , formCode ) ;
112112 }
113113
114- public refreshFields ( nameList : string [ ] | string , formCode ?: string ) {
114+ public refreshFields ( nameList : NamePath [ ] | NamePath , formCode ?: string ) {
115115 this . presenter ?. refreshFields ( nameList , formCode ) ;
116116 }
117117
0 commit comments