From e9f2b5701cd6165f198e116366e56f4b7129fac2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 22 Apr 2025 18:49:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=8A=A5=E9=94=99=EF=BC=9A=20top=20level=20await=20?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/upload/use-upload.ts | 4 ++-- apps/web-antd/src/views/system/dept/data.ts | 7 +++---- apps/web-antd/src/views/system/dept/index.vue | 18 ++++++++++++++-- .../src/views/system/mail/template/data.ts | 6 +++--- .../src/views/system/mail/template/index.vue | 18 +++++++++++++++- apps/web-antd/src/views/system/tenant/data.ts | 11 +++------- .../src/views/system/tenant/index.vue | 21 ++++++++++++++++++- packages/icons/src/iconify/index.ts | 4 +++- 8 files changed, 67 insertions(+), 22 deletions(-) diff --git a/apps/web-antd/src/components/upload/use-upload.ts b/apps/web-antd/src/components/upload/use-upload.ts index a11727c6e..7b9b4ca66 100644 --- a/apps/web-antd/src/components/upload/use-upload.ts +++ b/apps/web-antd/src/components/upload/use-upload.ts @@ -4,7 +4,7 @@ import type { AxiosProgressEvent, InfraFileApi } from '#/api/infra/file'; import { computed, unref } from 'vue'; import { $t } from '@vben/locales'; import CryptoJS from 'crypto-js' -import axios from 'axios' +import { baseRequestClient } from '#/api/request'; import { uploadFile, getFilePresignedUrl, createFile } from '#/api/infra/file'; export function useUploadType({ @@ -78,7 +78,7 @@ export const useUpload = () => { // 1.2 获取文件预签名地址 const presignedInfo = await getFilePresignedUrl(fileName) // 1.3 上传文件 - return axios + return baseRequestClient .put(presignedInfo.uploadUrl, file, { headers: { 'Content-Type': file.type diff --git a/apps/web-antd/src/views/system/dept/data.ts b/apps/web-antd/src/views/system/dept/data.ts index 1f3c3d691..ce12f4cd3 100644 --- a/apps/web-antd/src/views/system/dept/data.ts +++ b/apps/web-antd/src/views/system/dept/data.ts @@ -3,6 +3,7 @@ import type { VxeTableGridOptions } from '@vben/plugins/vxe-table'; import type { VbenFormSchema } from '#/adapter/form'; import type { OnActionClickFn } from '#/adapter/vxe-table'; import type { SystemDeptApi } from '#/api/system/dept'; +import type { SystemUserApi } from '#/api/system/user'; import { useAccess } from '@vben/access'; @@ -122,9 +123,9 @@ export function useFormSchema(): VbenFormSchema[] { } /** 列表的字段 */ -const userList = await getSimpleUserList(); export function useGridColumns( onActionClick?: OnActionClickFn, + getLeaderName?: (userId: number) => string | undefined, ): VxeTableGridOptions['columns'] { return [ { @@ -140,9 +141,7 @@ export function useGridColumns( title: '负责人', minWidth: 150, formatter: (row) => { - return ( - userList.find((user) => user.id === row.cellValue)?.nickname || '-' - ); + return getLeaderName?.(row.cellValue) || '-'; }, }, { diff --git a/apps/web-antd/src/views/system/dept/index.vue b/apps/web-antd/src/views/system/dept/index.vue index b790d2dec..f15cabd34 100644 --- a/apps/web-antd/src/views/system/dept/index.vue +++ b/apps/web-antd/src/views/system/dept/index.vue @@ -4,8 +4,9 @@ import type { VxeTableGridOptions, } from '#/adapter/vxe-table'; import type { SystemDeptApi } from '#/api/system/dept'; +import type { SystemUserApi } from '#/api/system/user'; -import { ref } from 'vue'; +import { onMounted, ref } from 'vue'; import { Page, useVbenModal } from '@vben/common-ui'; import { Plus } from '@vben/icons'; @@ -14,6 +15,7 @@ import { Button, message } from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteDept, getDeptList } from '#/api/system/dept'; +import { getSimpleUserList } from '#/api/system/user'; import { $t } from '#/locales'; import { useGridColumns } from './data'; @@ -24,6 +26,13 @@ const [FormModal, formModalApi] = useVbenModal({ destroyOnClose: true, }); +const userList = ref([]); + +/** 获取负责人名称 */ +const getLeaderName = (userId: number) => { + return userList.value.find((user) => user.id === userId)?.nickname; +}; + /** 刷新表格 */ function onRefresh() { gridApi.query(); @@ -93,7 +102,7 @@ function onActionClick({ const [Grid, gridApi] = useVbenVxeGrid({ gridOptions: { - columns: useGridColumns(onActionClick), + columns: useGridColumns(onActionClick, getLeaderName), height: 'auto', keepSource: true, pagerConfig: { @@ -121,6 +130,11 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, } as VxeTableGridOptions, }); + +/** 初始化 */ +onMounted(async () => { + userList.value = await getSimpleUserList(); +});