fix: dept leaderUser
This commit is contained in:
@@ -10,6 +10,8 @@ import { z } from '#/adapter/form';
|
||||
import { getDeptList } from '#/api/system/dept';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
|
||||
const userList = await getSimpleUserList();
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -109,9 +111,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(
|
||||
getLeaderName?: (userId: number) => string | undefined,
|
||||
): VxeTableGridOptions<SystemDeptApi.Dept>['columns'] {
|
||||
export function useGridColumns(): VxeTableGridOptions<SystemDeptApi.Dept>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
@@ -126,7 +126,8 @@ export function useGridColumns(
|
||||
field: 'leaderUserId',
|
||||
title: '负责人',
|
||||
minWidth: 150,
|
||||
formatter: ({ cellValue }) => getLeaderName?.(cellValue) || '-',
|
||||
formatter: ({ cellValue }) =>
|
||||
userList.find((user) => user.id === cellValue)?.nickname || '-',
|
||||
},
|
||||
{
|
||||
field: 'sort',
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemDeptApi } from '#/api/system/dept';
|
||||
import type { SystemUserApi } from '#/api/system/user';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
@@ -12,7 +11,6 @@ import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteDept, deleteDeptList, getDeptList } from '#/api/system/dept';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns } from './data';
|
||||
@@ -23,12 +21,6 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 获取负责人名称 */
|
||||
const userList = ref<SystemUserApi.User[]>([]);
|
||||
function getLeaderName(userId: number) {
|
||||
return userList.value.find((user) => user.id === userId)?.nickname;
|
||||
}
|
||||
|
||||
/** 切换树形展开/收缩状态 */
|
||||
const isExpanded = ref(true);
|
||||
function handleExpand() {
|
||||
@@ -99,7 +91,7 @@ function handleRowCheckboxChange({
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useGridColumns(getLeaderName),
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
@@ -132,11 +124,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
userList.value = await getSimpleUserList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user