diff --git a/apps/web-ele/src/api/system/notify/template/index.ts b/apps/web-ele/src/api/system/notify/template/index.ts index 5f2e3de29..dd19f4b8f 100644 --- a/apps/web-ele/src/api/system/notify/template/index.ts +++ b/apps/web-ele/src/api/system/notify/template/index.ts @@ -59,6 +59,13 @@ export function deleteNotifyTemplate(id: number) { 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) { return requestClient.download('/system/notify-template/export-excel', { diff --git a/apps/web-ele/src/views/system/notify/template/data.ts b/apps/web-ele/src/views/system/notify/template/data.ts index d85675ba8..50d4378e5 100644 --- a/apps/web-ele/src/views/system/notify/template/data.ts +++ b/apps/web-ele/src/views/system/notify/template/data.ts @@ -233,6 +233,10 @@ export function useGridColumns( onActionClick: OnActionClickFn, ): VxeTableGridOptions['columns'] { return [ + { + type: 'checkbox', + width: 40, + }, { field: 'id', title: '编号', diff --git a/apps/web-ele/src/views/system/notify/template/index.vue b/apps/web-ele/src/views/system/notify/template/index.vue index b585dc78c..bbfa31a1f 100644 --- a/apps/web-ele/src/views/system/notify/template/index.vue +++ b/apps/web-ele/src/views/system/notify/template/index.vue @@ -5,15 +5,17 @@ import type { } from '#/adapter/vxe-table'; import type { SystemNotifyTemplateApi } from '#/api/system/notify/template'; +import { ref } from 'vue'; + import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { Download, Plus } from '@vben/icons'; -import { downloadFileFromBlobPart } from '@vben/utils'; +import { downloadFileFromBlobPart, isEmpty } 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 { deleteNotifyTemplate, + deleteNotifyTemplateList, exportNotifyTemplate, getNotifyTemplatePage, } 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([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemNotifyTemplateApi.NotifyTemplate[]; +}) { + checkedIds.value = records.map((item) => item.id as number); +} + /** 表格操作按钮的回调函数 */ function onActionClick({ code, @@ -124,6 +152,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ search: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -137,23 +169,32 @@ const [Grid, gridApi] = useVbenVxeGrid({