This commit is contained in:
chenjianxing 2020-06-02 16:16:55 +08:00
commit 17b10751a8
7 changed files with 42 additions and 63 deletions

View File

@ -2,38 +2,35 @@
<div id="menu-bar">
<el-row type="flex">
<el-col :span="8">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'>
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'
menu-trigger="click">
<el-menu-item :index="'/api/home'">
{{ $t("i18n.home") }}
</el-menu-item>
<el-submenu v-if="isCurrentWorkspaceUser"
index="3" popper-class="submenu">
<el-submenu v-if="isCurrentWorkspaceUser" index="3">
<template v-slot:title>{{$t('commons.project')}}</template>
<ms-recent-list :options="projectRecent"/>
<el-divider/>
<el-divider class="menu-divider"/>
<ms-show-all :index="'/api/project/all'"/>
<ms-create-button v-permission="['test_manager', 'test_user']" :index="'/api/project/create'" :title="$t('project.create')"/>
<ms-create-button v-permission="['test_manager', 'test_user']" :index="'/api/project/create'"
:title="$t('project.create')"/>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="4" popper-class="submenu">
<el-submenu v-if="isCurrentWorkspaceUser" index="4">
<template v-slot:title>{{$t('commons.test')}}</template>
<ms-recent-list :options="testRecent"/>
<el-divider/>
<el-divider class="menu-divider"/>
<ms-show-all :index="'/api/test/list/all'"/>
<ms-create-button v-permission="['test_manager', 'test_user']" :index="'/api/test/create'" :title="$t('load_test.create')"/>
<!-- <el-menu-item :index="testCaseProjectPath" class="blank_item"></el-menu-item>-->
<!-- <el-menu-item :index="testEditPath" class="blank_item"></el-menu-item>-->
<ms-create-button v-permission="['test_manager', 'test_user']" :index="'/api/test/create'"
:title="$t('load_test.create')"/>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="5" popper-class="submenu">
<el-submenu v-if="isCurrentWorkspaceUser" index="5">
<template v-slot:title>{{$t('commons.report')}}</template>
<ms-recent-list :options="reportRecent"/>
<el-divider/>
<el-divider class="menu-divider"/>
<ms-show-all :index="'/api/report/list/all'"/>
<!-- <el-menu-item :index="reportViewPath" class="blank_item"></el-menu-item>-->
</el-submenu>
</el-menu>
</el-col>
@ -62,10 +59,6 @@
data() {
return {
isCurrentWorkspaceUser: false,
// testCaseProjectPath: '',
// testEditPath: '',
// reportViewPath: '',
// isRouterAlive: true,
projectRecent: {
title: this.$t('project.recent'),
url: "/project/recent/5",
@ -96,55 +89,20 @@
}
}
},
// watch: {
// '$route'(to, from) {
// let path = to.path;
// //
// if (path.indexOf("/api/test/") >= 0) {
// this.testCaseProjectPath = '/api/test/' + this.$route.params.projectId;
// this.reload();
// }
// if (path.indexOf("/api/test/edit/") >= 0) {
// this.testEditPath = '/api/test/edit/' + this.$route.params.testId;
// this.reload();
// }
// if (path.indexOf("/api/report/view/") >= 0) {
// this.reportViewPath = '/api/report/view/' + this.$route.params.reportId;
// this.reload();
// }
// }
// },
mounted() {
this.isCurrentWorkspaceUser = checkoutCurrentWorkspace();
},
// methods: {
// reload() {
// this.isRouterAlive = false;
// this.$nextTick(function () {
// this.isRouterAlive = true;
// })
// }
// }
}
</script>
<style scoped>
.el-divider--horizontal {
margin: 0;
}
.el-menu.el-menu--horizontal {
border-bottom: none;
}
#menu-bar {
border-bottom: 1px solid #E6E6E6;
background-color: #FFF;
}
.blank_item {
display: none;
.menu-divider {
margin: 0;
}
</style>

View File

@ -85,9 +85,7 @@
methods: {
init() {
this.result = this.$get("/project/listAll", response => {
this.projects = response.data;
})
let projectId;
if (this.id) {
this.create = false;
this.getTest(this.id);
@ -97,7 +95,14 @@
if (this.$refs.config) {
this.$refs.config.reset();
}
//
projectId = this.$store.state.common.projectId;
}
this.result = this.$get("/project/listAll", response => {
this.projects = response.data;
//
if (projectId) this.test.projectId = projectId;
})
},
getTest(id) {
this.result = this.$get("/api/get/" + id, response => {

View File

@ -150,6 +150,9 @@
},
init() {
this.projectId = this.$route.params.projectId;
if (this.projectId && this.projectId !== "all") {
this.$store.commit('setProjectId', this.projectId);
}
this.search();
},
/* filter(value, row) {

View File

@ -3,6 +3,17 @@ import Vuex from 'vuex'
Vue.use(Vuex);
const Common = {
state: {
projectId: ""
},
mutations: {
setProjectId(state, projectId) {
state.projectId = projectId;
}
}
}
const API = {
state: {
test: {}
@ -14,13 +25,12 @@ const API = {
clearTest(state) {
state.test = {};
}
},
actions: {},
getters: {}
}
}
export default new Vuex.Store({
modules: {
api: API
api: API,
common: Common
}
})

View File

@ -4,6 +4,7 @@ export default {
'organization': 'Organization',
'setting': 'Setting',
'project': 'Project',
current_project: 'Current Project',
'name': 'Name',
'description': 'Description',
'clear': 'Clear',

View File

@ -4,6 +4,7 @@ export default {
'organization': '组织',
'setting': '设置',
'project': '项目',
current_project: '当前项目',
'name': '名称',
'description': '描述',
'clear': '清空',

View File

@ -4,6 +4,7 @@ export default {
'organization': '組織',
'setting': '設置',
'project': '項目',
current_project: '當前項目',
'name': '名稱',
'description': '描述',
'clear': '清空',