feat: 【ele】站内信管理新增批量删除

pull/146/head
puhui999 2025-06-16 21:26:38 +08:00
parent d1b3a98b7c
commit 586c9e161c
3 changed files with 73 additions and 21 deletions

View File

@ -59,6 +59,13 @@ export function deleteNotifyTemplate(id: number) {
return requestClient.delete(`/system/notify-template/delete?id=${id}`); return requestClient.delete(`/system/notify-template/delete?id=${id}`);
} }
/** 批量删除站内信模板 */
export function deleteNotifyTemplateList(ids: number[]) {
return requestClient.delete(
`/system/notify-template/delete-list?ids=${ids.join(',')}`,
);
}
/** 导出站内信模板 */ /** 导出站内信模板 */
export function exportNotifyTemplate(params: any) { export function exportNotifyTemplate(params: any) {
return requestClient.download('/system/notify-template/export-excel', { return requestClient.download('/system/notify-template/export-excel', {

View File

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

View File

@ -5,15 +5,17 @@ import type {
} from '#/adapter/vxe-table'; } from '#/adapter/vxe-table';
import type { SystemNotifyTemplateApi } from '#/api/system/notify/template'; import type { SystemNotifyTemplateApi } from '#/api/system/notify/template';
import { ref } from 'vue';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { Download, Plus } from '@vben/icons'; import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { downloadFileFromBlobPart } from '@vben/utils';
import { ElButton, ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
deleteNotifyTemplate, deleteNotifyTemplate,
deleteNotifyTemplateList,
exportNotifyTemplate, exportNotifyTemplate,
getNotifyTemplatePage, getNotifyTemplatePage,
} from '#/api/system/notify/template'; } from '#/api/system/notify/template';
@ -76,6 +78,32 @@ async function onDelete(row: SystemNotifyTemplateApi.NotifyTemplate) {
} }
} }
/** 批量删除站内信模板 */
async function onDeleteBatch() {
const loadingInstance = ElMessage({
message: $t('ui.actionMessage.deleting'),
type: 'info',
duration: 0,
});
try {
await deleteNotifyTemplateList(checkedIds.value);
loadingInstance.close();
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh();
} finally {
loadingInstance.close();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: SystemNotifyTemplateApi.NotifyTemplate[];
}) {
checkedIds.value = records.map((item) => item.id as number);
}
/** 表格操作按钮的回调函数 */ /** 表格操作按钮的回调函数 */
function onActionClick({ function onActionClick({
code, code,
@ -124,6 +152,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
search: true, search: true,
}, },
} as VxeTableGridOptions<SystemNotifyTemplateApi.NotifyTemplate>, } as VxeTableGridOptions<SystemNotifyTemplateApi.NotifyTemplate>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
checkboxChange: handleRowCheckboxChange,
},
}); });
</script> </script>
@ -137,23 +169,32 @@ const [Grid, gridApi] = useVbenVxeGrid({
<SendModal /> <SendModal />
<Grid table-title=""> <Grid table-title="">
<template #toolbar-tools> <template #toolbar-tools>
<ElButton <TableAction
type="primary" :actions="[
@click="onCreate" {
v-access:code="['system:notify-template:create']" label: $t('ui.actionTitle.create', ['站内信模板']),
> type: 'primary',
<Plus class="mr-2 size-5" /> icon: ACTION_ICON.ADD,
{{ $t('ui.actionTitle.create', ['站内信模板']) }} auth: ['system:notify-template:create'],
</ElButton> onClick: onCreate,
<ElButton },
type="primary" {
class="ml-2" label: $t('ui.actionTitle.export'),
@click="onExport" type: 'primary',
v-access:code="['system:notify-template:export']" icon: ACTION_ICON.DOWNLOAD,
> auth: ['system:notify-template:export'],
<Download class="mr-2 size-5" /> onClick: onExport,
{{ $t('ui.actionTitle.export') }} },
</ElButton> {
label: $t('ui.actionTitle.deleteBatch'),
type: 'danger',
icon: ACTION_ICON.DELETE,
disabled: isEmpty(checkedIds),
auth: ['system:notify-template:delete'],
onClick: onDeleteBatch,
},
]"
/>
</template> </template>
</Grid> </Grid>
</Page> </Page>