Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
haifeng414 2020-02-21 11:46:23 +08:00
commit d8408e9c7e
5 changed files with 106 additions and 78 deletions

View File

@ -1 +1,7 @@
export const TokenKey = 'Admin-Token';
export const ROLE_ADMIN = 'admin';
export const ROLE_ORG_ADMIN = 'org_admin';
export const ROLE_TEST_MANAGER = 'test_manager';
export const ROLE_TEST_USER = 'test_user';
export const ROLE_TEST_VIEWER = 'test_viewer';

View File

@ -7,8 +7,13 @@
:default-active="activeIndex"
@select="handleSelect"
router>
<el-menu-item index="1">功能测试</el-menu-item>
<el-menu-item index="/createTest" onselectstart="return false">性能测试</el-menu-item>
<el-menu-item index="1" v-permission="['test_manager','test_user','test_viewer']">
功能测试
</el-menu-item>
<el-menu-item index="/createTest" onselectstart="return false"
v-permission="['test_manager','test_user','test_viewer']">
性能测试
</el-menu-item>
<el-menu-item index="/setting" onselectstart="return false">系统设置</el-menu-item>
</el-menu>
</template>
@ -22,15 +27,15 @@
}
},
watch: {
'$route' () {
'$route'() {
this.handleSelect(this.activeIndex);
}
},
mounted () {
mounted() {
this.activeIndex = this.$route.matched[0].path || '/'
},
methods: {
handleSelect (index) {
handleSelect(index) {
this.activeIndex = index
}
}

View File

@ -6,7 +6,7 @@
class="header-user-menu"
background-color="rgb(44, 42, 72)"
text-color="#fff">
<el-submenu index="1" popper-class="submenu">
<el-submenu index="1" popper-class="submenu" v-permission="['org_admin']">
<template slot="title">组织</template>
<label v-for="(item,index) in organizationList" :key="index">
<el-menu-item @click="clickMenu(item)">{{item.name}}
@ -15,7 +15,7 @@
</el-menu-item>
</label>
</el-submenu>
<el-submenu index="2" popper-class="submenu">
<el-submenu index="2" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
<template slot="title">工作空间</template>
<label v-for="(item,index) in workspaceList" :key="index">
<el-menu-item @click="clickMenu(item)">
@ -43,7 +43,7 @@
<script>
import Cookies from 'js-cookie';
import {TokenKey} from '../../common/constants';
import {ROLE_ORG_ADMIN, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER, TokenKey} from '../../common/constants';
export default {
name: "MsUser",
@ -98,13 +98,18 @@
}
},
initMenuData() {
this.$get("/organization/list/userorg/" + this.currentUserId, response => {
this.organizationList = response.data;
})
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => {
this.workspaceList = response.data;
this.workspaceIds = response.data.map(r => r.id);
})
let roles = this.currentUser.roles.map(r => r.id);
if (roles.indexOf(ROLE_ORG_ADMIN) > 0) {
this.$get("/organization/list/userorg/" + this.currentUserId, response => {
this.organizationList = response.data;
});
}
if (roles.indexOf(ROLE_TEST_MANAGER) > 0 || roles.indexOf(ROLE_TEST_USER) > 0 || roles.indexOf(ROLE_TEST_VIEWER) > 0) {
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => {
this.workspaceList = response.data;
this.workspaceIds = response.data.map(r => r.id);
});
}
},
getCurrentUserInfo() {
this.$get("/user/info/" + this.currentUserId, response => {

View File

@ -1,10 +1,10 @@
<template>
<el-row type="flex" align="middle" class="current-user">
<el-avatar shape="square" size="small" :src="squareUrl"/>
<span class="username">kun@fit2cloud.com</span>
<span class="username">{{currentUser.name}}</span>
<el-button class="edit" type="primary" icon="el-icon-edit" size="mini"
circle @click="editVisible = true"/>
<el-dialog :title="title" :visible.sync="editVisible" width="30%">
circle @click="edit"/>
<el-dialog :title="currentUser.name" :visible.sync="editVisible" width="30%">
<el-form :model="form" label-position="top" size="small">
<el-form-item label="姓名">
<el-input v-model="form.name" autocomplete="off"/>
@ -14,28 +14,40 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="editVisible = false" size="medium">更新</el-button>
</span>
<el-button type="primary" @click="submit" size="medium">更新</el-button>
</span>
</el-dialog>
</el-row>
</template>
<script>
import Cookies from 'js-cookie';
import {TokenKey} from "../../../common/constants";
export default {
name: "MsCurrentUser",
data() {
return {
editVisible: false,
id: "123456",
squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
form: {
name: "kun@fit2cloud.com",
mobile: ""
}
form: {}
}
}, computed: {
title: function () {
return "编辑账号(id: " + this.id + ")";
},
methods: {
edit() {
this.editVisible = true;
this.form = Object.assign({}, this.currentUser);
},
submit() {
this.editVisible = false;
}
},
computed: {
currentUser: () => {
let user = Cookies.get(TokenKey);
return JSON.parse(user);
}
}
}

View File

@ -1,63 +1,63 @@
<template>
<el-menu menu-trigger="click" :default-active="$route.path" router>
<el-submenu index="1" v-permission="['admin']">
<template slot="title">
<font-awesome-icon class="icon account" :icon="['far', 'address-card']" size="lg"/>
<span>账号</span>
</template>
<el-menu-item index="/setting/user">用户</el-menu-item>
<el-menu-item index="/setting/testresourcepool" v-permission="['test']">测试资源池</el-menu-item>
<el-menu-item index="/setting/organization">组织</el-menu-item>
<el-menu-item index="/setting/workspace">工作空间</el-menu-item>
<el-menu-item>API Keys</el-menu-item>
</el-submenu>
<el-submenu index=2 v-permission="['admin','org_admin']">
<template slot="title">
<font-awesome-icon class="icon workspace" :icon="['far', 'clone']" size="lg"/>
<span>工作空间</span>
</template>
<el-menu-item index="/setting/member">成员</el-menu-item>
<el-menu-item>证书</el-menu-item>
<el-menu-item>测试计划</el-menu-item>
<el-menu-item>警告</el-menu-item>
</el-submenu>
<el-submenu index="3">
<template slot="title">
<font-awesome-icon class="icon" :icon="['far', 'user']" size="lg"/>
<span>个人</span>
</template>
<el-menu-item>个人设置</el-menu-item>
<el-menu-item>API Keys</el-menu-item>
</el-submenu>
</el-menu>
<el-menu menu-trigger="click" :default-active="$route.path" router>
<el-submenu index="1" v-permission="['admin']">
<template slot="title">
<font-awesome-icon class="icon account" :icon="['far', 'address-card']" size="lg"/>
<span>账号</span>
</template>
<el-menu-item index="/setting/user" v-permission="['admin']">用户</el-menu-item>
<el-menu-item index="/setting/testresourcepool" v-permission="['test']">测试资源池</el-menu-item>
<el-menu-item index="/setting/organization" v-permission="['admin']">组织</el-menu-item>
<el-menu-item index="/setting/workspace" v-permission="['org_admin']">工作空间</el-menu-item>
<el-menu-item>API Keys</el-menu-item>
</el-submenu>
<el-submenu index=2 v-permission="['org_admin']">
<template slot="title">
<font-awesome-icon class="icon workspace" :icon="['far', 'clone']" size="lg"/>
<span>工作空间</span>
</template>
<el-menu-item index="/setting/member">成员</el-menu-item>
<el-menu-item>证书</el-menu-item>
<el-menu-item>测试计划</el-menu-item>
<el-menu-item>警告</el-menu-item>
</el-submenu>
<el-submenu index="3">
<template slot="title">
<font-awesome-icon class="icon" :icon="['far', 'user']" size="lg"/>
<span>个人</span>
</template>
<el-menu-item>个人设置</el-menu-item>
<el-menu-item>API Keys</el-menu-item>
</el-submenu>
</el-menu>
</template>
<script>
export default {
name: "MsSettingMenu"
}
export default {
name: "MsSettingMenu"
}
</script>
<style scoped>
.el-menu {
border-right: 0;
}
.el-menu {
border-right: 0;
}
.el-menu-item {
height: 40px;
line-height: 40px;
}
.el-menu-item {
height: 40px;
line-height: 40px;
}
.icon {
width: 24px;
margin-right: 10px;
}
.icon {
width: 24px;
margin-right: 10px;
}
.account {
color: #5a78f0;
}
.account {
color: #5a78f0;
}
.workspace {
color: #44b349;
}
.workspace {
color: #44b349;
}
</style>