feat: 【ele】社交客户端管理新增批量删除

pull/146/head
puhui999 2025-06-16 21:30:11 +08:00
parent d115c3d14a
commit c79b569a13
3 changed files with 64 additions and 13 deletions

View File

@ -46,3 +46,10 @@ export function updateSocialClient(data: SystemSocialClientApi.SocialClient) {
export function deleteSocialClient(id: number) {
return requestClient.delete(`/system/social-client/delete?id=${id}`);
}
/** 批量删除社交客户端 */
export function deleteSocialClientList(ids: number[]) {
return requestClient.delete(
`/system/social-client/delete-list?ids=${ids.join(',')}`,
);
}

View File

@ -156,6 +156,10 @@ export function useGridColumns<T = SystemSocialClientApi.SocialClient>(
onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
return [
{
type: 'checkbox',
width: 40,
},
{
field: 'id',
title: '编号',

View File

@ -5,14 +5,17 @@ import type {
} from '#/adapter/vxe-table';
import type { SystemSocialClientApi } from '#/api/system/social/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 {
deleteSocialClient,
deleteSocialClientList,
getSocialClientPage,
} from '#/api/system/social/client';
import { $t } from '#/locales';
@ -50,13 +53,35 @@ async function onDelete(row: SystemSocialClientApi.SocialClient) {
await deleteSocialClient(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
onRefresh();
} catch {
// finallyloading
} finally {
loadingInstance.close();
}
}
/** 批量删除社交客户端 */
async function onDeleteBatch() {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting'),
fullscreen: true,
});
try {
await deleteSocialClientList(checkedIds.value);
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh();
} finally {
loadingInstance.close();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: SystemSocialClientApi.SocialClient[];
}) {
checkedIds.value = records.map((item) => item.id as number);
}
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
@ -101,6 +126,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
search: true,
},
} as VxeTableGridOptions<SystemSocialClientApi.SocialClient>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
checkboxChange: handleRowCheckboxChange,
},
});
</script>
@ -113,14 +142,25 @@ const [Grid, gridApi] = useVbenVxeGrid({
<FormModal @success="onRefresh" />
<Grid table-title="">
<template #toolbar-tools>
<ElButton
type="primary"
@click="onCreate"
v-access:code="['system:social-client:create']"
>
<Plus class="mr-2 size-5" />
{{ $t('ui.actionTitle.create', ['社交客户端']) }}
</ElButton>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['社交客户端']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['system:social-client:create'],
onClick: onCreate,
},
{
label: $t('ui.actionTitle.deleteBatch'),
type: 'danger',
icon: ACTION_ICON.DELETE,
disabled: isEmpty(checkedIds),
auth: ['system:social-client:delete'],
onClick: onDeleteBatch,
},
]"
/>
</template>
</Grid>
</Page>