feat: 【ele】OAuth 2.0 新增批量删除
parent
c79b569a13
commit
c874f754b8
|
@ -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(',')}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -195,6 +195,10 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
||||||
onActionClick: OnActionClickFn<T>,
|
onActionClick: OnActionClickFn<T>,
|
||||||
): VxeTableGridOptions['columns'] {
|
): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
width: 40,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'clientId',
|
field: 'clientId',
|
||||||
title: '客户端编号',
|
title: '客户端编号',
|
||||||
|
|
|
@ -5,14 +5,17 @@ import type {
|
||||||
} from '#/adapter/vxe-table';
|
} 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 { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
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 {
|
import {
|
||||||
deleteOAuth2Client,
|
deleteOAuth2Client,
|
||||||
|
deleteOAuth2ClientList,
|
||||||
getOAuth2ClientPage,
|
getOAuth2ClientPage,
|
||||||
} from '#/api/system/oauth2/client';
|
} from '#/api/system/oauth2/client';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
@ -50,13 +53,35 @@ async function onDelete(row: SystemOAuth2ClientApi.OAuth2Client) {
|
||||||
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();
|
onRefresh();
|
||||||
} catch {
|
|
||||||
// 异常处理
|
|
||||||
} finally {
|
} finally {
|
||||||
loadingInstance.close();
|
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<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: SystemOAuth2ClientApi.OAuth2Client[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id as number);
|
||||||
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
/** 表格操作按钮的回调函数 */
|
||||||
function onActionClick({
|
function onActionClick({
|
||||||
code,
|
code,
|
||||||
|
@ -101,6 +126,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<SystemOAuth2ClientApi.OAuth2Client>,
|
} as VxeTableGridOptions<SystemOAuth2ClientApi.OAuth2Client>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -116,14 +145,25 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="onRefresh" />
|
||||||
<Grid table-title="OAuth2 客户端列表">
|
<Grid table-title="OAuth2 客户端列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<ElButton
|
<TableAction
|
||||||
type="primary"
|
:actions="[
|
||||||
@click="onCreate"
|
{
|
||||||
v-access:code="['system:oauth2-client:create']"
|
label: $t('ui.actionTitle.create', [' OAuth2.0 客户端']),
|
||||||
>
|
type: 'primary',
|
||||||
<Plus class="mr-2 size-5" />
|
icon: ACTION_ICON.ADD,
|
||||||
{{ $t('ui.actionTitle.create', [' OAuth2.0 客户端']) }}
|
auth: ['system:oauth2-client:create'],
|
||||||
</ElButton>
|
onClick: onCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
|
type: 'danger',
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
|
auth: ['system:oauth2-client:delete'],
|
||||||
|
onClick: onDeleteBatch,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
Loading…
Reference in New Issue