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