fix: 修复公司名称展示及菜单权限限制

pull/197/head
刘释隆 1 year ago
parent 08973c8225
commit 0816abc9c7

@ -74,7 +74,7 @@ function logOut() {
const currentCompanyName = computed(() => {
const deptlist = useInfo.deptlist
const currentId = userStore.getTenantId
const current = deptlist.find(item => item.id === currentId)
const current = deptlist.find(item => item.deptno === currentId)
return current?.departname || 'name'
})

@ -1,13 +1,19 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { websiteConfig } from '@/config/website.config'
import { storage } from '@/utils/Storage'
import { CURRENT_USER } from '@/store/mutation-types'
defineOptions({ name: 'Index' })
const router = useRouter()
function clickHandler() {
router.push({ path: '/home' })
const userInfo = storage.get(CURRENT_USER)
if (userInfo && userInfo.frontmenuTList) {
if (userInfo.frontmenuTList.find(item => item.resUrl == '/home'))
router.push({ path: '/home' })
}
}
</script>
@ -18,23 +24,23 @@ function clickHandler() {
</template>
<style lang="less" scoped>
.logo {
display: flex;
align-items: center;
justify-content: center;
height: 64px;
line-height: 64px;
overflow: hidden;
white-space: nowrap;
.logo {
display: flex;
align-items: center;
justify-content: center;
height: 64px;
line-height: 64px;
overflow: hidden;
white-space: nowrap;
img {
width: auto;
height: 32px;
cursor: pointer;
}
img {
width: auto;
height: 32px;
cursor: pointer;
}
.title {
margin: 0;
}
.title {
margin: 0;
}
}
</style>

@ -1,57 +1,57 @@
<script lang="ts">
import { computed, defineComponent, onMounted, ref, unref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { IconGroup } from "../IconGroup";
import { useAsyncRouteStore } from "@/store/modules/asyncRoute";
import { generatorMenu } from "@/utils";
import { storage } from "@/utils/Storage";
import { CURRENT_USER } from "@/store/mutation-types";
import { computed, defineComponent, onMounted, ref, unref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { IconGroup } from '../IconGroup'
import { useAsyncRouteStore } from '@/store/modules/asyncRoute'
import { generatorMenu } from '@/utils'
import { storage } from '@/utils/Storage'
import { CURRENT_USER } from '@/store/mutation-types'
export default defineComponent({
name: "AppMenu",
name: 'AppMenu',
components: { IconGroup },
emits: ["clickMenuItem"],
emits: ['clickMenuItem'],
setup(props, { emit }) {
//
const currentRoute = useRoute();
const router = useRouter();
const asyncRouteStore = useAsyncRouteStore();
const menus = ref<any[]>([]);
const selectedSvg = ref<string>(currentRoute.meta.svgname as string);
const currentRoute = useRoute()
const router = useRouter()
const asyncRouteStore = useAsyncRouteStore()
const menus = ref<any[]>([])
const selectedSvg = ref<string>(currentRoute.meta.svgname as string)
const getSelectedSvg = computed(() => {
return unref(selectedSvg);
});
return unref(selectedSvg)
})
//
watch(
() => currentRoute.fullPath,
() => {
updateMenu();
}
);
updateMenu()
},
)
function updateSelectedKeys() {
const svgname: string = (currentRoute.meta?.svgname as string) || "";
selectedSvg.value = svgname;
const svgname: string = (currentRoute.meta?.svgname as string) || ''
selectedSvg.value = svgname
}
function updateMenu() {
menus.value = generatorMenu(asyncRouteStore.getMenus);
const userInfo = storage.get(CURRENT_USER);
menus.value = generatorMenu(asyncRouteStore.getMenus)
const userInfo = storage.get(CURRENT_USER)
if (userInfo && userInfo.frontmenuTList) {
menus.value = userInfo.frontmenuTList.map((item) => {
let v = {
const v = {
component: () =>
item.resUrl == "/task"
? import("@/views/task/index.vue")
: item.resUrl == "/home"
? import("@/views/home/index.vue")
: item.resUrl == "/worksheet"
? import("@/views/worksheet/index.vue")
: item.resUrl == "/final"
? import("@/views/final/index.vue")
: "",
item.resUrl == '/task'
? import('@/views/task/index.vue')
: item.resUrl == '/home'
? import('@/views/home/index.vue')
: item.resUrl == '/worksheet'
? import('@/views/worksheet/index.vue')
: item.resUrl == '/final'
? import('@/views/final/index.vue')
: '',
icon: undefined,
key: item.resKey,
label: item.description,
@ -62,38 +62,36 @@ export default defineComponent({
path: item.resUrl,
name: item.resKey,
svgname: item.icon,
svgsize: item.resUrl == "/home" ? 60 : 22,
svgsize: item.resUrl == '/home' ? 60 : 22,
title: item.description,
};
return v;
});
}
return v
})
}
console.log(userInfo.frontmenuTList,'frontmenuTList');
console.log(menus.value,'menus')
updateSelectedKeys();
updateSelectedKeys()
}
//
function clickMenuItem(key: string) {
console.log('clickMenuItem',key)
if (/http(s)?:/.test(key)) window.open(key);
else router.push({ name: key });
if (/http(s)?:/.test(key))
window.open(key)
else router.push({ name: key })
emit("clickMenuItem" as any, key);
emit('clickMenuItem' as any, key)
}
onMounted(() => {
updateMenu();
});
updateMenu()
})
return {
menus,
selectedSvg,
getSelectedSvg,
clickMenuItem,
};
}
},
});
})
</script>
<template>

Loading…
Cancel
Save