测试用例项目显示问题

This commit is contained in:
chenjianxing 2020-04-02 09:30:23 +08:00
parent 810927feb9
commit 4f16362954
6 changed files with 44 additions and 18 deletions

View File

@ -65,7 +65,7 @@
<script>
import MsCreateBox from "../settings/CreateBox";
import {Message} from "element-ui";
import {TokenKey} from "../../../common/constants";
import {TokenKey,CURRENT_PROJECT} from "../../../common/constants";
export default {
name: "MsProject",
@ -166,6 +166,10 @@
this.$get('/project/delete/' + row.id, () => {
Message.success(this.$t('commons.delete_success'));
this.list();
let currentProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT));
if(currentProject && row.id === currentProject.id){
localStorage.removeItem(CURRENT_PROJECT);
}
});
}).catch(() => {
});

View File

@ -9,14 +9,16 @@
<template slot="title">
{{currentProject == null ? '' : currentProject.name}}
</template>
<el-scrollbar style="height:500px">
<div style="height:400px;">
<el-scrollbar style="height:100%">
<label v-for="(item,index) in projects" :key="index">
<el-menu-item @click="changeProject(item)">
{{item.name}}
<i class="el-icon-check" v-if="item.id === currentProject.id"></i>
</el-menu-item>
</label>
</el-scrollbar>
</el-scrollbar>
</div>
</el-submenu>
</el-menu>
<node-tree class="node_tree"
@ -47,7 +49,7 @@
import NodeTree from './components/NodeTree';
import TestCaseEdit from './components/TestCaseEdit';
import {WORKSPACE_ID} from '../../../../common/constants';
import {WORKSPACE_ID,CURRENT_PROJECT} from '../../../../common/constants';
import TestCaseList from "./components/TestCaseList";
export default {
@ -74,17 +76,28 @@
this.projectId = this.$route.params.projectId;
this.getProjects();
},
watch: {
'$route'(to, from) {
console.log(from);
console.log(to);
if (from.name.indexOf("Project") > 0){
this.getProjects();
}
}
},
methods: {
getProjects() {
this.$get("/project/listAll", (response) => {
if (response.success) {
this.projects = response.data;
this.initProjects = this.projects.slice(0, 4);
if(localStorage.getItem('currentProject')) {
this.currentProject = JSON.parse(localStorage.getItem('currentProject'));
if(localStorage.getItem(CURRENT_PROJECT)) {
this.currentProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT));
} else {
this.currentProject = this.projects[0];
localStorage.setItem('currentProject', JSON.stringify(this.projects[0]));
if(this.projects.length > 0){
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(this.projects[0]));
}
}
} else {
this.$message()({
@ -93,7 +106,7 @@
});
}
this.loadingRequire.project = false;
this.checkProject();
// this.checkProject();
});
},
checkProject() {
@ -108,7 +121,7 @@
},
changeProject(project) {
this.currentProject = project;
localStorage.setItem('currentProject', JSON.stringify(project));
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project));
this.$refs.testCaseList.initTableData()
this.$refs.nodeTree.getNodeTree();
},

View File

@ -60,6 +60,9 @@
</template>
<script>
import {CURRENT_PROJECT} from '../../../../../common/constants';
export default {
name: "NodeTree",
data() {
@ -133,7 +136,7 @@
},
getChildNodeId(rootNode, nodeIds) {
//ID
nodeIds.push(rootNode.data.id)
nodeIds.push(rootNode.data.id);
for (let i = 0; i < rootNode.childNodes.length; i++){
this.getChildNodeId(rootNode.childNodes[i], nodeIds);
}
@ -153,8 +156,8 @@
this.dialogFormVisible = true;
},
getNodeTree() {
if(localStorage.getItem('currentProject')){
let projectId = JSON.parse(localStorage.getItem('currentProject')).id;
if(localStorage.getItem(CURRENT_PROJECT)) {
let projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id;
this.$get("/case/node/list/" + projectId, response => {
this.treeNodes = response.data;
});
@ -180,8 +183,8 @@
param.name = this.form.name;
param.label = this.form.name;
if(localStorage.getItem('currentProject')){
param.projectId = JSON.parse(localStorage.getItem('currentProject')).id;
if(localStorage.getItem(CURRENT_PROJECT)) {
param.projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id;
}
this.$post(url, param, response => {

View File

@ -180,6 +180,9 @@
</template>
<script>
import {CURRENT_PROJECT} from '../../../../../common/constants';
export default {
name: "TestCaseEdit",
data() {
@ -261,8 +264,8 @@
param.nodePath = item.path;
}
});
if(localStorage.getItem('currentProject')){
param.projectId = JSON.parse(localStorage.getItem('currentProject')).id;
if(localStorage.getItem(CURRENT_PROJECT)) {
param.projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id;
}
this.$post('/test/case/' + this.operationType, param, () => {
this.$message.success(this.$t('commons.save_success'));

View File

@ -119,6 +119,8 @@
</template>
<script>
import {CURRENT_PROJECT} from '../../../../../common/constants';
export default {
name: "TestCaseList",
data() {
@ -146,8 +148,8 @@
};
param.nodeIds = nodeIds;
if(localStorage.getItem('currentProject')){
param.projectId = JSON.parse(localStorage.getItem('currentProject')).id;
if(localStorage.getItem(CURRENT_PROJECT)) {
param.projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id;
}
this.$post(this.buildPagePath('/test/case/list'), param, response => {

View File

@ -7,3 +7,4 @@ export const ROLE_TEST_USER = 'test_user';
export const ROLE_TEST_VIEWER = 'test_viewer';
export const WORKSPACE_ID = 'workspace_id';
export const CURRENT_PROJECT = 'current_project';