From e838537356909264e7dc44d60d698d2df63e15ed Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Sat, 4 Jan 2025 18:30:20 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-antd/src/components/tree/src/data.tsx | 79 ++++++++ .../components/tree/src/menu-select-table.vue | 169 +++++++----------- .../views/system/role-beta/role-drawer.vue | 2 +- 3 files changed, 145 insertions(+), 105 deletions(-) create mode 100644 apps/web-antd/src/components/tree/src/data.tsx diff --git a/apps/web-antd/src/components/tree/src/data.tsx b/apps/web-antd/src/components/tree/src/data.tsx new file mode 100644 index 00000000..441caf45 --- /dev/null +++ b/apps/web-antd/src/components/tree/src/data.tsx @@ -0,0 +1,79 @@ +import type { VxeGridProps } from '#/adapter/vxe-table'; +import type { ID } from '#/api/common'; +import type { MenuOption } from '#/api/system/menu/model'; + +import { FolderIcon, MenuIcon, OkButtonIcon, VbenIcon } from '@vben/icons'; +import { h, markRaw } from 'vue'; + +export interface Permission { + checked: boolean; + id: ID; + label: string; +} + +export interface MenuPermissionOption extends MenuOption { + permissions: Permission[]; +} + +const menuTypes = { + C: { icon: markRaw(MenuIcon), value: '菜单' }, + F: { icon: markRaw(OkButtonIcon), value: '按钮' }, + M: { icon: markRaw(FolderIcon), value: '目录' }, +}; + +export const columns: VxeGridProps['columns'] = [ + { + type: 'checkbox', + title: '菜单名称', + field: 'label', + treeNode: true, + headerAlign: 'left', + align: 'left', + width: 230, + }, + { + title: '图标', + field: 'icon', + width: 80, + slots: { + default: ({ row }) => { + if (row?.icon === '#') { + return ''; + } + return ( + + + + ); + }, + }, + }, + { + title: '类型', + field: 'menuType', + width: 80, + slots: { + default: ({ row }) => { + const current = menuTypes[row.menuType as 'C' | 'F' | 'M']; + if (!current) { + return '未知'; + } + return ( + + {h(current.icon, { class: 'size-[18px]' })} + {current.value} + + ); + }, + }, + }, + { + title: '权限标识', + field: 'permissions', + headerAlign: 'left', + align: 'left', + slots: { + default: 'permissions', + }, + }, +]; diff --git a/apps/web-antd/src/components/tree/src/menu-select-table.vue b/apps/web-antd/src/components/tree/src/menu-select-table.vue index 5afe9cd7..c416ba39 100644 --- a/apps/web-antd/src/components/tree/src/menu-select-table.vue +++ b/apps/web-antd/src/components/tree/src/menu-select-table.vue @@ -1,15 +1,16 @@