fix:修复打包报错: top level await 的问题
This commit is contained in:
@@ -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<SystemDeptApi.SystemDept>,
|
||||
getLeaderName?: (userId: number) => string | undefined,
|
||||
): VxeTableGridOptions<SystemDeptApi.SystemDept>['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) || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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<SystemUserApi.SystemUser[]>([]);
|
||||
|
||||
/** 获取负责人名称 */
|
||||
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();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user