From 1d11ebad3a79143c35273b5a609ef300281b1aff Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 6 Sep 2025 19:47:13 +0800 Subject: [PATCH] =?UTF-8?q?reactor=EF=BC=9A=E3=80=90system=20=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=AE=A1=E7=90=86=E3=80=91oauth2/token=20=E8=BF=9B?= =?UTF-8?q?=E4=B8=80=E6=AD=A5=E7=BB=9F=E4=B8=80=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/oauth2/token/data.ts | 10 ++ .../src/views/system/oauth2/token/index.vue | 68 ++++++++++--- .../src/views/system/oauth2/token/data.ts | 34 ++----- .../src/views/system/oauth2/token/index.vue | 97 ++++++++++++++----- 4 files changed, 148 insertions(+), 61 deletions(-) diff --git a/apps/web-antd/src/views/system/oauth2/token/data.ts b/apps/web-antd/src/views/system/oauth2/token/data.ts index 51390fb3f..ab5cf8a66 100644 --- a/apps/web-antd/src/views/system/oauth2/token/data.ts +++ b/apps/web-antd/src/views/system/oauth2/token/data.ts @@ -13,6 +13,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入用户编号', + allowClear: true, }, }, { @@ -22,6 +23,7 @@ export function useGridFormSchema(): VbenFormSchema[] { componentProps: { options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'), placeholder: '请选择用户类型', + allowClear: true, }, }, { @@ -30,6 +32,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入客户端编号', + allowClear: true, }, }, ]; @@ -42,18 +45,22 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'accessToken', title: '访问令牌', + minWidth: 300, }, { field: 'refreshToken', title: '刷新令牌', + minWidth: 300, }, { field: 'userId', title: '用户编号', + minWidth: 100, }, { field: 'userType', title: '用户类型', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.USER_TYPE }, @@ -62,15 +69,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'clientId', title: '客户端编号', + minWidth: 120, }, { field: 'expiresTime', title: '过期时间', + minWidth: 180, formatter: 'formatDateTime', }, { field: 'createTime', title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { diff --git a/apps/web-antd/src/views/system/oauth2/token/index.vue b/apps/web-antd/src/views/system/oauth2/token/index.vue index 8e0573b54..84a0886e8 100644 --- a/apps/web-antd/src/views/system/oauth2/token/index.vue +++ b/apps/web-antd/src/views/system/oauth2/token/index.vue @@ -2,7 +2,10 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { SystemOAuth2TokenApi } from '#/api/system/oauth2/token'; -import { DocAlert, Page } from '@vben/common-ui'; +import { ref } from 'vue'; + +import { confirm, DocAlert, Page } from '@vben/common-ui'; +import { isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -16,7 +19,7 @@ import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } @@ -24,20 +27,43 @@ function onRefresh() { async function handleDelete(row: SystemOAuth2TokenApi.OAuth2Token) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', ['令牌']), - key: 'action_key_msg', + duration: 0, }); try { await deleteOAuth2Token(row.accessToken); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', ['令牌']), - key: 'action_key_msg', - }); - onRefresh(); + message.success($t('ui.actionMessage.deleteSuccess', ['令牌'])); + handleRefresh(); } finally { hideLoading(); } } +/** 批量删除 OAuth2 令牌 */ +async function handleDeleteBatch() { + await confirm($t('ui.actionMessage.deleteBatchConfirm')); + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deletingBatch'), + duration: 0, + }); + try { + await deleteOAuth2Token(checkedIds.value.join(',')); + checkedIds.value = []; + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); + } finally { + hideLoading(); + } +} + +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemOAuth2TokenApi.OAuth2Token[]; +}) { + checkedIds.value = records.map((item) => item.accessToken); +} + const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -58,13 +84,18 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, }, rowConfig: { - keyField: 'id', + keyField: 'accessToken', + isHover: true, }, toolbarConfig: { refresh: true, search: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -78,17 +109,32 @@ const [Grid, gridApi] = useVbenVxeGrid({ + - + + + +