merge: with master

This commit is contained in:
ibuler
2020-05-28 16:13:01 +08:00
10 changed files with 116 additions and 54 deletions

View File

@@ -22,8 +22,9 @@ export default {
goDetail() {
const defaultRoute = this.$route.name.replace('List', 'Detail')
const routeName = this.col.route || this.col.detailRoute || defaultRoute
const routeQuery = this.col.routeQuery || {}
this.$log.debug('Will go to detail route: ', routeName)
this.$router.push({ name: routeName, params: { id: this.row.id }})
this.$router.push({ name: routeName, params: { id: this.row.id }, query: routeQuery })
}
}
}

View File

@@ -69,6 +69,7 @@
"Role": "角色",
"SerialNumber": "序列号",
"SetMFA": "设置多因子认证",
"UpdateMFA": "更改多因子认证",
"Source": "来源",
"SystemUserDetail": "系统用户详情",
"SystemUsers": "系统用户",

View File

@@ -53,6 +53,9 @@ export default {
methods: {
handleClick(val) {
switch (val) {
case 'profile':
this.$router.push({ name: 'userProfile' })
break
case 'AdminPage':
setPermission('Admin')
window.location.href = `/`

View File

@@ -20,6 +20,9 @@
<script>
import Page from '../Page/'
const ACTIVE_TAB_KEY = 'activeTab'
export default {
name: 'TabPage',
components: {
@@ -53,29 +56,32 @@ export default {
}
},
mounted() {
// 尝试从cookie中取活跃的tab
this.iActiveMenu = this.getPropActiveTab()
},
methods: {
handleTabClick(tab) {
this.$emit('tab-click', tab)
this.$emit('update:activeMenu', tab.name)
this.$cookie.set('activeTab', tab.name, 1)
this.$cookie.set(ACTIVE_TAB_KEY, tab.name, 1)
},
getPropActiveTab() {
const tabActive = this.$cookie.get('activeTab')
let tabIndex = this.tabIndices[tabActive]
let activeMenu = ''
if (tabIndex !== undefined) {
activeMenu = tabActive
} else {
activeMenu = this.activeMenu
let activeTab = ''
let tabObj = null
const activeTabs = [
this.$route.query[ACTIVE_TAB_KEY],
this.$cookie.get(ACTIVE_TAB_KEY),
this.activeMenu
]
for (activeTab of activeTabs) {
tabObj = this.tabIndices[activeTab]
if (tabObj !== undefined) {
return activeTab
}
}
tabIndex = this.tabIndices[activeMenu]
if (tabIndex === undefined) {
activeMenu = this.submenu[0].name
}
return activeMenu
return this.submenu[0].name
}
}
}

View File

@@ -77,7 +77,7 @@ router.beforeEach(async(to, from, next) => {
// remove token and go to login page to re-login
// await store.dispatch('user/resetToken')
Message.error(error || 'Has Error')
// next(`/login?redirect=${to.path}`)
next(`/auth/login/`)
console.log(error)
NProgress.done()
// next()

View File

@@ -50,7 +50,31 @@ export const constantRoutes = [
}
]
/**
* admin and user routes
* the routes that need to be dynamically loaded based on admin or user roles
*/
export const commonRoutes = {
userProfile: {
path: '/users/profile',
component: Layout,
children: [
{
path: '',
name: 'userProfile',
component: () => import('@/userviews/users/index'),
meta: { title: i18n.t('route.UserProfile'), icon: 'user', activeMenu: '/users/profile' }
}
]
}
}
/**
* admin
* the routes that need to be dynamically loaded based on admin roles
*/
export const adminRoutes = [
Object.assign({}, commonRoutes.userProfile, { hidden: true }),
{
path: '/',
component: Layout,

View File

@@ -11,7 +11,8 @@ const getDefaultState = () => {
token: getToken(),
profile: {},
currentOrg: getCurrentOrg(),
orgs: []
orgs: [],
internalInit: Boolean
}
}
@@ -27,6 +28,9 @@ const mutations = {
SET_PROFILE: (state, profile) => {
state.profile = profile
},
SET_STATUS: (state) => {
state.internalInit = true
},
SET_ORGS: (state, orgs) => {
// API BUG FIX
for (let index = 0; index < orgs.length; index++) {
@@ -61,18 +65,23 @@ const actions = {
// get user Profile
getProfile({ commit, state }) {
return new Promise((resolve, reject) => {
if (!state.internalInit) {
reject('Init failed, please Login again.')
}
getProfile().then(response => {
if (!response) {
reject('Verification failed, please Login again.')
}
const { admin_or_audit_orgs } = response
// const rules = [role]
const { admin_or_audit_orgs, rule } = response
const rules = [rule]
// roles must be a non-empty array
// if (!rules || rules.length <= 0) {
// reject('getProfile: roles must be a non-null array!')
// }
if (!rules || rules.length <= 0) {
reject('getProfile: roles must be a non-null array!')
}
commit('SET_PROFILE', response)
commit('SET_ORGS', admin_or_audit_orgs)
commit('SET_STATUS')
resolve(response)
}).catch(error => {
reject(error)

View File

@@ -14,7 +14,7 @@ import DetailCard from '@/components/DetailCard'
import QuickActions from '@/components/QuickActions'
import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'Detail',
name: 'UserProfile',
components: {
DetailCard,
QuickActions
@@ -38,6 +38,16 @@ export default {
click: function() {}
}
},
{
title: this.$t('assets.UpdateMFA'),
attrs: {
type: 'primary',
label: this.$t('common.Reset')
},
callbacks: {
click: function() {}
}
},
{
title: this.$t('assets.UpdatePassword'),
attrs: {

View File

@@ -1,37 +1,36 @@
<template>
<GenericDetailPage :object.sync="TaskDetail" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners">
<GenericDetailPage :object.sync="user" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners">
<keep-alive>
<component :is="config.activeMenu" :object="TaskDetail" />
<component :is="config.activeMenu" :object="user" />
</keep-alive>
</GenericDetailPage>
</template>
<script>
import { GenericDetailPage } from '@/layout/components'
import Detail from './Detail.vue'
export default {
name: 'AssetListDetail',
components: {
GenericDetailPage,
Detail
},
data() {
return {
TaskDetail: {},
config: {
title: this.$t('assets.SystemUserDetail'),
activeMenu: 'Detail',
submenu: [
{
title: this.$t('assets.detail'),
name: 'Detail'
}
],
hasRightSide: false
}
import { GenericDetailPage } from '@/layout/components'
import UserProfile from './UserProfile.vue'
export default {
name: 'AssetListDetail',
components: {
GenericDetailPage,
UserProfile
},
data() {
return {
user: {},
config: {
title: this.$t('common.nav.Profile'),
submenu: [
{
title: this.$t('common.BasicInfo'),
name: 'UserProfile'
}
],
hasRightSide: false
}
}
}
}
</script>
<style scoped>

View File

@@ -4,7 +4,7 @@
<script>
import GenericTreeListPage from '@/layout/components/GenericTreeListPage'
import { ExpandAssetPermissionFormatter } from '@/components/ListTable/formatters/index'
import { DetailFormatter } from '@/components/ListTable/formatters/index'
export default {
components: {
@@ -35,20 +35,29 @@ export default {
{ label: this.$t('perms.SystemUser'), key: 'system_user' },
{ label: '继承(先占位)', key: 'all=0' }
],
columns: ['expand', 'name', 'users_amount', 'user_groups_amount', 'assets_amount', 'nodes_amount', 'system_users_amount', 'is_active', 'actions'],
columns: ['name', 'users_amount', 'user_groups_amount', 'assets_amount', 'nodes_amount', 'system_users_amount', 'is_active', 'actions'],
columnsMeta: {
expand: {
type: 'expand',
formatter: ExpandAssetPermissionFormatter
name: {
routeQuery: {
activeTab: 'AssetPermissionDetail'
}
},
users_amount: {
label: this.$t('perms.User')
label: this.$t('perms.User'),
formatter: DetailFormatter,
routeQuery: {
activeTab: 'AssetPermissionUser'
}
},
user_groups_amount: {
label: this.$t('perms.UserGroups')
},
assets_amount: {
label: this.$t('perms.Asset')
label: this.$t('perms.Asset'),
formatter: DetailFormatter,
routeQuery: {
activeTab: 'AssetPermissionAsset'
}
},
nodes_amount: {
label: this.$t('perms.Node')