diff --git a/jshERP-web/src/components/page/GlobalHeader.vue b/jshERP-web/src/components/page/GlobalHeader.vue index 6f9321f3..ae5164ba 100644 --- a/jshERP-web/src/components/page/GlobalHeader.vue +++ b/jshERP-web/src/components/page/GlobalHeader.vue @@ -45,9 +45,8 @@ import UserMenu from '../tools/UserMenu' import SMenu from '../menu/' import Logo from '../tools/Logo' - import { getCurrentSystemConfig, getUserBtnByCurrentUser } from '@/api/api' + import { getCurrentSystemConfig } from '@/api/api' import { mixin } from '@/utils/mixin.js' - import Vue from 'vue' export default { name: 'GlobalHeader', @@ -166,11 +165,6 @@ this.companyName = res.data.companyName } }) - getUserBtnByCurrentUser().then((res) => { - if(res.code === 200 && res.data){ - Vue.ls.set('winBtnStrList', res.data.userBtn, 7 * 24 * 60 * 60 * 1000) - } - }) }, //update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮----- } diff --git a/jshERP-web/src/permission.js b/jshERP-web/src/permission.js index c599210f..46a61399 100644 --- a/jshERP-web/src/permission.js +++ b/jshERP-web/src/permission.js @@ -3,7 +3,6 @@ import router from './router' import store from './store' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style -import notification from 'ant-design-vue/es/notification' import { USER_ID,INDEX_MAIN_PAGE_PATH } from '@/store/mutation-types' import { generateIndexRouter } from "@/utils/util" @@ -25,6 +24,10 @@ router.beforeEach((to, from, next) => { if (menuData === null || menuData === "" || menuData === undefined) { return; } + // 缓存用户的按钮权限 + store.dispatch('GetUserBtnList').then(res => { + Vue.ls.set('winBtnStrList', res.data.userBtn, 7 * 24 * 60 * 60 * 1000) + }) let constRoutes = []; constRoutes = generateIndexRouter(menuData); // 添加主界面路由 diff --git a/jshERP-web/src/store/modules/user.js b/jshERP-web/src/store/modules/user.js index 4c7f363e..81ca0e67 100644 --- a/jshERP-web/src/store/modules/user.js +++ b/jshERP-web/src/store/modules/user.js @@ -2,7 +2,7 @@ import Vue from 'vue' import { login, logout } from "@/api/login" import { ACCESS_TOKEN, USER_NAME,USER_INFO,UI_CACHE_DB_DICT_DATA,USER_ID,USER_LOGIN_NAME,CACHE_INCLUDED_ROUTES } from "@/store/mutation-types" import { welcome } from "@/utils/util" -import { queryPermissionsByUser } from '@/api/api' +import { queryPermissionsByUser, getUserBtnByCurrentUser } from '@/api/api' import { getAction } from '@/api/manage' const user = { @@ -104,6 +104,17 @@ const user = { }) }, + // 获取用户的按钮权限 + GetUserBtnList({ commit }) { + return new Promise((resolve, reject) => { + getUserBtnByCurrentUser().then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) + }, + // 登出 Logout({ commit, state }) { return new Promise((resolve) => {