fix: tenant tenantPackage
This commit is contained in:
@@ -8,6 +8,8 @@ import { z } from '#/adapter/form';
|
||||
import { getTenantPackageList } from '#/api/system/tenant-package';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
const tenantPackageList = await getTenantPackageList();
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -163,9 +165,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(
|
||||
getPackageName?: (packageId: number) => string | undefined,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
@@ -182,8 +182,10 @@ export function useGridColumns(
|
||||
field: 'packageId',
|
||||
title: '租户套餐',
|
||||
minWidth: 180,
|
||||
formatter: (row: { cellValue: number }) => {
|
||||
return getPackageName?.(row.cellValue) || '-';
|
||||
formatter: ({ cellValue }) => {
|
||||
return cellValue === 0
|
||||
? '系统租户'
|
||||
: tenantPackageList.find((pkg) => pkg.id === cellValue)?.name || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemTenantApi } from '#/api/system/tenant';
|
||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
@@ -17,22 +16,11 @@ import {
|
||||
exportTenant,
|
||||
getTenantPage,
|
||||
} from '#/api/system/tenant';
|
||||
import { getTenantPackageList } from '#/api/system/tenant-package';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const tenantPackageList = ref<SystemTenantPackageApi.TenantPackage[]>([]);
|
||||
|
||||
/** 获取套餐名称 */
|
||||
const getPackageName = (packageId: number) => {
|
||||
if (packageId === 0) {
|
||||
return '系统租户';
|
||||
}
|
||||
return tenantPackageList.value.find((pkg) => pkg.id === packageId)?.name;
|
||||
};
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
@@ -105,7 +93,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(getPackageName),
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
@@ -133,11 +121,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
tenantPackageList.value = await getTenantPackageList();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
|
||||
@@ -8,6 +8,8 @@ import { z } from '#/adapter/form';
|
||||
import { getTenantPackageList } from '#/api/system/tenant-package';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
const tenantPackageList = await getTenantPackageList();
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -164,9 +166,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(
|
||||
getPackageName?: (packageId: number) => string | undefined,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
@@ -183,8 +183,10 @@ export function useGridColumns(
|
||||
field: 'packageId',
|
||||
title: '租户套餐',
|
||||
minWidth: 180,
|
||||
formatter: (row: { cellValue: number }) => {
|
||||
return getPackageName?.(row.cellValue) || '-';
|
||||
formatter: ({ cellValue }) => {
|
||||
return cellValue === 0
|
||||
? '系统租户'
|
||||
: tenantPackageList.find((pkg) => pkg.id === cellValue)?.name || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemTenantApi } from '#/api/system/tenant';
|
||||
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
@@ -17,22 +16,11 @@ import {
|
||||
exportTenant,
|
||||
getTenantPage,
|
||||
} from '#/api/system/tenant';
|
||||
import { getTenantPackageList } from '#/api/system/tenant-package';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const tenantPackageList = ref<SystemTenantPackageApi.TenantPackage[]>([]);
|
||||
|
||||
/** 获取套餐名称 */
|
||||
const getPackageName = (packageId: number) => {
|
||||
if (packageId === 0) {
|
||||
return '系统租户';
|
||||
}
|
||||
return tenantPackageList.value.find((pkg) => pkg.id === packageId)?.name;
|
||||
};
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
@@ -103,7 +91,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(getPackageName),
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
@@ -131,11 +119,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
tenantPackageList.value = await getTenantPackageList();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
|
||||
Reference in New Issue
Block a user