master
xy 3 years ago
parent 2d399e6faf
commit 8b168b0c5c

@ -6,12 +6,8 @@
</div> </div>
<ul> <ul>
<li :class="{'li-active':active === 0}" @click="active = 0,$router.push('/worker')">工作台</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':active === 1}" @click="active = 1">内控管理</li> <li :class="{'li-active':$route.path === '/contract/system/menu'}" @click="active = 5,$router.push('/contract/system/menu')">系统设置</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>
</ul> </ul>
<div class="top-head-bar__user"> <div class="top-head-bar__user">
@ -41,7 +37,7 @@
</el-scrollbar> </el-scrollbar>
</template> </template>
<template v-else-if="$route.path === '/bookmanage'"> <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>
<template v-else> <template v-else>
<sidebar class="sidebar-container" /> <sidebar class="sidebar-container" />
@ -103,10 +99,18 @@ import worker from "./components/worker"
this.$store.dispatch('app/closeSideBar', { this.$store.dispatch('app/closeSideBar', {
withoutAnimation: false withoutAnimation: false
}) })
},
menuClick(item){
this.$router.push(item.path)
console.log(this.$route.path)
} }
}, },
mounted() { mounted() {
}
},
} }
</script> </script>

@ -45,9 +45,9 @@ export const constantRoutes = [{
{ {
path: '/', path: '/',
component: Layout, component: Layout,
redirect: '/dashboard', redirect: '/worker',
children: [{ children: [{
path: 'dashboard', path: 'contract/dashboard',
name: '系统首页', name: '系统首页',
component: () => import('@/views/dashboard/index'), component: () => import('@/views/dashboard/index'),
meta: { meta: {

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

@ -1,6 +1,6 @@
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
const TokenKey = 'HeTongGuanli_NEW_token' const TokenKey = 'HeTongGuanli_hjjc_token'
export function getToken() { export function getToken() {
//return Cookies.get(TokenKey) //return Cookies.get(TokenKey)

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

Loading…
Cancel
Save