fix: menu drawer can not be closed after a successful submitting (#5770)
							parent
							
								
									66c1d390b9
								
							
						
					
					
						commit
						3f0d30897f
					
				|  | @ -32,7 +32,6 @@ const emit = defineEmits<{ | ||||||
|   success: []; |   success: []; | ||||||
| }>(); | }>(); | ||||||
| const formData = ref<SystemMenuApi.SystemMenu>(); | const formData = ref<SystemMenuApi.SystemMenu>(); | ||||||
| const loading = ref(false); |  | ||||||
| const titleSuffix = ref<string>(); | const titleSuffix = ref<string>(); | ||||||
| const schema: VbenFormSchema[] = [ | const schema: VbenFormSchema[] = [ | ||||||
|   { |   { | ||||||
|  | @ -445,9 +444,6 @@ const [Form, formApi] = useVbenForm({ | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| const [Drawer, drawerApi] = useVbenDrawer({ | const [Drawer, drawerApi] = useVbenDrawer({ | ||||||
|   onBeforeClose() { |  | ||||||
|     if (loading.value) return false; |  | ||||||
|   }, |  | ||||||
|   onConfirm: onSubmit, |   onConfirm: onSubmit, | ||||||
|   onOpenChange(isOpen) { |   onOpenChange(isOpen) { | ||||||
|     if (isOpen) { |     if (isOpen) { | ||||||
|  | @ -474,13 +470,7 @@ const [Drawer, drawerApi] = useVbenDrawer({ | ||||||
| async function onSubmit() { | async function onSubmit() { | ||||||
|   const { valid } = await formApi.validate(); |   const { valid } = await formApi.validate(); | ||||||
|   if (valid) { |   if (valid) { | ||||||
|     loading.value = true; |     drawerApi.lock(); | ||||||
|     drawerApi.setState({ |  | ||||||
|       closeOnClickModal: false, |  | ||||||
|       closeOnPressEscape: false, |  | ||||||
|       confirmLoading: true, |  | ||||||
|       loading: true, |  | ||||||
|     }); |  | ||||||
|     const data = |     const data = | ||||||
|       await formApi.getValues< |       await formApi.getValues< | ||||||
|         Omit<SystemMenuApi.SystemMenu, 'children' | 'id'> |         Omit<SystemMenuApi.SystemMenu, 'children' | 'id'> | ||||||
|  | @ -498,13 +488,7 @@ async function onSubmit() { | ||||||
|       drawerApi.close(); |       drawerApi.close(); | ||||||
|       emit('success'); |       emit('success'); | ||||||
|     } finally { |     } finally { | ||||||
|       loading.value = false; |       drawerApi.unlock(); | ||||||
|       drawerApi.setState({ |  | ||||||
|         closeOnClickModal: true, |  | ||||||
|         closeOnPressEscape: true, |  | ||||||
|         confirmLoading: false, |  | ||||||
|         loading: false, |  | ||||||
|       }); |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Netfan
						Netfan