+
{
+ localStorage.setItem('projectChangeFlag', 'true');
this.$router.push('/track/case/all');
});
this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent);
@@ -728,6 +728,11 @@ export default {
},
async loadTestCase() {
+ if (localStorage.getItem('projectChangeFlag')) {
+ localStorage.removeItem('projectChangeFlag');
+ return;
+ }
+
let initFuc = this.initEdit;
this.loading = true;
@@ -758,15 +763,18 @@ export default {
});
}
- getTestCaseNodesByCaseFilter(this.projectId, {})
- .then(r => {
- this.treeNodes = r.data;
- this.treeNodes.forEach(node => {
- node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
- buildTree(node, {path: ''});
- this.setNodeModule();
+ if (!this.isPublicShow) {
+ // 公共用例库不展示模块,这里调用接口会有权限校验
+ getTestCaseNodesByCaseFilter(this.projectId, {})
+ .then(r => {
+ this.treeNodes = r.data;
+ this.treeNodes.forEach(node => {
+ node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
+ buildTree(node, {path: ''});
+ this.setNodeModule();
+ });
});
- });
+ }
getTestCaseFollow(this.caseId).then((response) => {
this.form.follows = response.data;
@@ -802,7 +810,12 @@ export default {
this.checkVersionEnable();
},
editPublicCase(type) {
- openCaseEdit({caseId: this.caseId, type}, this)
+ // 这个接口会校验权限
+ getEditSimpleTestCase(this.caseId)
+ .then(() => {
+ openCaseEdit({caseId: this.caseId, type}, this);
+ })
+ .catch(() => {});
},
copyPublicCase() {
this.editPublicCase('copy');
@@ -980,7 +993,7 @@ export default {
},
async checkCurrentProject() {
if (this.isPublicShow) {
- // 如果是用例库查看用例
+ // 用例库查看用例
await getSimpleTestCase(this.caseId).then((response) => {
let testCase = response.data;
this.projectId = testCase.projectId;
@@ -993,17 +1006,22 @@ export default {
setCurrentProjectID(this.projectId);
location.reload();
}
- } else {
- if (this.caseId) {
- await getSimpleTestCase(this.caseId).then((response) => {
- let testCase = response.data;
- if (getCurrentProjectID() !== testCase.projectId) {
- // 如果不是当前项目,先切项目
- setCurrentProjectID(testCase.projectId);
- location.reload();
- }
- })
- }
+ } else if (this.caseId) {
+ // 接口会校验是否有改用例的编辑权限
+ await getEditSimpleTestCase(this.caseId).then((response) => {
+ let testCase = response.data;
+ if (getCurrentProjectID() !== testCase.projectId) {
+ // 如果不是当前项目,先切项目
+ setCurrentProjectID(testCase.projectId);
+ location.reload();
+ } else {
+ this.projectId = testCase.projectId;
+ }
+ })
+ .catch(() => {
+ // 没有权限则跳转到根路径
+ this.$router.push("/");
+ });
}
}
},
diff --git a/test-track/frontend/src/business/case/components/case/CaseBaseInfo.vue b/test-track/frontend/src/business/case/components/case/CaseBaseInfo.vue
index b06c9aa08b..d37ee977f4 100644
--- a/test-track/frontend/src/business/case/components/case/CaseBaseInfo.vue
+++ b/test-track/frontend/src/business/case/components/case/CaseBaseInfo.vue
@@ -47,7 +47,8 @@
-