master
xy 3 years ago
parent 2d399e6faf
commit 8b168b0c5c

@ -6,12 +6,8 @@
</div>
<ul>
<li :class="{'li-active':active === 0}" @click="active = 0,$router.push('/worker')">工作台</li>
<li :class="{'li-active':active === 1}" @click="active = 1">内控管理</li>
<li :class="{'li-active':active === 2}" @click="active = 2,$router.push('/dashboard')">预算绩效管理</li>
<li :class="{'li-active':active === 3}" @click="active = 3,$router.push('/bookmanage')">图书管理</li>
<li :class="{'li-active':active === 4}" @click="active = 4">安全生产</li>
<li :class="{'li-active':active === 5}" @click="active = 5">系统设置</li>
<li v-for="item in $store.state.permission.rootMenu" :class="{'li-active':new RegExp(`^${item.path}`).test($route.path) && $route.path !== '/contract/system/menu'}" @click="menuClick(item)">{{ item.name }}</li>
<li :class="{'li-active':$route.path === '/contract/system/menu'}" @click="active = 5,$router.push('/contract/system/menu')">系统设置</li>
</ul>
<div class="top-head-bar__user">
@ -41,7 +37,7 @@
</el-scrollbar>
</template>
<template v-else-if="$route.path === '/bookmanage'">
<iframe style="width: 100%;height: 100%;padding-top: 50px;" src="http://hjjc-book-service-test.ali251.langye.net/"></iframe>
<iframe ref="bookIframe" style="width: 100%;height: 100%;padding-top: 50px;" src="http://hjjc-book-service-test.ali251.langye.net/">你的浏览器不支持该iframe</iframe>
</template>
<template v-else>
<sidebar class="sidebar-container" />
@ -103,10 +99,18 @@ import worker from "./components/worker"
this.$store.dispatch('app/closeSideBar', {
withoutAnimation: false
})
},
menuClick(item){
this.$router.push(item.path)
console.log(this.$route.path)
}
},
mounted() {
}
},
}
</script>

@ -45,9 +45,9 @@ export const constantRoutes = [{
{
path: '/',
component: Layout,
redirect: '/dashboard',
redirect: '/worker',
children: [{
path: 'dashboard',
path: 'contract/dashboard',
name: '系统首页',
component: () => import('@/views/dashboard/index'),
meta: {
@ -63,7 +63,7 @@ export const constantRoutes = [{
* the routes that need to be dynamically loaded based on user roles
*/
export const asyncRoutes = [
// 404 page must be placed at the end !!!
{
path: '*',

@ -53,6 +53,7 @@ export function filterAsyncRoutes(routes, roles) {
const state = {
routes: [],
rootMenu:[],
addRoutes: []
}
@ -66,7 +67,7 @@ export function generaMenu(routes, data) {
routes.push({
path: '/',
component: Layout,
redirect: '/dashboard',
redirect: '/worker',
children: [{
path: 'dashboard',
name: '系统首页',
@ -84,16 +85,16 @@ export function generaMenu(routes, data) {
}
const menu = {
path: (path === '#' ? item.id + '_key' : path),
redirect: (item.children.length > 0 ? "noRedirect" : ""),
redirect: (item.children?.length > 0 ? "noRedirect" : ""),
component: item.url === '#' ? Layout : loadView(item.url),
// hidden: true,
hidden: item.hidden ?? false,
children: [],
name: 'menu_' + item.id,
meta: {
title: item.name,
id: item.id,
roles: ['admin'],
icon: item.icon
}
}
@ -109,6 +110,9 @@ const mutations = {
SET_ROUTES: (state, routes) => {
state.addRoutes = routes
state.routes = constantRoutes.concat(routes)
},
SET_ROOTMENU:(state,menu) => {
state.rootMenu = menu
}
}
@ -124,11 +128,19 @@ const actions = {
getAuthMenu(state.token).then(response => {
let data = response
//console.log(JSON.stringify(data))
commit('SET_ROOTMENU',data)
Object.assign(loadMenuData, data)
let routes = data.filter(item => item.path === '/contract')[0]?.children
let root = data.map(item => {
delete item.children
item.hidden = true
return item
})
Object.assign(loadMenuData, [...routes,...root])
asyncRoutes.length=0;
generaMenu(asyncRoutes, loadMenuData)
console.log(asyncRoutes)
let accessedRoutes
if (roles.includes('admin')) {
// alert(JSON.stringify(asyncRoutes))

@ -1,6 +1,6 @@
import Cookies from 'js-cookie'
const TokenKey = 'HeTongGuanli_NEW_token'
const TokenKey = 'HeTongGuanli_hjjc_token'
export function getToken() {
//return Cookies.get(TokenKey)
@ -21,4 +21,4 @@ export function removeToken() {
sessionStorage.clear();
return Cookies.remove(TokenKey)
}
}

@ -69,7 +69,8 @@ service.interceptors.response.use(
Message({
message: res.errmsg || 'Error',
type: 'error',
duration: 5 * 1000
duration: 5 * 1000,
offset:50
})
// 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
@ -99,7 +100,8 @@ service.interceptors.response.use(
Message({
message: error.message,
type: 'error',
duration: 5 * 1000
duration: 5 * 1000,
offset: 50
})
return Promise.reject(error)
}

Loading…
Cancel
Save