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

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

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

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

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

Loading…
Cancel
Save