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',
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<SystemDeptApi.SystemDept>,
): VxeTableGridOptions<SystemDeptApi.SystemDept>['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',

View File

@ -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);
}
</script>
<template>
<Page auto-content-height>
@ -123,6 +133,9 @@ function refreshGrid() {
<Plus class="size-5" />
{{ $t('ui.actionTitle.create', ['部门']) }}
</Button>
<Button class="ml-2" @click="toggleExpand">
{{ isExpanded ? '收缩' : '展开' }}
</Button>
</template>
</Grid>
</Page>