feat: 添加提交前验证

This commit is contained in:
xingyu
2022-10-17 11:24:22 +08:00
parent aa983a6fa9
commit 855d23aec3
26 changed files with 548 additions and 397 deletions

View File

@ -49,23 +49,29 @@ const handleUpdate = async (row: OAuth2ClientVo) => {
// 提交按钮
const submitForm = async () => {
actionLoading.value = true
// 提交请求
try {
const data = unref(formRef)?.formModel as OAuth2ClientVo
if (actionType.value === 'create') {
await ClientApi.createOAuth2ClientApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ClientApi.updateOAuth2ClientApi(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 OAuth2ClientVo
if (actionType.value === 'create') {
await ClientApi.createOAuth2ClientApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ClientApi.updateOAuth2ClientApi(data)
ElMessage.success(t('common.updateSuccess'))
}
// 操作成功,重新加载列表
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
// 操作成功,重新加载列表
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== 详情相关 ==========