mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	feat: 添加提交前验证
This commit is contained in:
		| @@ -50,23 +50,29 @@ const handleUpdate = async (row: PostVO) => { | ||||
|  | ||||
| // 提交按钮 | ||||
| const submitForm = async () => { | ||||
|   actionLoading.value = true | ||||
|   // 提交请求 | ||||
|   try { | ||||
|     const data = unref(formRef)?.formModel as PostVO | ||||
|     if (actionType.value === 'create') { | ||||
|       await PostApi.createPostApi(data) | ||||
|       ElMessage.success(t('common.createSuccess')) | ||||
|     } else { | ||||
|       await PostApi.updatePostApi(data) | ||||
|       ElMessage.success(t('common.updateSuccess')) | ||||
|   const elForm = unref(formRef)?.getElFormRef() | ||||
|   if (!elForm) return | ||||
|   elForm.validate(async (valid) => { | ||||
|     if (valid) { | ||||
|       actionLoading.value = true | ||||
|       // 提交请求 | ||||
|       try { | ||||
|         const data = unref(formRef)?.formModel as PostVO | ||||
|         if (actionType.value === 'create') { | ||||
|           await PostApi.createPostApi(data) | ||||
|           ElMessage.success(t('common.createSuccess')) | ||||
|         } else { | ||||
|           await PostApi.updatePostApi(data) | ||||
|           ElMessage.success(t('common.updateSuccess')) | ||||
|         } | ||||
|         // 操作成功,重新加载列表 | ||||
|         dialogVisible.value = false | ||||
|         await getList() | ||||
|       } finally { | ||||
|         actionLoading.value = false | ||||
|       } | ||||
|     } | ||||
|     // 操作成功,重新加载列表 | ||||
|     dialogVisible.value = false | ||||
|     await getList() | ||||
|   } finally { | ||||
|     actionLoading.value = false | ||||
|   } | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // ========== 详情相关 ========== | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 xingyu
					xingyu