diff --git a/src/components/custom/tenant-select.vue b/src/components/custom/tenant-select.vue index 7f9dbcb6..2c86c4e1 100644 --- a/src/components/custom/tenant-select.vue +++ b/src/components/custom/tenant-select.vue @@ -3,10 +3,10 @@ import { computed, onMounted, ref } from 'vue'; import type { SelectOption } from 'naive-ui'; import { useLoading } from '@sa/hooks'; import { fetchTenantList } from '@/service/api'; -import { fetchChangeTenant, fetchClearTenant } from '@/service/api/system/tenant'; +import { fetchClearTenant } from '@/service/api/system/tenant'; import { useAppStore } from '@/store/modules/app'; import { useTabStore } from '@/store/modules/tab'; -import { useAuth } from '@/hooks/business/auth'; +import { useAuthStore } from '@/store/modules/auth'; import { useRouterPush } from '@/hooks/common/router'; defineOptions({ name: 'TenantSelect' }); @@ -20,7 +20,7 @@ withDefaults(defineProps(), { }); const appStore = useAppStore(); -const { hasRole } = useAuth(); +const { userInfo } = useAuthStore(); const { clearTabs } = useTabStore(); const { toHome } = useRouterPush(); @@ -33,7 +33,7 @@ const tenantOption = ref([]); const { loading, startLoading, endLoading } = useLoading(); const showTenantSelect = computed(() => { - return hasRole('superadmin') && enabled.value; + return userInfo.user?.userId === 1 && enabled.value; }); /** @@ -57,7 +57,6 @@ async function handleChangeTenant(_tenantId: CommonType.IdType) { if (lastSelected.value === _tenantId) { return; } - await fetchChangeTenant(_tenantId); closeAndRefresh('切换租户成功', _tenantId); } @@ -82,7 +81,7 @@ async function handleFetchTenantList() { endLoading(); } onMounted(async () => { - if (!hasRole('superadmin')) { + if (userInfo.user?.userId !== 1) { return; } await handleFetchTenantList(); diff --git a/src/service/api/system/tenant.ts b/src/service/api/system/tenant.ts index 000073de..c3222e1d 100644 --- a/src/service/api/system/tenant.ts +++ b/src/service/api/system/tenant.ts @@ -47,6 +47,15 @@ export function fetchSyncTenantDict() { }); } +/** 同步租户套餐 */ +export function fetchSyncTenantPackage(params: Api.System.SyncTenantPackageParams) { + return request({ + url: '/system/tenant/syncTenantPackage', + method: 'get', + params + }); +} + /** 动态切换租户 */ export function fetchChangeTenant(tenantId: CommonType.IdType) { return request({ diff --git a/src/typings/api/system.api.d.ts b/src/typings/api/system.api.d.ts index 905264c1..5a5bc83e 100644 --- a/src/typings/api/system.api.d.ts +++ b/src/typings/api/system.api.d.ts @@ -558,6 +558,9 @@ declare namespace Api { } >; + /** sync tenant package params */ + type SyncTenantPackageParams = CommonType.RecordNullable>; + /** tenant list */ type TenantList = Api.Common.PaginatingQueryRecord; diff --git a/src/views/system/tenant/index.vue b/src/views/system/tenant/index.vue index 5a3957ba..17a38e54 100644 --- a/src/views/system/tenant/index.vue +++ b/src/views/system/tenant/index.vue @@ -1,7 +1,12 @@