diff --git a/src/resources/api/framework/users/user.js b/src/resources/api/framework/users/user.js index cf76580fab7c51e9be00a14ad2286b9b090af750..e9086aa79c5e985508ecd74f5571a50d1e58a97e 100644 --- a/src/resources/api/framework/users/user.js +++ b/src/resources/api/framework/users/user.js @@ -16,9 +16,6 @@ export default { getUser(data) { return axios.post('/api/rest/user/get', data); }, - getUserCopy(data) { - return axios.post('/api/rest/user/get', data); - }, //删除用户Api deleteUser(data) { return axios.post('/api/rest/user/delete', data); diff --git a/src/resources/init.js b/src/resources/init.js index d76bc840da8ea4b340a5b43b1bdbf9205d324652..990e6a1991badfebb670be76f764cc037536ffbd 100644 --- a/src/resources/init.js +++ b/src/resources/init.js @@ -84,6 +84,7 @@ export function initRouter(VueRouter, store) { * */ await gettingUserInfo; + await gettingModuleList; let auth = to.meta ? to.meta.authority : []; auth = typeof auth == 'string' ? (auth.trim() ? [auth.trim()] : []) : auth; //字符串转数组,主要是兼容string array两种情况的数据 if (!auth || !auth.length || utils.checkHasSomeitem(store.getters.userAuthList, auth)) { diff --git a/src/resources/store/modules/topMenu.js b/src/resources/store/modules/topMenu.js index f57cb55519f88a816facd77a625d497740a3d3f7..81a29ae130f6ef998966b7fc1d6afac8893491ac 100644 --- a/src/resources/store/modules/topMenu.js +++ b/src/resources/store/modules/topMenu.js @@ -1,4 +1,4 @@ -import menuApi from '@/resources/api/common'; +import commonApi from '@/resources/api/common'; const state = { moduleList: [], //所有的模块及其描述、菜单、默认页等 @@ -43,25 +43,27 @@ const actions = { const menuConfigList = getAllMenuTypeList(); let moduleList = []; let userAuthList = []; - state.gettingModuleList = menuApi.getModuleList(); + state.gettingModuleList = commonApi.getModuleList(); const res = await state.gettingModuleList; + const userRes = await commonApi.getUser(); let showModuleList = null; //可以显示的模块,如果不是单独命令行的就默认null全部需要展示,如果有单独配置的获取配置 if (process.env.VUE_APP_PAGE_LIST && JSON.parse(process.env.VUE_APP_PAGE_LIST)) { //如果是指定编译模块的,要过滤掉不在模块列表里的 showModuleList = JSON.parse(process.env.VUE_APP_PAGE_LIST); } - res && - res.Return && - res.Return.forEach(item => { - if (item && item.authList && item.authList.length > 0) { - userAuthList.push(...item.authList); // 拿到所有权限列表 + + userRes && + userRes.Return && + userRes.Return.userAuthList.forEach(item => { + if (item && item.auth) { + userAuthList.push(item.auth); // 拿到所有权限列表 } }); res && res.Return && res.Return.forEach(moduleGroup => { try { - let { group: moduleId, groupName: moduleName, authList = [], description, isDefault, defaultPage } = moduleGroup; + let { group: moduleId, groupName: moduleName, description, isDefault, defaultPage } = moduleGroup; if (!description || !description.trim()) { description = `${moduleName}平台`; } @@ -69,7 +71,7 @@ const actions = { const menuGroupList = sortMenuList(authorizedMenuList, moduleId, menuConfigList); if (routerConfig[moduleId]) { const hasAuthorizedDynamicMenu = routerConfig[moduleId].some(route => route.meta && route.meta.istitle && userAuthList.length > 0 && userAuthList.includes(route.meta.authority)); - if (((hasAuthorizedDynamicMenu || authorizedMenuList.length > 0) && !showModuleList) || (showModuleList && (hasAuthorizedDynamicMenu || authorizedMenuList.length > 0) && showModuleList.indexOf(moduleId) > -1 && authList.length > 0)) { + if (((hasAuthorizedDynamicMenu || authorizedMenuList.length > 0) && !showModuleList) || (showModuleList && (hasAuthorizedDynamicMenu || authorizedMenuList.length > 0) && showModuleList.indexOf(moduleId) > -1 && userAuthList.length > 0)) { //有权限菜单的模块才让显示 moduleList.push({ moduleId, moduleName, menuGroupList, description, isDefault, defaultPage }); } @@ -98,7 +100,7 @@ const actions = { const processModule = state.moduleList.find(item => item.moduleId === 'process'); if (!processModule) return; if (!forceUpdate && state.dynamicMenu.hasOwnProperty('process')) return; - const res = await menuApi.updateProcessMenu({ isAll: 0 }); + const res = await commonApi.updateProcessMenu({ isAll: 0 }); if (!res.Return || !res.Return.workcenterList || res.Return.workcenterList.length === 0) return; const processType = res.Return.workcenterList.map(type => ({ name: type.name, @@ -121,7 +123,7 @@ const actions = { const knowledgeModule = state.moduleList.find(item => item.moduleId === 'knowledge'); if (!knowledgeModule) return; if (!forceUpdate && state.dynamicMenu.hasOwnProperty('knowledge')) return; - const res = await menuApi.updateKnowledgeMenu(); + const res = await commonApi.updateKnowledgeMenu(); if (!res.Return || res.Return.length === 0) return; const knowledgeType = res.Return.map(type => ({ name: type.text, @@ -146,7 +148,7 @@ const actions = { if (!forceUpdate && state.dynamicMenu.hasOwnProperty('dashboard')) { return; } - const res = await menuApi.updateDashboardMenu({ limit: 6 }); + const res = await commonApi.updateDashboardMenu({ limit: 6 }); if (!res.Return.tbodyList || res.Return.tbodyList.length === 0) { return; } @@ -171,7 +173,7 @@ const actions = { const reportModule = state.moduleList.find(item => item.moduleId === 'report'); if (!reportModule) return; if (!forceUpdate && state.dynamicMenu.hasOwnProperty('report')) return; - const res = await menuApi.updateReportMenu({ pageSize: 6 }); + const res = await commonApi.updateReportMenu({ pageSize: 6 }); if (res.Return.tbodyList.length === 0) return; const reportInstanceList = res.Return.tbodyList.map(item => ({ name: item.name, @@ -194,7 +196,7 @@ const actions = { const cmdbModule = state.moduleList.find(item => item.moduleId === 'cmdb'); if (!cmdbModule) return; if (!forceUpdate && state.dynamicMenu.hasOwnProperty('cmdb')) return; - state.gettingCmdbMenu = menuApi.updateCmdbMenu(); + state.gettingCmdbMenu = commonApi.updateCmdbMenu(); const res = await state.gettingCmdbMenu; if (res.Return.length === 0) return; let newMenuGroup = []; @@ -227,7 +229,7 @@ const actions = { const inspectModule = state.moduleList.find(item => item.moduleId === 'inspect'); if (!inspectModule) return; if (!forceUpdate && state.dynamicMenu.hasOwnProperty('inspect')) return; - const res = await menuApi.updateInspectMenu(); + const res = await commonApi.updateInspectMenu(); let recentIssuesRouteList = []; // 最新问题路由列表 if (res.Return && res.Return.length > 0) { recentIssuesRouteList = res.Return.map(type => ({ @@ -359,13 +361,13 @@ function isAuthMenu(route, authList = []) { } else if ( typeof route.meta.authority == 'string' && authList.some(auth => { - return route.meta.authority === auth.name; + return route.meta.authority === auth; }) ) { return true; } else if (typeof route.meta.authority == 'object') { let isSame = authList.filter(a => { - let repeatItem = route.meta.authority.indexOf(a.name) > -1; + let repeatItem = route.meta.authority.indexOf(a) > -1; return repeatItem; }); if (isSame && isSame.length) { @@ -382,13 +384,13 @@ function hasAuthNoMenu(route, authList = []) { route.meta && typeof route.meta.authority == 'string' && authList.some(auth => { - return route.meta.authority === auth.name; + return route.meta.authority === auth; }) ) { return true; } else if (route.meta && typeof route.meta.authority == 'object') { let isSame = authList.filter(a => { - let repeatItem = route.meta.authority.indexOf(a.name) > -1; + let repeatItem = route.meta.authority.indexOf(a) > -1; return repeatItem; }); if (isSame && isSame.length) { diff --git a/src/views/components/topnav/topnav-menu.vue b/src/views/components/topnav/topnav-menu.vue index 6d61e42c4d3043ce0736331ff26c3e29d65d83e2..9385ae8c161669057980b0b774a7e88a95a6a05a 100644 --- a/src/views/components/topnav/topnav-menu.vue +++ b/src/views/components/topnav/topnav-menu.vue @@ -109,7 +109,7 @@ export default { }; }, initExtramenu() { - this.$api.framework.extramenu.getMenuList().then(res => { + this.$api.framework && this.$api.framework.extramenu.getMenuList().then(res => { // 修复用户权限加载快,$api没有挂载好,extramenu拿不到问题 if (res.Status === 'OK') { this.extramenu = res.Return || {}; } diff --git a/src/views/pages/index/navigation/navigation.vue b/src/views/pages/index/navigation/navigation.vue index 736eb2a6b4d0bf250ecb693013688270afdb3cd9..2cdf243eec1eaca6911511767a4bb48a88e81a81 100644 --- a/src/views/pages/index/navigation/navigation.vue +++ b/src/views/pages/index/navigation/navigation.vue @@ -35,7 +35,6 @@ export default { location.assign(HOME + '/' + this.defaultModuleId + '.html'); } }, - computed: { defaultModuleId() { return this.$store.getters.defaultModule.moduleId; diff --git a/src/views/pages/knowledge/knowledge.js b/src/views/pages/knowledge/knowledge.js index be16a3b76dacb1750d78642ac2acaf0d654ad82a..a0846cee58a3e9f6a60c566217f39d8c4cd8f999 100644 --- a/src/views/pages/knowledge/knowledge.js +++ b/src/views/pages/knowledge/knowledge.js @@ -26,9 +26,7 @@ Vue.prototype.$tsrouter = router; Vue.config.productionTip = false; Vue.prototype.$api = api; Vue.prototype.$localStore = new LocalStore('knowledge', router); - -// eslint-disable-next-line space-before-function-paren -router.beforeEach(async (to, from, next) => { +router.beforeEach((to, from, next) => { let title = to.meta.title ? to.meta.title : to.name || to.path; document.title = $t(title); let usertoken = Vue.prototype.$utils.getCookie('neatlogic_authorization'); diff --git a/src/views/pages/process/task/processdispatch/workorder/base-setting.vue b/src/views/pages/process/task/processdispatch/workorder/base-setting.vue index 18fb76b6e694642c7e39e64bfd232ccca9a2c414..812552854810fa05a01fa581a7bf797b2af5c6c9 100644 --- a/src/views/pages/process/task/processdispatch/workorder/base-setting.vue +++ b/src/views/pages/process/task/processdispatch/workorder/base-setting.vue @@ -198,7 +198,7 @@ export default { let data = { userUuid: userId }; - return this.$api.framework.user.getUserCopy(data).then(res => { + return this.$api.framework.user.getUser(data).then(res => { if (res.Status == 'OK') { this.userDetail = res.Return; }