diff --git a/apps/web-antd/src/api/system/social/client/index.ts b/apps/web-antd/src/api/system/social/client/index.ts index d4da4dd48..181cdf86b 100644 --- a/apps/web-antd/src/api/system/social/client/index.ts +++ b/apps/web-antd/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-antd/src/views/system/social/client/data.ts b/apps/web-antd/src/views/system/social/client/data.ts index deeb0aed1..bbcd3c18b 100644 --- a/apps/web-antd/src/views/system/social/client/data.ts +++ b/apps/web-antd/src/views/system/social/client/data.ts @@ -104,6 +104,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入应用名', + allowClear: true, }, }, { @@ -132,6 +133,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入客户端编号', + allowClear: true, }, }, { @@ -150,17 +152,21 @@ export function useGridFormSchema(): VbenFormSchema[] { /** 列表的字段 */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ + { type: 'checkbox', width: 40 }, { field: 'id', title: '编号', + minWidth: 100, }, { field: 'name', title: '应用名', + minWidth: 120, }, { field: 'socialType', title: '社交平台', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, @@ -169,6 +175,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'userType', title: '用户类型', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.USER_TYPE }, @@ -177,10 +184,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'clientId', title: '客户端编号', + minWidth: 180, }, { field: 'status', title: '状态', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, @@ -189,11 +198,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'createTime', title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { title: '操作', - width: 130, + width: 220, fixed: 'right', slots: { default: 'actions' }, }, diff --git a/apps/web-antd/src/views/system/social/client/index.vue b/apps/web-antd/src/views/system/social/client/index.vue index 567561694..afda4ad04 100644 --- a/apps/web-antd/src/views/system/social/client/index.vue +++ b/apps/web-antd/src/views/system/social/client/index.vue @@ -2,13 +2,17 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { SystemSocialClientApi } from '#/api/system/social/client'; -import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; +import { ref } from 'vue'; + +import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui'; +import { isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteSocialClient, + deleteSocialClientList, getSocialClientPage, } from '#/api/system/social/client'; import { $t } from '#/locales'; @@ -22,7 +26,7 @@ const [FormModal, formModalApi] = useVbenModal({ }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } @@ -40,20 +44,43 @@ function handleEdit(row: SystemSocialClientApi.SocialClient) { async function handleDelete(row: SystemSocialClientApi.SocialClient) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.name]), - key: 'action_key_msg', + duration: 0, }); try { await deleteSocialClient(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.name]), - key: 'action_key_msg', - }); - onRefresh(); + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); + handleRefresh(); } finally { hideLoading(); } } +/** 批量删除社交客户端 */ +async function handleDeleteBatch() { + await confirm($t('ui.actionMessage.deleteBatchConfirm')); + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deletingBatch'), + duration: 0, + }); + try { + await deleteSocialClientList(checkedIds.value); + checkedIds.value = []; + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); + } finally { + hideLoading(); + } +} + +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemSocialClientApi.SocialClient[]; +}) { + checkedIds.value = records.map((item) => item.id!); +} + const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -75,12 +102,17 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, search: true, }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -90,7 +122,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ - + diff --git a/apps/web-antd/src/views/system/social/user/data.ts b/apps/web-antd/src/views/system/social/user/data.ts index 7b8e1dae6..a420fb3d3 100644 --- a/apps/web-antd/src/views/system/social/user/data.ts +++ b/apps/web-antd/src/views/system/social/user/data.ts @@ -55,6 +55,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'type', title: '社交平台', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, @@ -63,14 +64,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'openid', title: '社交 openid', + minWidth: 180, }, { field: 'nickname', title: '用户昵称', + minWidth: 120, }, { field: 'avatar', title: '用户头像', + minWidth: 100, cellRender: { name: 'CellImage', }, @@ -78,16 +82,18 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'createTime', title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { field: 'updateTime', title: '更新时间', + minWidth: 180, formatter: 'formatDateTime', }, { title: '操作', - width: 80, + width: 120, fixed: 'right', slots: { default: 'actions' }, }, diff --git a/apps/web-antd/src/views/system/social/user/index.vue b/apps/web-antd/src/views/system/social/user/index.vue index 1659a3a21..08a413543 100644 --- a/apps/web-antd/src/views/system/social/user/index.vue +++ b/apps/web-antd/src/views/system/social/user/index.vue @@ -3,10 +3,10 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { SystemSocialUserApi } from '#/api/system/social/user'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { $t } from '@vben/locales'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { getSocialUserPage } from '#/api/system/social/user'; +import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; import Detail from './modules/detail.vue'; @@ -42,6 +42,7 @@ const [Grid] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, 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 e366e00cc..8ddb5c242 100644 --- a/apps/web-ele/src/views/system/social/client/data.ts +++ b/apps/web-ele/src/views/system/social/client/data.ts @@ -1,8 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; -import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; -import type { SystemSocialClientApi } from '#/api/system/social/client'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; -import { useAccess } from '@vben/access'; import { CommonStatusEnum, DICT_TYPE, @@ -12,8 +10,6 @@ import { getDictOptions } from '@vben/hooks'; import { z } from '#/adapter/form'; -const { hasAccessByCodes } = useAccess(); - /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { return [ @@ -108,6 +104,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入应用名', + clearable: true, }, }, { @@ -136,6 +133,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入客户端编号', + clearable: true, }, }, { @@ -152,18 +150,13 @@ export function useGridFormSchema(): VbenFormSchema[] { } /** 列表的字段 */ -export function useGridColumns( - onActionClick: OnActionClickFn, -): VxeTableGridOptions['columns'] { +export function useGridColumns(): VxeTableGridOptions['columns'] { return [ - { - type: 'checkbox', - width: 40, - }, + { type: 'checkbox', width: 40 }, { field: 'id', title: '编号', - minWidth: 80, + minWidth: 100, }, { field: 'name', @@ -173,7 +166,7 @@ export function useGridColumns( { field: 'socialType', title: '社交平台', - minWidth: 120, + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_SOCIAL_TYPE }, @@ -182,7 +175,7 @@ export function useGridColumns( { field: 'userType', title: '用户类型', - minWidth: 120, + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.USER_TYPE }, @@ -196,7 +189,7 @@ export function useGridColumns( { field: 'status', title: '状态', - minWidth: 80, + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, @@ -209,29 +202,10 @@ export function useGridColumns( formatter: 'formatDateTime', }, { - field: 'operation', title: '操作', - minWidth: 130, - align: 'center', + width: 220, fixed: 'right', - cellRender: { - attrs: { - nameField: 'name', - nameTitle: '社交客户端', - onClick: onActionClick, - }, - name: 'CellOperation', - options: [ - { - code: 'edit', - show: hasAccessByCodes(['system:social-client:update']), - }, - { - code: 'delete', - show: hasAccessByCodes(['system:social-client:delete']), - }, - ], - }, + slots: { default: 'actions' }, }, ]; } 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 15d303bca..f03f3f80d 100644 --- a/apps/web-ele/src/views/system/social/client/index.vue +++ b/apps/web-ele/src/views/system/social/client/index.vue @@ -1,8 +1,5 @@