|
@@ -19,11 +19,44 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</div>
|
|
|
- <div class="ml-auto">
|
|
|
+ <div class="mr-4 ml-auto">
|
|
|
<el-button type="primary" @click="state.drawer = true"
|
|
|
>临时字典</el-button
|
|
|
>
|
|
|
</div>
|
|
|
+ <el-dropdown :disabled="DictionaryStore.tenants.list.length < 2">
|
|
|
+ <div class="__hover flex items-center gap-2 text-[#303133]">
|
|
|
+ {{ AppStore.tenantInfo?.name }}
|
|
|
+ <SvgIcon name="czr_arrow" :rotate="90" size="10" color="#303133" />
|
|
|
+ </div>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <template
|
|
|
+ v-for="item in DictionaryStore.tenants.list.filter(
|
|
|
+ (v) => v.id !== AppStore.tenantInfo.id,
|
|
|
+ )"
|
|
|
+ >
|
|
|
+ <el-dropdown-item @click="onChangeTenant(item)">{{
|
|
|
+ item.name
|
|
|
+ }}</el-dropdown-item>
|
|
|
+ </template>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+ <el-dropdown>
|
|
|
+ <div
|
|
|
+ class="__hover mr-4 ml-4 flex items-center gap-2 text-sm text-[#303133]"
|
|
|
+ >
|
|
|
+ <img src="@/assets/images/avatar-default.png" class="size-8" />
|
|
|
+ {{ AppStore.userInfo?.name }}
|
|
|
+ <SvgIcon name="czr_arrow" :rotate="90" size="10" color="#303133" />
|
|
|
+ </div>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
<el-drawer v-model="state.drawer" title="临时字典管理">
|
|
|
<div class="h-full w-full overflow-y-auto">
|
|
|
<el-collapse v-model="state.activeNames">
|
|
@@ -60,11 +93,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { computed, getCurrentInstance, reactive } from 'vue'
|
|
|
-import { useMenuStore } from '@/stores'
|
|
|
+import { computed, getCurrentInstance, onMounted, reactive } from 'vue'
|
|
|
+import {
|
|
|
+ useAppStore,
|
|
|
+ useDialogStore,
|
|
|
+ useDictionaryStore,
|
|
|
+ useMenuStore,
|
|
|
+} from '@/stores'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
|
-const MenuStore = useMenuStore()
|
|
|
+const AppStore = useAppStore()
|
|
|
+const DictionaryStore = useDictionaryStore()
|
|
|
+const DialogStore = useDialogStore()
|
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
|
const { proxy } = getCurrentInstance()
|
|
@@ -81,6 +121,7 @@ const menusCpt: any = computed(
|
|
|
import { sysDict } from '@/api/modules/global/dictionary'
|
|
|
import { copy } from '@/utils/czr-util'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
+import { loginChangeTenant, loginLogout } from '@/api/modules/global/login'
|
|
|
sysDict().then(({ data }: any) => {
|
|
|
data.forEach((v) => {
|
|
|
const d = state.dictMap.get(v.dictType)
|
|
@@ -103,6 +144,37 @@ const copyDict = (label, value) => {
|
|
|
console.log(e)
|
|
|
}
|
|
|
}
|
|
|
+const onChangeTenant = (row) => {
|
|
|
+ DialogStore.confirm({
|
|
|
+ content: `请确认是否切换到租户 ${row.name} ?`,
|
|
|
+ onSubmit: () => {
|
|
|
+ loginChangeTenant(row.id)
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ localStorage.setItem((import.meta as any).env.VITE_TOKEN, data)
|
|
|
+ window.location.reload()
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ .finally(() => {})
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+const logout = () => {
|
|
|
+ DialogStore.confirm({
|
|
|
+ content: `请确认是否退出登录?`,
|
|
|
+ onSubmit: () => {
|
|
|
+ loginLogout()
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ localStorage.clear()
|
|
|
+ window.location.reload()
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ .finally(() => {})
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ DictionaryStore.initTenants()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|