mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 11:24:17 +00:00
@@ -97,10 +97,10 @@ export default {
|
||||
getDefaultFormSetting() {
|
||||
const vm = this
|
||||
return {
|
||||
submitMethod: () => 'post',
|
||||
submitMethod: () => 'patch',
|
||||
cleanFormValue: function(value) {
|
||||
const filterValue = {}
|
||||
Object.keys(value).filter((key) => vm.checkedFields.includes(key)).forEach((key) => {
|
||||
Object.keys(value).filter((key) => vm.checkedFields?.includes(key)).forEach((key) => {
|
||||
filterValue[key] = value[key]
|
||||
})
|
||||
const formValue = []
|
||||
|
||||
@@ -101,16 +101,19 @@ export default {
|
||||
return currentOrgId
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
changeOrg(orgId) {
|
||||
if (orgId === 'create') {
|
||||
this.$router.push({ name: 'OrganizationCreate' })
|
||||
} else if (orgId === 'list') {
|
||||
this.$router.push({ name: 'OrganizationList' })
|
||||
} else {
|
||||
orgUtil.changeOrg(orgId)
|
||||
const org = this.usingOrgs.find(item => item.id === orgId)
|
||||
|
||||
switch (orgId) {
|
||||
case 'create':
|
||||
this.$router.push({ name: 'OrganizationCreate' })
|
||||
break
|
||||
case 'list':
|
||||
this.$router.push({ name: 'OrganizationList' })
|
||||
break
|
||||
default:
|
||||
orgUtil.changeOrg(org)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-menu
|
||||
default-active="activeIndex"
|
||||
:default-active="currentViewRoute.name"
|
||||
class="menu-main"
|
||||
:class="mode"
|
||||
:mode="mode"
|
||||
@@ -45,7 +45,9 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
showTip: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
@@ -145,5 +147,4 @@ export default {
|
||||
.menu-main.mobile-view-switch >>> .el-submenu__icon-arrow {
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -5,8 +5,8 @@ const CURRENT_ORG_KEY = 'jms_current_org'
|
||||
const CURRENT_ROLE_KEY = 'jms_current_role'
|
||||
|
||||
export function getTokenFromCookie() {
|
||||
let cookieNamePrefix = VueCookie.get('SESSION_COOKIE_NAME_PREFIX', '')
|
||||
if (cookieNamePrefix === '""') {
|
||||
let cookieNamePrefix = VueCookie.get('SESSION_COOKIE_NAME_PREFIX')
|
||||
if (!cookieNamePrefix || ['""', "''"].indexOf(cookieNamePrefix) > -1) {
|
||||
cookieNamePrefix = ''
|
||||
}
|
||||
return VueCookie.get(cookieNamePrefix + TOKEN_KEY)
|
||||
|
||||
@@ -159,6 +159,10 @@ export function hasUUID(s) {
|
||||
return s.search(uuidPattern) !== -1
|
||||
}
|
||||
|
||||
export function replaceUUID(s, n) {
|
||||
return s.replace(uuidPattern, n)
|
||||
}
|
||||
|
||||
export function getDaysAgo(days, now) {
|
||||
if (!now) {
|
||||
now = new Date()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { hasUUID, BASE_URL } from '@/utils/common'
|
||||
import { getOrgDetail } from '@/api/orgs'
|
||||
import store from '@/store'
|
||||
import { hasUUID, replaceUUID } from '@/utils/common'
|
||||
|
||||
export const DEFAULT_ORG_ID = '00000000-0000-0000-0000-000000000002'
|
||||
|
||||
@@ -10,12 +9,25 @@ function getPropOrg() {
|
||||
if (defaultOrg) {
|
||||
return defaultOrg
|
||||
}
|
||||
return orgs.filter(item => !item.is_root)[0]
|
||||
return orgs.filter(item => !item['is_root'])[0]
|
||||
}
|
||||
|
||||
function change2PropOrg() {
|
||||
async function change2PropOrg() {
|
||||
const org = getPropOrg()
|
||||
setTimeout(() => changeOrg(org.id), 100)
|
||||
await changeOrg(org)
|
||||
}
|
||||
|
||||
async function changeOrg(org) {
|
||||
await store.dispatch('users/setCurrentOrg', org)
|
||||
await store.dispatch('app/reset')
|
||||
let path = location.href
|
||||
if (hasUUID(path)) {
|
||||
path = replaceUUID(path, '')
|
||||
path = _.trimEnd(path, '/')
|
||||
location.href = path
|
||||
} else {
|
||||
setTimeout(() => location.reload(), 400)
|
||||
}
|
||||
}
|
||||
|
||||
function hasCurrentOrgPermission() {
|
||||
@@ -25,27 +37,10 @@ function hasCurrentOrgPermission() {
|
||||
return orgs.find((item) => item.id === currentOrgId)
|
||||
}
|
||||
|
||||
async function changeOrg(orgId) {
|
||||
const org = await getOrgDetail(orgId)
|
||||
if (!org) {
|
||||
console.debug('Error: org not found')
|
||||
} else {
|
||||
console.debug('Change to org: ', org)
|
||||
}
|
||||
|
||||
store.dispatch('users/setCurrentOrg', org).then(() => {
|
||||
// console.log('Set current org to: ', org)
|
||||
if (hasUUID(location.href)) {
|
||||
location.href = BASE_URL
|
||||
} else {
|
||||
window.location.reload(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
hasCurrentOrgPermission,
|
||||
changeOrg,
|
||||
DEFAULT_ORG_ID,
|
||||
change2PropOrg
|
||||
change2PropOrg,
|
||||
changeOrg,
|
||||
getPropOrg
|
||||
}
|
||||
|
||||
@@ -67,14 +67,12 @@ async function changeCurrentOrgIfNeed({ to, from, next }) {
|
||||
await refreshCurrentOrg()
|
||||
const currentOrg = store.getters.currentOrg
|
||||
if (!currentOrg || typeof currentOrg !== 'object') {
|
||||
Vue.$log.error('Current org is null or not a object')
|
||||
orgUtil.change2PropOrg()
|
||||
return reject('Change prop org')
|
||||
Vue.$log.error('Current org is null or not a object: ', currentOrg)
|
||||
await orgUtil.change2PropOrg({ to, from, next })
|
||||
}
|
||||
if (!orgUtil.hasCurrentOrgPermission()) {
|
||||
Vue.$log.error('Not has current org permission')
|
||||
orgUtil.change2PropOrg()
|
||||
return reject('Change prop org')
|
||||
Vue.$log.error('Not has current org permission: ', currentOrg)
|
||||
await orgUtil.change2PropOrg({ to, from, next })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +124,7 @@ export async function changeCurrentViewIfNeed({ to, from, next }) {
|
||||
}
|
||||
|
||||
const has = isViewHasOrgs(viewName)
|
||||
Vue.$log.debug('Change has current view, has perm: ', has)
|
||||
Vue.$log.debug('Change has current view, has perm: ', viewName, '=>', has)
|
||||
if (has) {
|
||||
await store.dispatch('users/changeToView', viewName)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user