From c79b569a13898b441620ee7bb0404235710b96a2 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 16 Jun 2025 21:30:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90ele=E3=80=91=E7=A4=BE=E4=BA=A4?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=AE=A1=E7=90=86=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/system/social/client/index.ts | 7 ++ .../src/views/system/social/client/data.ts | 4 ++ .../src/views/system/social/client/index.vue | 66 +++++++++++++++---- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/apps/web-ele/src/api/system/social/client/index.ts b/apps/web-ele/src/api/system/social/client/index.ts index d4da4dd48..181cdf86b 100644 --- a/apps/web-ele/src/api/system/social/client/index.ts +++ b/apps/web-ele/src/api/system/social/client/index.ts @@ -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(',')}`, + ); +} diff --git a/apps/web-ele/src/views/system/social/client/data.ts b/apps/web-ele/src/views/system/social/client/data.ts index 5cf391c27..d9440aeef 100644 --- a/apps/web-ele/src/views/system/social/client/data.ts +++ b/apps/web-ele/src/views/system/social/client/data.ts @@ -156,6 +156,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/social/client/index.vue b/apps/web-ele/src/views/system/social/client/index.vue index eb7a45711..46245f58e 100644 --- a/apps/web-ele/src/views/system/social/client/index.vue +++ b/apps/web-ele/src/views/system/social/client/index.vue @@ -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 { - // 发生错误时不需要做特殊处理,finally会关闭loading } 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([]); +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, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -113,14 +142,25 @@ const [Grid, gridApi] = useVbenVxeGrid({