diff --git a/f/web-kboss/src/router/index.js b/f/web-kboss/src/router/index.js index 1dca6fa..e2f3298 100644 --- a/f/web-kboss/src/router/index.js +++ b/f/web-kboss/src/router/index.js @@ -256,6 +256,19 @@ export const constantRoutes = [ component: () => import('@/views/product/charge/index.vue'), hidden: true }, + { + path: '/product/productHome', + component: Layout, + hidden: true, + children: [ + { + path: '', + name: 'ProductConsoleHomeStatic', + component: () => import('@/views/product/productHome/productIndex/index.vue'), + meta: { title: '产品', fullPath: '/product/productHome', noCache: true } + } + ] + }, { path: '/kyyForm', name: 'kyyForm', @@ -653,6 +666,17 @@ export const asyncRoutes = [ noCache: true } }, + { + path: "productHome", + component: () => import('@/views/product/productHome/productIndex/index.vue'), + name: 'ProductConsoleHome', + hidden: true, + meta: { + title: "产品", + fullPath: "/product/productHome", + noCache: true + } + }, ] }, // 令牌管理 - 一级菜单(所有登录用户都能看到) @@ -1250,30 +1274,30 @@ export const asyncRoutes = [ // 容器实例 - 客户角色可见 - { - path: "/containerInstance", - component: Layout, - redirect: "/containerInstance/index", - meta: { - title: "容器实例", - icon: "el-icon-box", - noCache: true, - fullPath: "/containerInstance", - roles: ["客户"] - }, - children: [ - { - path: "index", - component: () => import("@/views/customer/containerInstance"), - name: "ContainerInstance", - meta: { - title: "容器实例", - fullPath: "/containerInstance/index", - roles: ["客户"] - } - } - ] - }, + // { + // path: "/containerInstance", + // component: Layout, + // redirect: "/containerInstance/index", + // meta: { + // title: "容器实例", + // icon: "el-icon-box", + // noCache: true, + // fullPath: "/containerInstance", + // roles: ["客户"] + // }, + // children: [ + // { + // path: "index", + // component: () => import("@/views/customer/containerInstance"), + // name: "ContainerInstance", + // meta: { + // title: "容器实例", + // fullPath: "/containerInstance/index", + // roles: ["客户"] + // } + // } + // ] + // }, // 退订管理 - 变为一级菜单(包含子菜单) diff --git a/f/web-kboss/src/store/modules/permission.js b/f/web-kboss/src/store/modules/permission.js index 08d5880..9b8272d 100644 --- a/f/web-kboss/src/store/modules/permission.js +++ b/f/web-kboss/src/store/modules/permission.js @@ -370,7 +370,8 @@ function getAdministratorRoutes(routes, deviceType = 'pc') { } function addAdministratorRoutes(accessedRoutes, routes, userRoles = [], deviceType = 'pc') { - if (!userRoles.includes(ADMINISTRATOR_ROLE)) { + const orgType = parseInt(sessionStorage.getItem('org_type') || sessionStorage.getItem('orgType') || '0') + if (!userRoles.includes(ADMINISTRATOR_ROLE) || isCustomer(userRoles) || orgType === 2 || orgType === 3) { return accessedRoutes; } @@ -522,7 +523,7 @@ const actions = { console.log("用户类型:", userType, "orgType:", orgType, "设备类型:", deviceType); console.log("ACTION generateRoutes - auths:", auths); - if (!isSuperAdmin && userRoles.includes(ADMINISTRATOR_ROLE)) { + if (!isSuperAdmin && userRoles.includes(ADMINISTRATOR_ROLE) && !isCustomer(userRoles) && orgType !== 2 && orgType !== 3) { const administratorRoutes = getAdministratorRoutes(asyncRoutes, deviceType); commit("SET_ROUTES", administratorRoutes); resolve(administratorRoutes); diff --git a/f/web-kboss/src/views/LoginDialog/LoginDialog.vue b/f/web-kboss/src/views/LoginDialog/LoginDialog.vue index 298bfc8..8404426 100644 --- a/f/web-kboss/src/views/LoginDialog/LoginDialog.vue +++ b/f/web-kboss/src/views/LoginDialog/LoginDialog.vue @@ -381,24 +381,49 @@ export default { } }) }, + goAfterLogin(path) { + if (this.$route.path === path) { + this.$router.replace({ + path, + query: { + ...this.$route.query, + _route_refresh: Date.now() + } + }).catch(() => {}) + return + } + this.$router.push(path).catch(() => {}) + }, redirectAfterLogin(res) { + if (res.admin === 1) { + this.goAfterLogin('/') + return + } + if (String(res.org_type) === '2' || String(res.org_type) === '3') { + sessionStorage.removeItem('loginRedirectPath') + this.goAfterLogin(getHomePath()) + return + } + if (res.roles && res.roles.includes('客户')) { + sessionStorage.removeItem('loginRedirectPath') + this.goAfterLogin(getHomePath()) + return + } if (res.roles && res.roles.includes('管理员')) { sessionStorage.removeItem('loginRedirectPath') - this.$router.push('/superAdministrator/roleManagement').catch(() => {}) + this.goAfterLogin('/superAdministrator/roleManagement') return } const redirectPath = sessionStorage.getItem('loginRedirectPath') if (redirectPath && redirectPath.startsWith('/') && !redirectPath.includes('/login')) { sessionStorage.removeItem('loginRedirectPath') - this.$router.push(redirectPath).catch(() => {}) + this.goAfterLogin(redirectPath) return } - if (res.admin === 1) this.$router.push('/').catch(() => {}) - else if (String(res.org_type) === '2' || String(res.org_type) === '3') this.$router.push(getHomePath()).catch(() => {}) - else if (res.roles && res.roles.includes('运营')) this.$router.push('/operation/supplierManagement').catch(() => {}) - else if (res.roles && res.roles.includes('销售')) this.$router.push('/sales/distributorManagement').catch(() => {}) - else if (res.roles && res.roles.includes('运维')) this.$router.push('/operationAndMaintenance/workOrderProcessing').catch(() => {}) - else this.$router.push('/').catch(() => {}) + if (res.roles && res.roles.includes('运营')) this.goAfterLogin('/operation/supplierManagement') + else if (res.roles && res.roles.includes('销售')) this.goAfterLogin('/sales/distributorManagement') + else if (res.roles && res.roles.includes('运维')) this.goAfterLogin('/operationAndMaintenance/workOrderProcessing') + else this.goAfterLogin('/') }, handleRegister() { if (!this.registerForm.agree) { diff --git a/f/web-kboss/src/views/homePage/components/topBox/index.vue b/f/web-kboss/src/views/homePage/components/topBox/index.vue index 24c8b71..bf94974 100644 --- a/f/web-kboss/src/views/homePage/components/topBox/index.vue +++ b/f/web-kboss/src/views/homePage/components/topBox/index.vue @@ -275,6 +275,7 @@ export default Vue.extend({ activeLocale: 'zh-CN', isProductPanelVisible: false, loginDialogVisible: false, + consoleRoutesEnsured: false, // 登录信息 isShowKbossCharge: false, @@ -296,7 +297,7 @@ export default Vue.extend({ } }, computed: { - ...mapGetters(['sidebar', 'avatar', 'device']), + ...mapGetters(['sidebar', 'avatar', 'device', 'permission_routes']), ...mapState({ mybalance: state => state.user.mybalance, logoutUrl: state => state.login.logoutUrl, @@ -313,7 +314,7 @@ export default Vue.extend({ return orgType !== '2' && orgType !== '3' && userId === null }, isNcmatchDomain() { - return window.location.hostname.includes('ncmatch.cn') + return window.location.hostname.includes('ncmatch.cn') || window.location.hostname.includes('zgcopc.opencomputing.cn') }, isActiveHome() { return this.isNcmatchDomain @@ -519,6 +520,7 @@ export default Vue.extend({ this.loginDialogVisible = false this.nick_name = sessionStorage.getItem('username') || '' this.userId = sessionStorage.getItem('userId') + this.consoleRoutesEnsured = false }, goLogin() { this.openLoginDialog() @@ -537,9 +539,35 @@ export default Vue.extend({ handleUnreadCountUpdate(count) { this.messageCount = count }, - goB() { + async ensureConsoleRoutes() { + if (this.consoleRoutesEnsured) return + const authsText = sessionStorage.getItem('auths') || '[]' + let auths = [] + try { + auths = JSON.parse(authsText) + } catch (error) { + auths = [] + } + const rolesText = sessionStorage.getItem('roles') || '[]' + let roles = [] + try { + roles = JSON.parse(rolesText) + } catch (error) { + roles = [] + } + const accessRoutes = await this.$store.dispatch('permission/generateRoutes', { + user: sessionStorage.getItem('username') || '', + auths, + orgType: sessionStorage.getItem('org_type'), + roles + }) + this.$router.addRoutes(accessRoutes) + this.consoleRoutesEnsured = true + }, + async goB() { + await this.ensureConsoleRoutes() const role = sessionStorage.getItem('jueseNew') || '' - if (role.includes('客户')) this.$router.push('/product/productHome') + if (role.includes('客户')) this.$router.push('/product/productHome').catch(() => this.$router.replace('/product/productHome')) else if (role.includes('运营')) this.$router.push('/operation/supplierManagement') else if (role.includes('运维')) this.$router.push('/operationAndMaintenance/workOrderProcessing') else if (role.includes('销售')) this.$router.push('/sales/distributorManagement') diff --git a/f/web-kboss/src/views/product/allProduct/index.vue b/f/web-kboss/src/views/product/allProduct/index.vue index 375cd6d..b56befc 100644 --- a/f/web-kboss/src/views/product/allProduct/index.vue +++ b/f/web-kboss/src/views/product/allProduct/index.vue @@ -1,6 +1,6 @@