From d115c3d14a53a6b00d72f7ad2a9f3f298242f93d Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 16 Jun 2025 21:28:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90ele=E3=80=91=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=AE=A1=E7=90=86=E6=96=B0=E5=A2=9E=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-ele/src/api/system/notice/index.ts | 7 ++ apps/web-ele/src/views/system/notice/data.ts | 4 + .../web-ele/src/views/system/notice/index.vue | 76 +++++++++++++++---- 3 files changed, 73 insertions(+), 14 deletions(-) diff --git a/apps/web-ele/src/api/system/notice/index.ts b/apps/web-ele/src/api/system/notice/index.ts index dac9ec70..5ae88853 100644 --- a/apps/web-ele/src/api/system/notice/index.ts +++ b/apps/web-ele/src/api/system/notice/index.ts @@ -46,6 +46,13 @@ export function deleteNotice(id: number) { return requestClient.delete(`/system/notice/delete?id=${id}`); } +/** 批量删除公告 */ +export function deleteNoticeList(ids: number[]) { + return requestClient.delete( + `/system/notice/delete-list?ids=${ids.join(',')}`, + ); +} + /** 推送公告 */ export function pushNotice(id: number) { return requestClient.post(`/system/notice/push?id=${id}`); diff --git a/apps/web-ele/src/views/system/notice/data.ts b/apps/web-ele/src/views/system/notice/data.ts index a181a534..8b74f238 100644 --- a/apps/web-ele/src/views/system/notice/data.ts +++ b/apps/web-ele/src/views/system/notice/data.ts @@ -95,6 +95,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/notice/index.vue b/apps/web-ele/src/views/system/notice/index.vue index f72fc8eb..4970ac43 100644 --- a/apps/web-ele/src/views/system/notice/index.vue +++ b/apps/web-ele/src/views/system/notice/index.vue @@ -5,13 +5,20 @@ import type { } from '#/adapter/vxe-table'; import type { SystemNoticeApi } from '#/api/system/notice'; +import { ref } from 'vue'; + import { Page, useVbenModal } from '@vben/common-ui'; -import { Plus } from '@vben/icons'; +import { isEmpty } from '@vben/utils'; -import { ElButton, ElMessage } from 'element-plus'; +import { ElMessage } from 'element-plus'; -import { useVbenVxeGrid } from '#/adapter/vxe-table'; -import { deleteNotice, getNoticePage, pushNotice } from '#/api/system/notice'; +import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; +import { + deleteNotice, + deleteNoticeList, + getNoticePage, + pushNotice, +} from '#/api/system/notice'; import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; @@ -49,11 +56,37 @@ async function onDelete(row: SystemNoticeApi.Notice) { loadingInstance.close(); ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.title])); onRefresh(); - } catch { + } finally { loadingInstance.close(); } } +/** 批量删除公告 */ +async function onDeleteBatch() { + const loadingInstance = ElMessage({ + message: $t('ui.actionMessage.deleting'), + type: 'info', + duration: 0, + }); + try { + await deleteNoticeList(checkedIds.value); + loadingInstance.close(); + ElMessage.success($t('ui.actionMessage.deleteSuccess')); + onRefresh(); + } finally { + loadingInstance.close(); + } +} + +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemNoticeApi.Notice[]; +}) { + checkedIds.value = records.map((item) => item.id as number); +} + /** 推送公告 */ async function onPush(row: SystemNoticeApi.Notice) { const loadingInstance = ElMessage({ @@ -65,7 +98,7 @@ async function onPush(row: SystemNoticeApi.Notice) { await pushNotice(row.id as number); loadingInstance.close(); ElMessage.success($t('ui.actionMessage.operationSuccess')); - } catch { + } finally { loadingInstance.close(); } } @@ -118,6 +151,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ search: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -126,14 +163,25 @@ const [Grid, gridApi] = useVbenVxeGrid({