From 855d23aec3c1e217a41c917ddd5d8b9175038ca8 Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 17 Oct 2022 11:24:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=89=8D=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/codegen/vue3/views/index.vue.vm | 38 +++++---- yudao-ui-admin-vue3/src/config/axios/index.ts | 15 ++-- .../src/views/Login/components/LoginForm.vue | 4 + .../src/views/bpm/form/index.vue | 38 +++++---- .../src/views/bpm/group/index.vue | 40 ++++++---- .../src/views/bpm/model/index.vue | 38 +++++---- .../src/views/infra/config/index.vue | 38 +++++---- .../views/infra/dataSourceConfig/index.vue | 38 +++++---- .../src/views/infra/fileConfig/index.vue | 38 +++++---- .../src/views/infra/job/index.vue | 40 ++++++---- .../src/views/pay/app/index.vue | 38 +++++---- .../src/views/pay/merchant/index.vue | 38 +++++---- .../src/views/pay/order/index.vue | 38 +++++---- .../src/views/system/dept/index.vue | 36 +++++---- .../src/views/system/dict/index.vue | 78 +++++++++++-------- .../src/views/system/errorCode/index.vue | 38 +++++---- .../src/views/system/menu/index.vue | 2 +- .../src/views/system/notice/index.vue | 38 +++++---- .../src/views/system/oauth2/client/index.vue | 38 +++++---- .../src/views/system/post/index.vue | 38 +++++---- .../src/views/system/role/index.vue | 38 +++++---- .../src/views/system/sensitiveWord/index.vue | 38 +++++---- .../src/views/system/sms/smsChannel/index.vue | 38 +++++---- .../views/system/sms/smsTemplate/index.vue | 38 +++++---- .../src/views/system/tenant/index.vue | 44 ++++++----- .../src/views/system/tenantPackage/index.vue | 40 ++++++---- 26 files changed, 548 insertions(+), 397 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm index c497a1801..ca4adc1a6 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -50,23 +50,29 @@ // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as ${simpleClassName}VO - if (actionType.value === 'create') { - await ${simpleClassName}Api.create${simpleClassName}Api(data) - ElMessage.success(t('common.createSuccess')) - } else { - await ${simpleClassName}Api.update${simpleClassName}Api(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 ${simpleClassName}VO + if (actionType.value === 'create') { + await ${simpleClassName}Api.create${simpleClassName}Api(data) + ElMessage.success(t('common.createSuccess')) + } else { + await ${simpleClassName}Api.update${simpleClassName}Api(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/config/axios/index.ts b/yudao-ui-admin-vue3/src/config/axios/index.ts index 1512be132..064cb2268 100644 --- a/yudao-ui-admin-vue3/src/config/axios/index.ts +++ b/yudao-ui-admin-vue3/src/config/axios/index.ts @@ -128,12 +128,18 @@ service.interceptors.response.use( const refreshTokenRes = await refreshToken() // 2.1 刷新成功,则回放队列的请求 + 当前请求 setToken(refreshTokenRes.data) - requestList.forEach((cb: any) => cb()) + ;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() + requestList.forEach((cb: any) => { + cb() + }) + requestList = [] return service(response.config) } catch (e) { // 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。 // 2.2 刷新失败,只回放队列的请求 - requestList.forEach((cb: any) => cb()) + requestList.forEach((cb: any) => { + cb() + }) // 提示是否要登出。即不回放当前请求!不然会形成递归 return handleAuthorized() } finally { @@ -194,10 +200,7 @@ service.interceptors.response.use( ) const refreshToken = async () => { - return await service({ - url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken(), - method: 'post' - }) + return await axios.post(base_url + '/system/auth/refresh-token?refreshToken=' + getRefreshToken()) } const handleAuthorized = () => { const { t } = useI18n() diff --git a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue index bb4e73cf5..a9e53a01a 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue +++ b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue @@ -111,6 +111,10 @@ const handleLogin = async (params) => { } loginData.loginForm.captchaVerification = params.captchaVerification const res = await LoginApi.loginApi(loginData.loginForm) + if (!res) { + loginLoading.value = false + return + } setToken(res) if (!redirect.value) { redirect.value = '/' diff --git a/yudao-ui-admin-vue3/src/views/bpm/form/index.vue b/yudao-ui-admin-vue3/src/views/bpm/form/index.vue index fc509207b..2fb70aabf 100644 --- a/yudao-ui-admin-vue3/src/views/bpm/form/index.vue +++ b/yudao-ui-admin-vue3/src/views/bpm/form/index.vue @@ -49,23 +49,29 @@ const handleUpdate = async (row: FormVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as FormVO - if (actionType.value === 'create') { - await FormApi.createFormApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await FormApi.updateFormApi(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 FormVO + if (actionType.value === 'create') { + await FormApi.createFormApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await FormApi.updateFormApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/bpm/group/index.vue b/yudao-ui-admin-vue3/src/views/bpm/group/index.vue index aa6af4cf2..fe327f9e4 100644 --- a/yudao-ui-admin-vue3/src/views/bpm/group/index.vue +++ b/yudao-ui-admin-vue3/src/views/bpm/group/index.vue @@ -62,24 +62,30 @@ const handleUpdate = async (row: UserGroupVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as UserGroupVO - data.memberUserIds = userIds.value - if (actionType.value === 'create') { - await UserGroupApi.createUserGroupApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await UserGroupApi.updateUserGroupApi(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 UserGroupVO + data.memberUserIds = userIds.value + if (actionType.value === 'create') { + await UserGroupApi.createUserGroupApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await UserGroupApi.updateUserGroupApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // 根据用户名获取用户真实名 diff --git a/yudao-ui-admin-vue3/src/views/bpm/model/index.vue b/yudao-ui-admin-vue3/src/views/bpm/model/index.vue index bbf0199e4..b85c50990 100644 --- a/yudao-ui-admin-vue3/src/views/bpm/model/index.vue +++ b/yudao-ui-admin-vue3/src/views/bpm/model/index.vue @@ -51,23 +51,29 @@ const handleUpdate = async (row: ModelVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as ModelVO - if (actionType.value === 'create') { - await ModelApi.createModelApi(data) - message.success(t('common.createSuccess')) - } else { - await ModelApi.updateModelApi(data) - message.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 ModelVO + if (actionType.value === 'create') { + await ModelApi.createModelApi(data) + message.success(t('common.createSuccess')) + } else { + await ModelApi.updateModelApi(data) + message.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } /** 流程表单的详情按钮操作 */ diff --git a/yudao-ui-admin-vue3/src/views/infra/config/index.vue b/yudao-ui-admin-vue3/src/views/infra/config/index.vue index 991c47a9b..b7a3c4b9d 100644 --- a/yudao-ui-admin-vue3/src/views/infra/config/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/config/index.vue @@ -50,23 +50,29 @@ const handleUpdate = async (row: ConfigVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as ConfigVO - if (actionType.value === 'create') { - await ConfigApi.createConfigApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await ConfigApi.updateConfigApi(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 ConfigVO + if (actionType.value === 'create') { + await ConfigApi.createConfigApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await ConfigApi.updateConfigApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/index.vue b/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/index.vue index 5a9f205ef..c8b363c1e 100644 --- a/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/dataSourceConfig/index.vue @@ -44,23 +44,29 @@ const handleUpdate = async (row: DataSourceConfigVO) => { // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as DataSourceConfigVO - if (actionType.value === 'create') { - await DataSourceConfiggApi.createDataSourceConfigApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await DataSourceConfiggApi.updateDataSourceConfigApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as DataSourceConfigVO + if (actionType.value === 'create') { + await DataSourceConfiggApi.createDataSourceConfigApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await DataSourceConfiggApi.updateDataSourceConfigApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - loading.value = false - } + }) } // 删除操作 diff --git a/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue b/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue index dd70921b9..b24bbb534 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/fileConfig/index.vue @@ -60,23 +60,29 @@ const handleMaster = (row: FileConfigVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as FileConfigVO - if (actionType.value === 'create') { - await FileConfigApi.createFileConfigApi(data) - message.success(t('common.createSuccess')) - } else { - await FileConfigApi.updateFileConfigApi(data) - message.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 FileConfigVO + if (actionType.value === 'create') { + await FileConfigApi.createFileConfigApi(data) + message.success(t('common.createSuccess')) + } else { + await FileConfigApi.updateFileConfigApi(data) + message.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/infra/job/index.vue b/yudao-ui-admin-vue3/src/views/infra/job/index.vue index b88dbf5cd..e5b9fff9e 100644 --- a/yudao-ui-admin-vue3/src/views/infra/job/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/job/index.vue @@ -98,24 +98,30 @@ const handleRun = (row: JobVO) => { } // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as JobVO - data.cronExpression = cronExpression.value - if (actionType.value === 'create') { - await JobApi.createJobApi(data) - message.success(t('common.createSuccess')) - } else { - await JobApi.updateJobApi(data) - message.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 JobVO + data.cronExpression = cronExpression.value + if (actionType.value === 'create') { + await JobApi.createJobApi(data) + message.success(t('common.createSuccess')) + } else { + await JobApi.updateJobApi(data) + message.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/pay/app/index.vue b/yudao-ui-admin-vue3/src/views/pay/app/index.vue index 36ded7be7..2968eb6ee 100644 --- a/yudao-ui-admin-vue3/src/views/pay/app/index.vue +++ b/yudao-ui-admin-vue3/src/views/pay/app/index.vue @@ -50,23 +50,29 @@ const handleUpdate = async (row: AppVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as AppVO - if (actionType.value === 'create') { - await AppApi.createAppApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await AppApi.updateAppApi(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 AppVO + if (actionType.value === 'create') { + await AppApi.createAppApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await AppApi.updateAppApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/pay/merchant/index.vue b/yudao-ui-admin-vue3/src/views/pay/merchant/index.vue index e30cad5ef..e5f3e7ea1 100644 --- a/yudao-ui-admin-vue3/src/views/pay/merchant/index.vue +++ b/yudao-ui-admin-vue3/src/views/pay/merchant/index.vue @@ -50,23 +50,29 @@ const handleUpdate = async (row: MerchantVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as MerchantVO - if (actionType.value === 'create') { - await MerchantApi.createMerchantApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await MerchantApi.updateMerchantApi(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 MerchantVO + if (actionType.value === 'create') { + await MerchantApi.createMerchantApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await MerchantApi.updateMerchantApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/pay/order/index.vue b/yudao-ui-admin-vue3/src/views/pay/order/index.vue index 63a8da7d2..25c482560 100644 --- a/yudao-ui-admin-vue3/src/views/pay/order/index.vue +++ b/yudao-ui-admin-vue3/src/views/pay/order/index.vue @@ -48,23 +48,29 @@ const handleUpdate = async (row: OrderVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as OrderVO - if (actionType.value === 'create') { - await OrderApi.createOrderApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await OrderApi.updateOrderApi(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 OrderVO + if (actionType.value === 'create') { + await OrderApi.createOrderApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await OrderApi.updateOrderApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/dept/index.vue b/yudao-ui-admin-vue3/src/views/system/dept/index.vue index 129510621..43c356bda 100644 --- a/yudao-ui-admin-vue3/src/views/system/dept/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/dept/index.vue @@ -82,22 +82,28 @@ const handleDelete = async (data: { id: number }) => { } // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as DeptVO - data.parentId = deptParentId.value - data.leaderUserId = leaderUserId.value - if (formTitle.value.startsWith('新增')) { - await DeptApi.createDeptApi(data) - } else if (formTitle.value.startsWith('修改')) { - await DeptApi.updateDeptApi(data) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as DeptVO + data.parentId = deptParentId.value + data.leaderUserId = leaderUserId.value + if (formTitle.value.startsWith('新增')) { + await DeptApi.createDeptApi(data) + } else if (formTitle.value.startsWith('修改')) { + await DeptApi.updateDeptApi(data) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - } finally { - loading.value = false - } + }) } onMounted(async () => { await getTree() diff --git a/yudao-ui-admin-vue3/src/views/system/dict/index.vue b/yudao-ui-admin-vue3/src/views/system/dict/index.vue index a49354591..26cc911a3 100644 --- a/yudao-ui-admin-vue3/src/views/system/dict/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/dict/index.vue @@ -92,43 +92,55 @@ const setDialogTile = (type: string) => { } // 提交按钮 const submitTypeForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(typeFormRef)?.formModel as DictTypeVO - if (actionType.value === 'typeCreate') { - await DictTypeApi.createDictTypeApi(data) - ElMessage.success(t('common.createSuccess')) - } else if (actionType.value === 'typeUpdate') { - await DictTypeApi.updateDictTypeApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(typeFormRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + actionLoading.value = true + // 提交请求 + try { + const data = unref(typeFormRef)?.formModel as DictTypeVO + if (actionType.value === 'typeCreate') { + await DictTypeApi.createDictTypeApi(data) + ElMessage.success(t('common.createSuccess')) + } else if (actionType.value === 'typeUpdate') { + await DictTypeApi.updateDictTypeApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + await getTypeList() + dialogVisible.value = false + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - await getTypeList() - dialogVisible.value = false - } finally { - actionLoading.value = false - } + }) } const submitDataForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(dataFormRef)?.formModel as DictDataVO - if (actionType.value === 'dataCreate') { - data.dictType = parentType.value - await DictDataApi.createDictDataApi(data) - ElMessage.success(t('common.createSuccess')) - } else if (actionType.value === 'dataUpdate') { - await DictDataApi.updateDictDataApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(dataFormRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + actionLoading.value = true + // 提交请求 + try { + const data = unref(dataFormRef)?.formModel as DictDataVO + if (actionType.value === 'dataCreate') { + data.dictType = parentType.value + await DictDataApi.createDictDataApi(data) + ElMessage.success(t('common.createSuccess')) + } else if (actionType.value === 'dataUpdate') { + await DictDataApi.updateDictDataApi(data) + ElMessage.success(t('common.updateSuccess')) + } + await getDataList() + // 操作成功,重新加载列表 + dialogVisible.value = false + } finally { + actionLoading.value = false + } } - await getDataList() - // 操作成功,重新加载列表 - dialogVisible.value = false - } finally { - actionLoading.value = false - } + }) } // 初始化查询 onMounted(async () => { diff --git a/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue b/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue index b35579fd1..a0fb96c32 100644 --- a/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/errorCode/index.vue @@ -49,23 +49,29 @@ const handleUpdate = async (row: ErrorCodeVO) => { // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as ErrorCodeVO - if (actionType.value === 'create') { - await ErrorCodeApi.createErrorCodeApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await ErrorCodeApi.updateErrorCodeApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as ErrorCodeVO + if (actionType.value === 'create') { + await ErrorCodeApi.createErrorCodeApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await ErrorCodeApi.updateErrorCodeApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - loading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/menu/index.vue b/yudao-ui-admin-vue3/src/views/system/menu/index.vue index 035b9d875..73cb78587 100644 --- a/yudao-ui-admin-vue3/src/views/system/menu/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/menu/index.vue @@ -127,7 +127,7 @@ const handleDelete = async (row: MenuVO) => { await getList() } // 保存操作 -function isExternal(path: string) { +const isExternal = (path: string) => { return /^(https?:|mailto:|tel:)/.test(path) } const submitForm = async () => { diff --git a/yudao-ui-admin-vue3/src/views/system/notice/index.vue b/yudao-ui-admin-vue3/src/views/system/notice/index.vue index 44fe19091..738a3f060 100644 --- a/yudao-ui-admin-vue3/src/views/system/notice/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/notice/index.vue @@ -48,23 +48,29 @@ const handleUpdate = async (row: NoticeVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as NoticeVO - if (actionType.value === 'create') { - await NoticeApi.createNoticeApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await NoticeApi.updateNoticeApi(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 NoticeVO + if (actionType.value === 'create') { + await NoticeApi.createNoticeApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await NoticeApi.updateNoticeApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue b/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue index e08f6d32a..bd1ba5a2c 100644 --- a/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue @@ -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 - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/post/index.vue b/yudao-ui-admin-vue3/src/views/system/post/index.vue index 3995b6759..4275ec15b 100644 --- a/yudao-ui-admin-vue3/src/views/system/post/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/post/index.vue @@ -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 - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/role/index.vue b/yudao-ui-admin-vue3/src/views/system/role/index.vue index c9bcca564..39273f4f0 100644 --- a/yudao-ui-admin-vue3/src/views/system/role/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/role/index.vue @@ -68,23 +68,29 @@ const handleUpdate = async (row: RoleVO) => { // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as RoleVO - if (actionType.value === 'create') { - await RoleApi.createRoleApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await RoleApi.updateRoleApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as RoleVO + if (actionType.value === 'create') { + await RoleApi.createRoleApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await RoleApi.updateRoleApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - loading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/sensitiveWord/index.vue b/yudao-ui-admin-vue3/src/views/system/sensitiveWord/index.vue index 69f9f97c5..5dbd6f5ea 100644 --- a/yudao-ui-admin-vue3/src/views/system/sensitiveWord/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/sensitiveWord/index.vue @@ -56,23 +56,29 @@ const handleUpdate = async (row: SensitiveWordVO) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as SensitiveWordVO - if (actionType.value === 'create') { - await SensitiveWordApi.createSensitiveWordApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await SensitiveWordApi.updateSensitiveWordApi(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 SensitiveWordVO + if (actionType.value === 'create') { + await SensitiveWordApi.createSensitiveWordApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await SensitiveWordApi.updateSensitiveWordApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/sms/smsChannel/index.vue b/yudao-ui-admin-vue3/src/views/system/sms/smsChannel/index.vue index 083e1cc3d..bb77f2e02 100644 --- a/yudao-ui-admin-vue3/src/views/system/sms/smsChannel/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/sms/smsChannel/index.vue @@ -49,23 +49,29 @@ const handleUpdate = async (row: SmsChannelVO) => { // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as SmsChannelVO - if (actionType.value === 'create') { - await SmsChannelApi.createSmsChannelApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await SmsChannelApi.updateSmsChannelApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as SmsChannelVO + if (actionType.value === 'create') { + await SmsChannelApi.createSmsChannelApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await SmsChannelApi.updateSmsChannelApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - loading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/sms/smsTemplate/index.vue b/yudao-ui-admin-vue3/src/views/system/sms/smsTemplate/index.vue index 71d455ec5..e1c192eee 100644 --- a/yudao-ui-admin-vue3/src/views/system/sms/smsTemplate/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/sms/smsTemplate/index.vue @@ -49,23 +49,29 @@ const handleUpdate = async (row: SmsTemplateVO) => { // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as SmsTemplateVO - if (actionType.value === 'create') { - await SmsTemplateApi.createSmsTemplateApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await SmsTemplateApi.updateSmsTemplateApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as SmsTemplateVO + if (actionType.value === 'create') { + await SmsTemplateApi.createSmsTemplateApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await SmsTemplateApi.updateSmsTemplateApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - loading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/tenant/index.vue b/yudao-ui-admin-vue3/src/views/system/tenant/index.vue index 204e0c7ef..696d15e96 100644 --- a/yudao-ui-admin-vue3/src/views/system/tenant/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/tenant/index.vue @@ -71,26 +71,32 @@ const handleUpdate = async (row: any) => { // 提交按钮 const submitForm = async () => { - actionLoading.value = true - // 提交请求 unix() - try { - const data = unref(formRef)?.formModel as TenantVO - data.packageId = tenantPackageId.value - if (actionType.value === 'create') { - data.expireTime = dayjs(data.expireTime).valueOf().toString() - await TenantApi.createTenantApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - data.expireTime = dayjs(data.expireTime).valueOf().toString() - await TenantApi.updateTenantApi(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 TenantVO + data.packageId = tenantPackageId.value + if (actionType.value === 'create') { + data.expireTime = dayjs(data.expireTime).valueOf().toString() + await TenantApi.createTenantApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + data.expireTime = dayjs(data.expireTime).valueOf().toString() + await TenantApi.updateTenantApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + actionLoading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - actionLoading.value = false - } + }) } // ========== 详情相关 ========== diff --git a/yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue b/yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue index 9bed7cef9..9d2cd4970 100644 --- a/yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue @@ -76,24 +76,30 @@ const handleUpdate = async (row: any) => { } // 提交按钮 const submitForm = async () => { - loading.value = true - // 提交请求 - try { - const data = unref(formRef)?.formModel as TenantPackageVO - data.menuIds = treeRef.value!.getCheckedKeys(false) as string[] - if (actionType.value === 'create') { - await TenantPackageApi.createTenantPackageTypeApi(data) - ElMessage.success(t('common.createSuccess')) - } else { - await TenantPackageApi.updateTenantPackageTypeApi(data) - ElMessage.success(t('common.updateSuccess')) + const elForm = unref(formRef)?.getElFormRef() + if (!elForm) return + elForm.validate(async (valid) => { + if (valid) { + loading.value = true + // 提交请求 + try { + const data = unref(formRef)?.formModel as TenantPackageVO + data.menuIds = treeRef.value!.getCheckedKeys(false) as string[] + if (actionType.value === 'create') { + await TenantPackageApi.createTenantPackageTypeApi(data) + ElMessage.success(t('common.createSuccess')) + } else { + await TenantPackageApi.updateTenantPackageTypeApi(data) + ElMessage.success(t('common.updateSuccess')) + } + // 操作成功,重新加载列表 + dialogVisible.value = false + await getList() + } finally { + loading.value = false + } } - // 操作成功,重新加载列表 - dialogVisible.value = false - await getList() - } finally { - loading.value = false - } + }) } // ========== 初始化 ==========