This commit is contained in:
hrx 2026-07-23 10:38:21 +08:00
parent 9009147d40
commit 57349ceeeb
4 changed files with 91 additions and 13 deletions

View File

@ -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
}
},
]
},
// 令牌管理 - 一级菜单(所有登录用户都能看到)

View File

@ -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);

View File

@ -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) {

View File

@ -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,
@ -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')