fix(测试跟踪): 用例库用例项目权限问题优化

--bug=1023636 --user=陈建星 【测试跟踪】公共用例库-当前用户对无项目权限的用例进行操作-问题汇总 https://www.tapd.cn/55049933/s/1340426
This commit is contained in:
chenjianxing 2023-02-22 11:51:24 +08:00 committed by CaptainB
parent 85f993cbb3
commit 58d3e27ab0
5 changed files with 42 additions and 19 deletions

View File

@ -205,6 +205,9 @@ export default {
}); });
}, },
getTranslateOption(item) { getTranslateOption(item) {
if (!item) {
return '';
}
if (Array.isArray(item)) { if (Array.isArray(item)) {
let arr = []; let arr = [];
item.forEach((v) => { item.forEach((v) => {

View File

@ -79,7 +79,7 @@
</div> </div>
<div <div
class="follow-row head-opt" class="follow-row head-opt"
v-if="!showFollow" v-if="!showFollow && !isPublicShow"
@click="saveFollow" @click="saveFollow"
> >
<div class="icon-row"> <div class="icon-row">
@ -89,7 +89,7 @@
</div> </div>
<div <div
class="follow-row head-opt" class="follow-row head-opt"
v-if="showFollow" v-if="showFollow && !isPublicShow"
@click="saveFollow" @click="saveFollow"
> >
<div class="icon-row"> <div class="icon-row">
@ -150,7 +150,7 @@
<div <div
class="edit-public-row head-opt" class="edit-public-row head-opt"
v-if="isPublicShow" v-if="isPublicShow"
@click="editPublicCase()" @click="editPublicCase"
> >
<div class="icon-row"> <div class="icon-row">
<img src="/assets/module/figma/icon_edit_outlined.svg" alt="" /> <img src="/assets/module/figma/icon_edit_outlined.svg" alt="" />
@ -567,7 +567,7 @@ export default {
}, },
computed: { computed: {
routeProjectId() { routeProjectId() {
return this.$route.params.projectId; return this.$route.query.projectId;
}, },
moduleOptions() { moduleOptions() {
return store.testCaseModuleOptions; return store.testCaseModuleOptions;
@ -795,16 +795,17 @@ export default {
this.checkVersionEnable(); this.checkVersionEnable();
}, },
editPublicCase(type) { editPublicCase() {
// //
getEditSimpleTestCase(this.caseId) getEditSimpleTestCase(this.caseId)
.then(() => { .then(() => {
openCaseEdit({caseId: this.caseId, type}, this); openCaseEdit({caseId: this.caseId}, this);
}) })
.catch(() => {}); .catch(() => {});
}, },
copyPublicCase() { copyPublicCase() {
this.editPublicCase('copy'); // 使使 projectId
openCaseEdit({caseId: this.caseId, type: 'copy', projectId: getCurrentProjectID()}, this);
}, },
closePublicCase() { closePublicCase() {
this.$emit("close"); this.$emit("close");
@ -986,11 +987,26 @@ export default {
}); });
} else { } else {
this.projectId = this.routeProjectId; this.projectId = this.routeProjectId;
if (this.routeProjectId) { //
// projectId if (this.isCopy || this.isAdd) {
if (getCurrentProjectID() !== this.projectId) { // routeProjectId
setCurrentProjectID(this.projectId); if (this.routeProjectId) {
location.reload(); if (getCurrentProjectID() !== this.projectId) {
setCurrentProjectID(this.projectId);
location.reload();
return;
}
} else {
// routeProjectId 使
this.projectId = getCurrentProjectID();
}
if (this.caseId) {
// copy
await getSimpleTestCase(this.caseId).then((response) => {
let testCase = response.data;
// ID
testCase.projectId = this.projectId;
});
} }
} else if (this.caseId) { } else if (this.caseId) {
// //
@ -1559,7 +1575,7 @@ export default {
this.saveCase(); this.saveCase();
}, },
copyRow() { copyRow() {
openCaseEdit({caseId: this.testCase.id, type: 'copy'}, this); openCaseEdit({caseId: this.testCase.id, type: 'copy', projectId: this.projectId}, this);
}, },
deleteRow() { deleteRow() {
getTestCaseVersions(this.testCase.id) getTestCaseVersions(this.testCase.id)

View File

@ -844,8 +844,8 @@ export default {
reloadTable() { reloadTable() {
this.$refs.table.resetHeader(); this.$refs.table.resetHeader();
}, },
handleEdit(testCase, type) { handleEdit(testCase) {
openCaseEdit({caseId: testCase.id, type}, this); openCaseEdit({caseId: testCase.id}, this);
}, },
getCase(id) { getCase(id) {
this.$refs.testCasePreview.open(); this.$refs.testCasePreview.open();
@ -870,7 +870,7 @@ export default {
}); });
}, },
handleCopy(testCase) { handleCopy(testCase) {
this.handleEdit(testCase, 'copy'); openCaseEdit({caseId: testCase.id, type: 'copy', projectId: this.projectId}, this);
}, },
handleDelete(testCase) { handleDelete(testCase) {
let title = this.$t('test_track.case.case_delete_completely_confirm') + ": " + testCase.name + "?"; let title = this.$t('test_track.case.case_delete_completely_confirm') + ": " + testCase.name + "?";

View File

@ -447,11 +447,11 @@ export default {
callBackSelectAll(selection) { callBackSelectAll(selection) {
this.selectCounts = this.$refs.table.selectDataCounts; this.selectCounts = this.$refs.table.selectDataCounts;
}, },
handleEdit(testCase, type) { handleEdit(testCase) {
// //
getEditSimpleTestCase(testCase.id) getEditSimpleTestCase(testCase.id)
.then(() => { .then(() => {
openCaseEdit({caseId: testCase.id, type}, this); openCaseEdit({caseId: testCase.id}, this);
}) })
.catch(() => {}); .catch(() => {});
}, },

View File

@ -64,7 +64,11 @@ export function openCaseEdit(query, v) {
if (!query.type) { if (!query.type) {
delete query.type; delete query.type;
} }
delete query.projectId; if (query.type !== 'copy') {
// 编辑不带项目id会检查用例的权限
// 复制需要带项目id复制到当前项目包括用例库的复制
delete query.projectId;
}
let path = '/track/case/edit/' + query.caseId; let path = '/track/case/edit/' + query.caseId;
delete query.caseId; delete query.caseId;
let TestCaseData = v.$router.resolve({ let TestCaseData = v.$router.resolve({