From c874f754b8ec74b9f965b9327c6b3074d195153a Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 16 Jun 2025 21:31:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90ele=E3=80=91OAuth=202.0=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/system/oauth2/client/index.ts | 7 ++ .../src/views/system/oauth2/client/data.ts | 4 ++ .../src/views/system/oauth2/client/index.vue | 66 +++++++++++++++---- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/apps/web-ele/src/api/system/oauth2/client/index.ts b/apps/web-ele/src/api/system/oauth2/client/index.ts index 7c1db7747..5817b858b 100644 --- a/apps/web-ele/src/api/system/oauth2/client/index.ts +++ b/apps/web-ele/src/api/system/oauth2/client/index.ts @@ -55,3 +55,10 @@ export function updateOAuth2Client(data: SystemOAuth2ClientApi.OAuth2Client) { export function deleteOAuth2Client(id: number) { return requestClient.delete(`/system/oauth2-client/delete?id=${id}`); } + +/** 批量删除 OAuth2.0 客户端 */ +export function deleteOAuth2ClientList(ids: number[]) { + return requestClient.delete( + `/system/oauth2-client/delete-list?ids=${ids.join(',')}`, + ); +} diff --git a/apps/web-ele/src/views/system/oauth2/client/data.ts b/apps/web-ele/src/views/system/oauth2/client/data.ts index 14e1208fe..38877d5eb 100644 --- a/apps/web-ele/src/views/system/oauth2/client/data.ts +++ b/apps/web-ele/src/views/system/oauth2/client/data.ts @@ -195,6 +195,10 @@ export function useGridColumns( onActionClick: OnActionClickFn, ): VxeTableGridOptions['columns'] { return [ + { + type: 'checkbox', + width: 40, + }, { field: 'clientId', title: '客户端编号', diff --git a/apps/web-ele/src/views/system/oauth2/client/index.vue b/apps/web-ele/src/views/system/oauth2/client/index.vue index 48bb2223d..895c4c7a2 100644 --- a/apps/web-ele/src/views/system/oauth2/client/index.vue +++ b/apps/web-ele/src/views/system/oauth2/client/index.vue @@ -5,14 +5,17 @@ import type { } from '#/adapter/vxe-table'; import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client'; +import { ref } from 'vue'; + import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { Plus } from '@vben/icons'; +import { isEmpty } from '@vben/utils'; -import { ElButton, ElLoading, ElMessage } from 'element-plus'; +import { ElLoading, ElMessage } from 'element-plus'; -import { useVbenVxeGrid } from '#/adapter/vxe-table'; +import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteOAuth2Client, + deleteOAuth2ClientList, getOAuth2ClientPage, } from '#/api/system/oauth2/client'; import { $t } from '#/locales'; @@ -50,13 +53,35 @@ async function onDelete(row: SystemOAuth2ClientApi.OAuth2Client) { await deleteOAuth2Client(row.id as number); ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name])); onRefresh(); - } catch { - // 异常处理 } finally { loadingInstance.close(); } } +/** 批量删除 OAuth2 客户端 */ +async function onDeleteBatch() { + const loadingInstance = ElLoading.service({ + text: $t('ui.actionMessage.deleting'), + fullscreen: true, + }); + try { + await deleteOAuth2ClientList(checkedIds.value); + ElMessage.success($t('ui.actionMessage.deleteSuccess')); + onRefresh(); + } finally { + loadingInstance.close(); + } +} + +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemOAuth2ClientApi.OAuth2Client[]; +}) { + checkedIds.value = records.map((item) => item.id as number); +} + /** 表格操作按钮的回调函数 */ function onActionClick({ code, @@ -101,6 +126,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ search: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -116,14 +145,25 @@ const [Grid, gridApi] = useVbenVxeGrid({