@@ -39,6 +39,7 @@ const DrawerForm: React.FC<any> = (props:any) => {
3939 } ) ;
4040
4141 const [ visible , setVisible ] = useState ( false ) ;
42+ const [ loading , setLoading ] = useState ( false ) ;
4243
4344 const getComponent = async ( ) => {
4445 const result = await get ( {
@@ -55,7 +56,7 @@ const DrawerForm: React.FC<any> = (props:any) => {
5556 }
5657 }
5758 } ) ;
58-
59+
5960 form . setFieldsValue ( initialValues ) ;
6061 setVisible ( true ) ;
6162 }
@@ -68,7 +69,7 @@ const DrawerForm: React.FC<any> = (props:any) => {
6869 if ( data . hasOwnProperty ( 'content' ) ) {
6970 return findFormComponent ( data . content ) ;
7071 }
71-
72+
7273 let conmpontent = [ ] ;
7374
7475 if ( data . hasOwnProperty ( 0 ) ) {
@@ -120,16 +121,20 @@ const DrawerForm: React.FC<any> = (props:any) => {
120121 if ( formComponent . disabledSubmitButton === true ) {
121122 return null ;
122123 }
123-
124+
124125 return (
125126 < Space >
126127 < Button onClick = { ( ) => setVisible ( false ) } >
127128 取消
128129 </ Button >
129130 < Button
131+ loading = { loading }
130132 onClick = { ( ) => {
131133 form . validateFields ( ) . then ( ( values :any ) => {
132- onFinish ( values ) ;
134+ setLoading ( true ) ;
135+ onFinish ( values ) . finally ( ( ) => {
136+ setLoading ( false ) ;
137+ } ) ;
133138 } ) . catch ( ( info :any ) => {
134139 console . log ( 'Validate Failed:' , info ) ;
135140 } ) ;
@@ -204,4 +209,4 @@ const DrawerForm: React.FC<any> = (props:any) => {
204209 ) ;
205210}
206211
207- export default DrawerForm ;
212+ export default DrawerForm ;
0 commit comments