From db46ebbbcbef937d92590f205b5f880cd9ae1fde Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 29 Mar 2025 15:57:41 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=20dept=20?= =?UTF-8?q?=E9=83=A8=E9=97=A8=20100%=EF=BC=88=E5=88=B7=E6=96=B0=E3=80=81?= =?UTF-8?q?=E6=94=B6=E7=BC=A9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/system/dept/data.ts | 11 +++++++---- apps/web-antd/src/views/system/dept/index.vue | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/apps/web-antd/src/views/system/dept/data.ts b/apps/web-antd/src/views/system/dept/data.ts index 457973942..eba3c4601 100644 --- a/apps/web-antd/src/views/system/dept/data.ts +++ b/apps/web-antd/src/views/system/dept/data.ts @@ -115,9 +115,7 @@ export function useSchema(): VbenFormSchema[] { { component: 'RadioGroup', componentProps: { - buttonStyle: 'solid', options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), - optionType: 'button', }, fieldName: 'status', label: '状态', @@ -127,6 +125,7 @@ export function useSchema(): VbenFormSchema[] { } /** 获取表格列配置 */ +const userList = await getSimpleUserList(); export function useColumns( onActionClick?: OnActionClickFn, ): VxeTableGridOptions['columns'] { @@ -139,11 +138,15 @@ export function useColumns( treeNode: true, minWidth: 150, }, - // TODO @芋艿:需要通过 userList 翻译 { - field: 'leader', + field: 'leaderUserId', title: '负责人', minWidth: 150, + formatter: (row) => { + return ( + userList.find((user) => user.id === row.cellValue)?.nickname || '-' + ); + }, }, { field: 'sort', diff --git a/apps/web-antd/src/views/system/dept/index.vue b/apps/web-antd/src/views/system/dept/index.vue index 92e1eda5f..756227d6e 100644 --- a/apps/web-antd/src/views/system/dept/index.vue +++ b/apps/web-antd/src/views/system/dept/index.vue @@ -5,6 +5,7 @@ import type { } from '#/adapter/vxe-table'; import type { SystemDeptApi } from '#/api/system/dept'; +import { ref } from 'vue'; import { $t } from '#/locales'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteDept, getDeptList } from '#/api/system/dept'; @@ -92,6 +93,9 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, }, }, + rowConfig: { + keyField: 'id', + }, toolbarConfig: { custom: true, export: false, @@ -103,6 +107,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ rowField: 'id', transform: true, expandAll: true, + reserve: true, }, } as VxeTableGridOptions, }); @@ -111,8 +116,13 @@ const [Grid, gridApi] = useVbenVxeGrid({ function refreshGrid() { gridApi.query(); } -// TODO @芋艿:展开/折叠所有 -// TODO @芋艿:刷新后,就折叠起来了! + +/** 切换树形展开/收缩状态 */ +const isExpanded = ref(true); +function toggleExpand() { + isExpanded.value = !isExpanded.value; + gridApi.grid.setAllTreeExpand(isExpanded.value); +}