feat:完善 dept 部门 100%(刷新、收缩)

pull/62/head
YunaiV 2025-03-29 15:57:41 +08:00
parent d8f4e0a1aa
commit db46ebbbcb
2 changed files with 22 additions and 6 deletions

View File

@ -115,9 +115,7 @@ export function useSchema(): VbenFormSchema[] {
{ {
component: 'RadioGroup', component: 'RadioGroup',
componentProps: { componentProps: {
buttonStyle: 'solid',
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
optionType: 'button',
}, },
fieldName: 'status', fieldName: 'status',
label: '状态', label: '状态',
@ -127,6 +125,7 @@ export function useSchema(): VbenFormSchema[] {
} }
/** 获取表格列配置 */ /** 获取表格列配置 */
const userList = await getSimpleUserList();
export function useColumns( export function useColumns(
onActionClick?: OnActionClickFn<SystemDeptApi.SystemDept>, onActionClick?: OnActionClickFn<SystemDeptApi.SystemDept>,
): VxeTableGridOptions<SystemDeptApi.SystemDept>['columns'] { ): VxeTableGridOptions<SystemDeptApi.SystemDept>['columns'] {
@ -139,11 +138,15 @@ export function useColumns(
treeNode: true, treeNode: true,
minWidth: 150, minWidth: 150,
}, },
// TODO @芋艿:需要通过 userList 翻译
{ {
field: 'leader', field: 'leaderUserId',
title: '负责人', title: '负责人',
minWidth: 150, minWidth: 150,
formatter: (row) => {
return (
userList.find((user) => user.id === row.cellValue)?.nickname || '-'
);
},
}, },
{ {
field: 'sort', field: 'sort',

View File

@ -5,6 +5,7 @@ import type {
} from '#/adapter/vxe-table'; } from '#/adapter/vxe-table';
import type { SystemDeptApi } from '#/api/system/dept'; import type { SystemDeptApi } from '#/api/system/dept';
import { ref } from 'vue';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteDept, getDeptList } from '#/api/system/dept'; import { deleteDept, getDeptList } from '#/api/system/dept';
@ -92,6 +93,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
}, },
}, },
rowConfig: {
keyField: 'id',
},
toolbarConfig: { toolbarConfig: {
custom: true, custom: true,
export: false, export: false,
@ -103,6 +107,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
rowField: 'id', rowField: 'id',
transform: true, transform: true,
expandAll: true, expandAll: true,
reserve: true,
}, },
} as VxeTableGridOptions, } as VxeTableGridOptions,
}); });
@ -111,8 +116,13 @@ const [Grid, gridApi] = useVbenVxeGrid({
function refreshGrid() { function refreshGrid() {
gridApi.query(); gridApi.query();
} }
// TODO @/
// TODO @ /** 切换树形展开/收缩状态 */
const isExpanded = ref(true);
function toggleExpand() {
isExpanded.value = !isExpanded.value;
gridApi.grid.setAllTreeExpand(isExpanded.value);
}
</script> </script>
<template> <template>
<Page auto-content-height> <Page auto-content-height>
@ -123,6 +133,9 @@ function refreshGrid() {
<Plus class="size-5" /> <Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['部门']) }} {{ $t('ui.actionTitle.create', ['部门']) }}
</Button> </Button>
<Button class="ml-2" @click="toggleExpand">
{{ isExpanded ? '收缩' : '展开' }}
</Button>
</template> </template>
</Grid> </Grid>
</Page> </Page>