From e8c87b5a2b8178a954f2be0bf79c1d954a7c2d17 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Thu, 15 May 2025 11:50:13 +0800 Subject: [PATCH] feat: use table-actions --- apps/web-antd/src/views/system/role/data.ts | 44 +------------ apps/web-antd/src/views/system/role/index.vue | 65 +++++++++++-------- apps/web-naive/src/adapter/vxe-table.ts | 36 +++++++--- 3 files changed, 68 insertions(+), 77 deletions(-) diff --git a/apps/web-antd/src/views/system/role/data.ts b/apps/web-antd/src/views/system/role/data.ts index aee51e3e..5b0a8b78 100644 --- a/apps/web-antd/src/views/system/role/data.ts +++ b/apps/web-antd/src/views/system/role/data.ts @@ -1,8 +1,5 @@ import type { VbenFormSchema } from '#/adapter/form'; -import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; -import type { SystemRoleApi } from '#/api/system/role'; - -import { useAccess } from '@vben/access'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { z } from '#/adapter/form'; import { @@ -13,8 +10,6 @@ import { SystemDataScopeEnum, } from '#/utils'; -const { hasAccessByCodes } = useAccess(); - /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { return [ @@ -189,9 +184,7 @@ export function useGridFormSchema(): VbenFormSchema[] { } /** 列表的字段 */ -export function useGridColumns( - onActionClick: OnActionClickFn, -): VxeTableGridOptions['columns'] { +export function useGridColumns(): VxeTableGridOptions['columns'] { return [ { field: 'id', @@ -243,41 +236,10 @@ export function useGridColumns( formatter: 'formatDateTime', }, { - field: 'operation', title: '操作', width: 240, fixed: 'right', - align: 'center', - cellRender: { - attrs: { - nameField: 'name', - nameTitle: '角色', - onClick: onActionClick, - }, - name: 'CellOperation', - options: [ - { - code: 'edit', - show: hasAccessByCodes(['system:role:update']), - }, - { - code: 'delete', - show: hasAccessByCodes(['system:role:delete']), - }, - { - code: 'assign-data-permission', - text: '数据权限', - show: hasAccessByCodes([ - 'system:permission:assign-role-data-scope', - ]), - }, - { - code: 'assign-menu', - text: '菜单权限', - show: hasAccessByCodes(['system:permission:assign-role-menu']), - }, - ], - }, + slots: { default: 'actions' }, }, ]; } diff --git a/apps/web-antd/src/views/system/role/index.vue b/apps/web-antd/src/views/system/role/index.vue index c00123c5..d344c2c6 100644 --- a/apps/web-antd/src/views/system/role/index.vue +++ b/apps/web-antd/src/views/system/role/index.vue @@ -1,8 +1,5 @@