From 182c447ef83adf6ec182e2d8af221f3f536dd361 Mon Sep 17 00:00:00 2001 From: xingyu Date: Tue, 28 Mar 2023 22:43:10 +0800 Subject: [PATCH] fix: dept leaderUserId #I6R4NH --- src/views/system/dept/dept.data.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/views/system/dept/dept.data.ts b/src/views/system/dept/dept.data.ts index 177433a4..3f38722f 100644 --- a/src/views/system/dept/dept.data.ts +++ b/src/views/system/dept/dept.data.ts @@ -3,6 +3,15 @@ import { getListSimpleUsers } from '@/api/system/user' import { BasicColumn, FormSchema, useRender } from '@/components/Table' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' +let userOptions: any[] = [] + +async function getUserList() { + const res = await getListSimpleUsers() + userOptions = res +} + +await getUserList() + export const columns: BasicColumn[] = [ { title: '部门名称', @@ -12,8 +21,19 @@ export const columns: BasicColumn[] = [ }, { title: '负责人', - dataIndex: 'leader', - width: 120 + dataIndex: 'leaderUserId', + width: 120, + customRender: ({ text }) => { + if (!text) { + return '未设置' + } + for (const user of userOptions) { + if (text === user.id) { + return user.nickname + } + } + return '未知【' + text + '】' + } }, { title: '排序', @@ -94,7 +114,7 @@ export const formSchema: FormSchema[] = [ field: 'leaderUserId', component: 'ApiSelect', componentProps: { - api: () => getListSimpleUsers(), + options: () => getListSimpleUsers(), labelField: 'nickname', valueField: 'id' }