|
|
@@ -1,6 +1,6 @@
|
|
|
<!-- 切换租户 -->
|
|
|
<template>
|
|
|
- <div class="switchTenantLable-wrapper" v-if="optionsShown">
|
|
|
+ <div class="switchTenantLable-wrapper">
|
|
|
<el-tree-select
|
|
|
:model-value="currentTenant"
|
|
|
:data="options"
|
|
|
@@ -14,11 +14,10 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
- import { ref, computed, onMounted } from 'vue';
|
|
|
+ import { ref, onMounted } from 'vue';
|
|
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
|
|
- import { useUserStore } from '@/store/modules/user';
|
|
|
import { queryListTenant } from '@/api/tenant';
|
|
|
- import { SYS_TENANT_ID, useTargetTenantIdSetting } from '@/utils/useTargetTenantIdSetting';
|
|
|
+ import { useTargetTenantIdSetting } from '@/utils/useTargetTenantIdSetting';
|
|
|
import { replaceParams } from '@/utils/helper/treeHelper';
|
|
|
import router from '@/router';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
@@ -29,7 +28,6 @@
|
|
|
children?: TenantOption[];
|
|
|
}
|
|
|
|
|
|
- const userStore = useUserStore();
|
|
|
const { setValue, getValue } = useTargetTenantIdSetting();
|
|
|
|
|
|
const currentTenant = ref();
|
|
|
@@ -37,10 +35,6 @@
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
- const optionsShown = computed(() => {
|
|
|
- return userStore.info.tenantId === SYS_TENANT_ID;
|
|
|
- });
|
|
|
-
|
|
|
onMounted(() => {
|
|
|
const routeTenantId = route.query.targetTenantId as string;
|
|
|
if (routeTenantId && routeTenantId !== 'undefined') {
|
|
|
@@ -54,7 +48,7 @@
|
|
|
if (!res) return;
|
|
|
options.value = replaceParams(res || [], 'tenantName', 'id');
|
|
|
/** 如果当前租户没选中的话,默认选中第一个 */
|
|
|
- if (!currentTenant.value && res.length > 1) {
|
|
|
+ if (currentTenant.value === undefined && res.length > 1) {
|
|
|
currentTenant.value = res[0].id;
|
|
|
}
|
|
|
});
|