切换公司2

This commit is contained in:
xielue 2022-12-15 19:15:49 +08:00
parent b89a685ffb
commit 3d95f8635d
1 changed files with 22 additions and 17 deletions

View File

@ -1,22 +1,22 @@
<template>
<div>
</div>
<div>
</div>
</template>
<script>
<script>
import { getUserInfo, getRoutesConfig, getPermission, getSettings, getCompany } from '@/services/base/user'
import { setAuthorization, setCompany } from '@/utils/request'
import { loadRoutes } from '@/utils/routerUtil'
import { mapMutations } from 'vuex'
import Cookie from 'js-cookie'
import { USER_MODEL } from '@/services/base/api.js';
import { USER_MODEL } from '@/services/base/api.js';
//
export default {
name: 'loginActions',
components: { },
components: {},
data() {
return {
logging: false,
@ -32,26 +32,26 @@ export default {
company: Cookie.get('company'),
loginResult: null
}
},
},
computed: {
},
beforeMount() {
},
created() {
},
methods: {
...mapMutations('account', ['setUid', 'setUser', 'setPermissions', 'setRoutesConfig', 'setSettings', 'setCompany', 'setProject']),
isMiddleAdmin() {
isMiddleAdmin() {
return USER_MODEL == "AdminUser";
},
afterLoginSuccess({ token, access_expire, uid, msg = '登录成功',pushTo = '/dashboard/workplace' }) {
afterLoginSuccess({ closeOthers, token, access_expire, uid, msg = '登录成功', pushTo = '/dashboard/workplace' }) {
setAuthorization({ token: token, expireAt: new Date(access_expire * 1000) }) // token
this.setUid(uid) // id
@ -74,8 +74,13 @@ export default {
const routesConfig = result.data.data
this.setRoutesConfig(routesConfig)
loadRoutes([routesConfig])
//this.$router.push(pushTo)
this.$closeOthers(pushTo)
if (closeOthers) {
this.$closeOthers(pushTo)
} else {
this.$router.push(pushTo)
}
this.$message.success(msg, 3)
}
})
@ -100,6 +105,6 @@ export default {
</script>
<style lang="less" scoped>
</style>