From 0659171f3b2a1e7b2d4f00a765da9e3037dad5a9 Mon Sep 17 00:00:00 2001 From: yaojn Date: Tue, 23 Jan 2024 18:57:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96=20=20=20?= =?UTF-8?q?=20-=20[=E5=85=B3=E8=81=94]#[1075165213982720]=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20http://192.168.0.96:8090/demo/rdm.html#/story-detail/9390509?= =?UTF-8?q?47543040/939050947543042/1075165213982720?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/api/framework/users/user.js | 3 -- src/resources/init.js | 1 + src/resources/store/modules/topMenu.js | 40 ++++++++++--------- src/views/components/topnav/topnav-menu.vue | 2 +- .../pages/index/navigation/navigation.vue | 1 - .../workorder/base-setting.vue | 2 +- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/resources/api/framework/users/user.js b/src/resources/api/framework/users/user.js index cf76580f..e9086aa7 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 d76bc840..990e6a19 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 f57cb555..81a29ae1 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 6d61e42c..9385ae8c 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 736eb2a6..2cdf243e 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/process/task/processdispatch/workorder/base-setting.vue b/src/views/pages/process/task/processdispatch/workorder/base-setting.vue index 18fb76b6..81255285 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; } -- Gitee From bc7962b2b298cb9ebad4ed5a683988f3e26e72d3 Mon Sep 17 00:00:00 2001 From: yaojn Date: Thu, 25 Jan 2024 10:16:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/init.js | 12 ++++----- src/resources/store/modules/topMenu.js | 10 +++---- .../pages/index/navigation/navigation.vue | 26 ++++++++++++++----- src/views/pages/knowledge/knowledge.js | 4 +-- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/resources/init.js b/src/resources/init.js index 990e6a19..780b67c2 100644 --- a/src/resources/init.js +++ b/src/resources/init.js @@ -51,16 +51,18 @@ export function initRouter(VueRouter, store) { base: '/' + TENANT + '/' + MODULEID + '.html', routes: MENULIST }); - const gettingUserInfo = store.dispatch('getUserInfo'); - const gettingModuleList = store.dispatch('getModuleList'); + // eslint-disable-next-line space-before-function-paren + (async function () { + await store.dispatch('getUserInfo'); + await store.dispatch('getModuleList'); + })(); // 返回的路由(包含所有模块) let routerFromPageConfig = sessionStorage.getItem('moduleFromPage') ? JSON.parse(sessionStorage.getItem('moduleFromPage')) : {}; let fromPageList = []; //历史页面记录 if (routerFromPageConfig && routerFromPageConfig[MODULEID]) { fromPageList = routerFromPageConfig[MODULEID]; } - // 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 = utils.getCookie('neatlogic_authorization'); @@ -83,8 +85,6 @@ export function initRouter(VueRouter, store) { * 直接从localstrage调出fromPageList,后续访问使用场景一的处理方式。 * */ - 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 81a29ae1..9958cc7e 100644 --- a/src/resources/store/modules/topMenu.js +++ b/src/resources/store/modules/topMenu.js @@ -1,4 +1,5 @@ import commonApi from '@/resources/api/common'; +import commonStore from '@/resources/store/index.js'; const state = { moduleList: [], //所有的模块及其描述、菜单、默认页等 @@ -45,16 +46,15 @@ const actions = { let userAuthList = []; state.gettingModuleList = commonApi.getModuleList(); const res = await state.gettingModuleList; - const userRes = await commonApi.getUser(); + const userInfo = commonStore.state.userInfo; 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); } - - userRes && - userRes.Return && - userRes.Return.userAuthList.forEach(item => { + userInfo && + userInfo.userAuthList && + userInfo.userAuthList.forEach(item => { if (item && item.auth) { userAuthList.push(item.auth); // 拿到所有权限列表 } diff --git a/src/views/pages/index/navigation/navigation.vue b/src/views/pages/index/navigation/navigation.vue index 2cdf243e..0ab80906 100644 --- a/src/views/pages/index/navigation/navigation.vue +++ b/src/views/pages/index/navigation/navigation.vue @@ -27,17 +27,29 @@ export default { home: HOME }; }, - async created() { - await this.$store.state.topMenu.gettingModuleList; - if (this.defaultModuleId === 'index') { - this.moduleList = this.$store.state.topMenu.moduleList; - } else { - location.assign(HOME + '/' + this.defaultModuleId + '.html'); - } + created() {}, + mounted() { + }, computed: { defaultModuleId() { return this.$store.getters.defaultModule.moduleId; + }, + topMenuModuleList() { + return this.$store.state.topMenu.moduleList; + } + }, + watch: { + topMenuModuleList: { + handler(moduleList) { + if (this.defaultModuleId === 'index') { + this.moduleList = moduleList; + } else { + location.assign(HOME + '/' + this.defaultModuleId + '.html'); + } + }, + deep: true, + immediate: true } } }; diff --git a/src/views/pages/knowledge/knowledge.js b/src/views/pages/knowledge/knowledge.js index be16a3b7..a0846cee 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'); -- Gitee From 6fe7473b73b4f8487194d5d91ee2077cd1406921 Mon Sep 17 00:00:00 2001 From: yaojn Date: Thu, 25 Jan 2024 10:28:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/init.js | 12 ++++----- src/resources/store/modules/topMenu.js | 10 +++---- .../pages/index/navigation/navigation.vue | 26 +++++-------------- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/resources/init.js b/src/resources/init.js index 780b67c2..990e6a19 100644 --- a/src/resources/init.js +++ b/src/resources/init.js @@ -51,18 +51,16 @@ export function initRouter(VueRouter, store) { base: '/' + TENANT + '/' + MODULEID + '.html', routes: MENULIST }); - // eslint-disable-next-line space-before-function-paren - (async function () { - await store.dispatch('getUserInfo'); - await store.dispatch('getModuleList'); - })(); + const gettingUserInfo = store.dispatch('getUserInfo'); + const gettingModuleList = store.dispatch('getModuleList'); // 返回的路由(包含所有模块) let routerFromPageConfig = sessionStorage.getItem('moduleFromPage') ? JSON.parse(sessionStorage.getItem('moduleFromPage')) : {}; let fromPageList = []; //历史页面记录 if (routerFromPageConfig && routerFromPageConfig[MODULEID]) { fromPageList = routerFromPageConfig[MODULEID]; } - router.beforeEach((to, from, next) => { + // eslint-disable-next-line space-before-function-paren + router.beforeEach(async (to, from, next) => { let title = to.meta.title ? to.meta.title : to.name || to.path; document.title = $t(title); let usertoken = utils.getCookie('neatlogic_authorization'); @@ -85,6 +83,8 @@ export function initRouter(VueRouter, store) { * 直接从localstrage调出fromPageList,后续访问使用场景一的处理方式。 * */ + 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 9958cc7e..81a29ae1 100644 --- a/src/resources/store/modules/topMenu.js +++ b/src/resources/store/modules/topMenu.js @@ -1,5 +1,4 @@ import commonApi from '@/resources/api/common'; -import commonStore from '@/resources/store/index.js'; const state = { moduleList: [], //所有的模块及其描述、菜单、默认页等 @@ -46,15 +45,16 @@ const actions = { let userAuthList = []; state.gettingModuleList = commonApi.getModuleList(); const res = await state.gettingModuleList; - const userInfo = commonStore.state.userInfo; + 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); } - userInfo && - userInfo.userAuthList && - userInfo.userAuthList.forEach(item => { + + userRes && + userRes.Return && + userRes.Return.userAuthList.forEach(item => { if (item && item.auth) { userAuthList.push(item.auth); // 拿到所有权限列表 } diff --git a/src/views/pages/index/navigation/navigation.vue b/src/views/pages/index/navigation/navigation.vue index 0ab80906..2cdf243e 100644 --- a/src/views/pages/index/navigation/navigation.vue +++ b/src/views/pages/index/navigation/navigation.vue @@ -27,29 +27,17 @@ export default { home: HOME }; }, - created() {}, - mounted() { - + async created() { + await this.$store.state.topMenu.gettingModuleList; + if (this.defaultModuleId === 'index') { + this.moduleList = this.$store.state.topMenu.moduleList; + } else { + location.assign(HOME + '/' + this.defaultModuleId + '.html'); + } }, computed: { defaultModuleId() { return this.$store.getters.defaultModule.moduleId; - }, - topMenuModuleList() { - return this.$store.state.topMenu.moduleList; - } - }, - watch: { - topMenuModuleList: { - handler(moduleList) { - if (this.defaultModuleId === 'index') { - this.moduleList = moduleList; - } else { - location.assign(HOME + '/' + this.defaultModuleId + '.html'); - } - }, - deep: true, - immediate: true } } }; -- Gitee