reactor:【system 系统管理】oauth2/client 进一步统一代码风格
This commit is contained in:
@@ -55,3 +55,10 @@ export function updateOAuth2Client(data: SystemOAuth2ClientApi.OAuth2Client) {
|
|||||||
export function deleteOAuth2Client(id: number) {
|
export function deleteOAuth2Client(id: number) {
|
||||||
return requestClient.delete(`/system/oauth2-client/delete?id=${id}`);
|
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(',')}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入授权范围',
|
placeholder: '请输入授权范围',
|
||||||
mode: 'tags',
|
mode: 'tags',
|
||||||
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -179,6 +180,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
component: 'Input',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入应用名',
|
placeholder: '请输入应用名',
|
||||||
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -197,21 +199,26 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
|
{ type: 'checkbox', width: 40 },
|
||||||
{
|
{
|
||||||
field: 'clientId',
|
field: 'clientId',
|
||||||
title: '客户端编号',
|
title: '客户端编号',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'secret',
|
field: 'secret',
|
||||||
title: '客户端密钥',
|
title: '客户端密钥',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: '应用名',
|
title: '应用名',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'logo',
|
field: 'logo',
|
||||||
title: '应用图标',
|
title: '应用图标',
|
||||||
|
minWidth: 100,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellImage',
|
name: 'CellImage',
|
||||||
},
|
},
|
||||||
@@ -219,6 +226,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
{
|
{
|
||||||
field: 'status',
|
field: 'status',
|
||||||
title: '状态',
|
title: '状态',
|
||||||
|
minWidth: 80,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
@@ -227,20 +235,24 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
{
|
{
|
||||||
field: 'accessTokenValiditySeconds',
|
field: 'accessTokenValiditySeconds',
|
||||||
title: '访问令牌的有效期',
|
title: '访问令牌的有效期',
|
||||||
|
minWidth: 150,
|
||||||
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'refreshTokenValiditySeconds',
|
field: 'refreshTokenValiditySeconds',
|
||||||
title: '刷新令牌的有效期',
|
title: '刷新令牌的有效期',
|
||||||
|
minWidth: 150,
|
||||||
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'authorizedGrantTypes',
|
field: 'authorizedGrantTypes',
|
||||||
title: '授权类型',
|
title: '授权类型',
|
||||||
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
deleteOAuth2Client,
|
deleteOAuth2Client,
|
||||||
|
deleteOAuth2ClientList,
|
||||||
getOAuth2ClientPage,
|
getOAuth2ClientPage,
|
||||||
} from '#/api/system/oauth2/client';
|
} from '#/api/system/oauth2/client';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@@ -22,7 +26,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,20 +44,43 @@ function handleEdit(row: SystemOAuth2ClientApi.OAuth2Client) {
|
|||||||
async function handleDelete(row: SystemOAuth2ClientApi.OAuth2Client) {
|
async function handleDelete(row: SystemOAuth2ClientApi.OAuth2Client) {
|
||||||
const hideLoading = message.loading({
|
const hideLoading = message.loading({
|
||||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
key: 'action_key_msg',
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteOAuth2Client(row.id as number);
|
await deleteOAuth2Client(row.id as number);
|
||||||
message.success({
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
handleRefresh();
|
||||||
key: 'action_key_msg',
|
|
||||||
});
|
|
||||||
onRefresh();
|
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 批量删除 OAuth2 客户端 */
|
||||||
|
async function handleDeleteBatch() {
|
||||||
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deletingBatch'),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteOAuth2ClientList(checkedIds.value);
|
||||||
|
checkedIds.value = [];
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: SystemOAuth2ClientApi.OAuth2Client[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
|
}
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
@@ -75,12 +102,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<SystemOAuth2ClientApi.OAuth2Client>,
|
} as VxeTableGridOptions<SystemOAuth2ClientApi.OAuth2Client>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -93,7 +125,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="OAuth2 客户端列表">
|
<Grid table-title="OAuth2 客户端列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
@@ -105,6 +137,15 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
auth: ['system:oauth2-client:create'],
|
auth: ['system:oauth2-client:create'],
|
||||||
onClick: handleCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
|
type: 'primary',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['system:oauth2-client:delete'],
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
|
onClick: handleDeleteBatch,
|
||||||
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
@@ -52,9 +48,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
fieldName: 'logo',
|
fieldName: 'logo',
|
||||||
label: '应用图标',
|
label: '应用图标',
|
||||||
component: 'ImageUpload',
|
component: 'ImageUpload',
|
||||||
componentProps: {
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -104,7 +97,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: getDictOptions(DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE),
|
options: getDictOptions(DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE),
|
||||||
mode: 'multiple',
|
multiple: true,
|
||||||
placeholder: '请输入授权类型',
|
placeholder: '请输入授权类型',
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
@@ -112,10 +105,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
{
|
{
|
||||||
fieldName: 'scopes',
|
fieldName: 'scopes',
|
||||||
label: '授权范围',
|
label: '授权范围',
|
||||||
component: 'Select',
|
component: 'InputTag',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入授权范围',
|
placeholder: '请输入授权范围',
|
||||||
mode: 'tags',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -124,37 +116,47 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入自动授权范围',
|
placeholder: '请输入自动授权范围',
|
||||||
mode: 'multiple',
|
multiple: true,
|
||||||
// TODO @芋艿:根据权限,自动授权范围
|
options: [],
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['scopes'],
|
||||||
|
componentProps: (values) => ({
|
||||||
|
options: values.scopes
|
||||||
|
? values.scopes.map((scope: string) => ({
|
||||||
|
label: scope,
|
||||||
|
value: scope,
|
||||||
|
}))
|
||||||
|
: [],
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'redirectUris',
|
fieldName: 'redirectUris',
|
||||||
label: '可重定向的 URI 地址',
|
label: '可重定向的 URI 地址',
|
||||||
component: 'Select',
|
component: 'InputTag',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入可重定向的 URI 地址',
|
placeholder: '请输入可重定向的 URI 地址',
|
||||||
mode: 'tags',
|
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'authorities',
|
fieldName: 'authorities',
|
||||||
label: '权限',
|
label: '权限',
|
||||||
component: 'Select',
|
component: 'InputTag',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入权限',
|
placeholder: '请输入权限',
|
||||||
mode: 'tags',
|
|
||||||
},
|
},
|
||||||
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'resourceIds',
|
fieldName: 'resourceIds',
|
||||||
label: '资源',
|
label: '资源',
|
||||||
component: 'Select',
|
component: 'InputTag',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
mode: 'tags',
|
|
||||||
placeholder: '请输入资源',
|
placeholder: '请输入资源',
|
||||||
},
|
},
|
||||||
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'additionalInformation',
|
fieldName: 'additionalInformation',
|
||||||
@@ -176,6 +178,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
component: 'Input',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入应用名',
|
placeholder: '请输入应用名',
|
||||||
|
clearable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -192,18 +195,13 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
onActionClick: OnActionClickFn<T>,
|
|
||||||
): VxeTableGridOptions['columns'] {
|
|
||||||
return [
|
return [
|
||||||
{
|
{ type: 'checkbox', width: 40 },
|
||||||
type: 'checkbox',
|
|
||||||
width: 40,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'clientId',
|
field: 'clientId',
|
||||||
title: '客户端编号',
|
title: '客户端编号',
|
||||||
minWidth: 200,
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'secret',
|
field: 'secret',
|
||||||
@@ -213,12 +211,12 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
|||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: '应用名',
|
title: '应用名',
|
||||||
minWidth: 300,
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'logo',
|
field: 'logo',
|
||||||
title: '应用图标',
|
title: '应用图标',
|
||||||
minWidth: 80,
|
minWidth: 100,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellImage',
|
name: 'CellImage',
|
||||||
},
|
},
|
||||||
@@ -235,19 +233,19 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
|||||||
{
|
{
|
||||||
field: 'accessTokenValiditySeconds',
|
field: 'accessTokenValiditySeconds',
|
||||||
title: '访问令牌的有效期',
|
title: '访问令牌的有效期',
|
||||||
minWidth: 130,
|
minWidth: 150,
|
||||||
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'refreshTokenValiditySeconds',
|
field: 'refreshTokenValiditySeconds',
|
||||||
title: '刷新令牌的有效期',
|
title: '刷新令牌的有效期',
|
||||||
minWidth: 130,
|
minWidth: 150,
|
||||||
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'authorizedGrantTypes',
|
field: 'authorizedGrantTypes',
|
||||||
title: '授权类型',
|
title: '授权类型',
|
||||||
minWidth: 180,
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
@@ -256,29 +254,10 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
|||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 130,
|
width: 130,
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
cellRender: {
|
slots: { default: 'actions' },
|
||||||
attrs: {
|
|
||||||
nameField: 'name',
|
|
||||||
nameTitle: 'OAuth2 客户端',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'edit',
|
|
||||||
show: hasAccessByCodes(['system:oauth2-client:update']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'delete',
|
|
||||||
show: hasAccessByCodes(['system:oauth2-client:delete']),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
OnActionClickParams,
|
|
||||||
VxeTableGridOptions,
|
|
||||||
} from '#/adapter/vxe-table';
|
|
||||||
import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
@@ -29,41 +26,48 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建 OAuth2 客户端 */
|
/** 创建 OAuth2 客户端 */
|
||||||
function onCreate() {
|
function handleCreate() {
|
||||||
formModalApi.setData(null).open();
|
formModalApi.setData(null).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑 OAuth2 客户端 */
|
/** 编辑 OAuth2 客户端 */
|
||||||
function onEdit(row: SystemOAuth2ClientApi.OAuth2Client) {
|
function handleEdit(row: SystemOAuth2ClientApi.OAuth2Client) {
|
||||||
formModalApi.setData(row).open();
|
formModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除 OAuth2 客户端 */
|
/** 删除 OAuth2 客户端 */
|
||||||
async function onDelete(row: SystemOAuth2ClientApi.OAuth2Client) {
|
async function handleDelete(row: SystemOAuth2ClientApi.OAuth2Client) {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteOAuth2Client(row.id as number);
|
await deleteOAuth2Client(row.id as number);
|
||||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 批量删除 OAuth2 客户端 */
|
/** 批量删除 OAuth2 客户端 */
|
||||||
async function onDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
await confirm('确定要批量删除该 OAuth2 客户端吗?');
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
await deleteOAuth2ClientList(checkedIds.value);
|
const loadingInstance = ElLoading.service({
|
||||||
checkedIds.value = [];
|
text: $t('ui.actionMessage.deletingBatch'),
|
||||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
});
|
||||||
onRefresh();
|
try {
|
||||||
|
await deleteOAuth2ClientList(checkedIds.value);
|
||||||
|
checkedIds.value = [];
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkedIds = ref<number[]>([]);
|
const checkedIds = ref<number[]>([]);
|
||||||
@@ -75,29 +79,12 @@ function handleRowCheckboxChange({
|
|||||||
checkedIds.value = records.map((item) => item.id!);
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
|
||||||
function onActionClick({
|
|
||||||
code,
|
|
||||||
row,
|
|
||||||
}: OnActionClickParams<SystemOAuth2ClientApi.OAuth2Client>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
|
||||||
onEdit(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick),
|
columns: useGridColumns(),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
@@ -113,6 +100,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
@@ -135,7 +123,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<Grid table-title="OAuth2 客户端列表">
|
<Grid table-title="OAuth2 客户端列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
@@ -145,15 +133,40 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: ACTION_ICON.ADD,
|
icon: ACTION_ICON.ADD,
|
||||||
auth: ['system:oauth2-client:create'],
|
auth: ['system:oauth2-client:create'],
|
||||||
onClick: onCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('ui.actionTitle.deleteBatch'),
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
disabled: isEmpty(checkedIds),
|
|
||||||
auth: ['system:oauth2-client:delete'],
|
auth: ['system:oauth2-client:delete'],
|
||||||
onClick: onDeleteBatch,
|
disabled: isEmpty(checkedIds),
|
||||||
|
onClick: handleDeleteBatch,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['system:oauth2-client:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['system:oauth2-client:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ const [Form, formApi] = useVbenForm({
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
},
|
},
|
||||||
formItemClass: 'col-span-2',
|
labelWidth: 140,
|
||||||
labelWidth: 80,
|
|
||||||
},
|
},
|
||||||
|
wrapperClass: 'grid-cols-2',
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle">
|
<Modal class="w-1/2" :title="getTitle">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user