fix(测试跟踪): 功能用例编辑页偶发会跳转到列表页

--bug=1024405 --user=陈建星 【测试跟踪】功能用例-点击创建用例-有时新增tab页进入功能用例列表页面 https://www.tapd.cn/55049933/s/1350974
This commit is contained in:
chenjianxing 2023-03-15 20:14:11 +08:00 committed by jianxing
parent 133868a9d7
commit e309c6aa42
8 changed files with 20 additions and 32 deletions

View File

@ -204,7 +204,6 @@ export default {
switchProject({id: this.userId, lastProjectId: projectId}) switchProject({id: this.userId, lastProjectId: projectId})
.then(response => { .then(response => {
this.userStore.switchProject(response); this.userStore.switchProject(response);
this.userStore.projectChangeFlag = true;
this.$EventBus.$emit('projectChange'); this.$EventBus.$emit('projectChange');
this.changeProjectName(projectId); this.changeProjectName(projectId);
// //

View File

@ -41,8 +41,7 @@ export default {
id: TokenKey, id: TokenKey,
state: () => ({ state: () => ({
language: getLanguage(), language: getLanguage(),
showLicenseCountWarning: false, showLicenseCountWarning: false
projectChangeFlag: false
}), }),
persist: true, persist: true,
getters: { getters: {

View File

@ -762,11 +762,6 @@ export default {
}); });
}, },
async loadTestCase() { async loadTestCase() {
if (this.useUserStore.projectChangeFlag) {
this.useUserStore.projectChangeFlag = false;
this.$router.push('/track/case/all');
return;
}
if (this.isPublicShow) { if (this.isPublicShow) {
this.resetForm(); this.resetForm();
@ -838,8 +833,8 @@ export default {
editPublicCase() { editPublicCase() {
// //
getEditSimpleTestCase(this.caseId) getEditSimpleTestCase(this.caseId)
.then(() => { .then((r) => {
openCaseEdit({caseId: this.caseId}, this); openCaseEdit({caseId: this.caseId, projectId: r.data.projectId}, this);
}) })
.catch(() => {}); .catch(() => {});
}, },
@ -1017,16 +1012,17 @@ export default {
}); });
} else { } else {
this.projectId = this.routeProjectId; this.projectId = this.routeProjectId;
if (this.projectId) {
// routeProjectId
if (getCurrentProjectID() !== this.projectId) {
setCurrentProjectID(this.projectId);
location.reload();
return;
}
}
// //
if (this.isCopy || this.isAdd) { if (this.isCopy || this.isAdd) {
// routeProjectId if (!this.projectId) {
if (this.routeProjectId) {
if (getCurrentProjectID() !== this.projectId) {
setCurrentProjectID(this.projectId);
location.reload();
return;
}
} else {
// routeProjectId 使 // routeProjectId 使
this.projectId = getCurrentProjectID(); this.projectId = getCurrentProjectID();
} }
@ -1043,9 +1039,8 @@ export default {
await getEditSimpleTestCase(this.caseId).then((response) => { await getEditSimpleTestCase(this.caseId).then((response) => {
let testCase = response.data; let testCase = response.data;
if (getCurrentProjectID() !== testCase.projectId) { if (getCurrentProjectID() !== testCase.projectId) {
// //
setCurrentProjectID(testCase.projectId); this.$router.push({path: '/track/case/all', query: {projectId: getCurrentProjectID()}});
location.reload();
} else { } else {
this.projectId = testCase.projectId; this.projectId = testCase.projectId;
} }

View File

@ -469,7 +469,7 @@ export default {
// //
getEditSimpleTestCase(testCase.id) getEditSimpleTestCase(testCase.id)
.then(() => { .then(() => {
openCaseEdit({caseId: testCase.id}, this); openCaseEdit({caseId: testCase.id, projectId: testCase.projectId}, this);
}) })
.catch(() => {}); .catch(() => {});
}, },

View File

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

View File

@ -618,7 +618,7 @@ export default {
this.relationGraphOpen = val; this.relationGraphOpen = val;
}, },
openTestTestCase(item) { openTestTestCase(item) {
openCaseEdit({caseId: item.caseId}, this); openCaseEdit({caseId: item.caseId, projectId: item.projectId}, this);
}, },
addPLabel(str) { addPLabel(str) {
return "<p>" + str + "</p>"; return "<p>" + str + "</p>";

View File

@ -81,7 +81,7 @@ export default {
openTestCase() { openTestCase() {
checkProjectPermission(this.testCase.projectId).then((r) => { checkProjectPermission(this.testCase.projectId).then((r) => {
if (r.data) { if (r.data) {
openCaseEdit({caseId: this.testCase.caseId}, this); openCaseEdit({caseId: this.testCase.caseId, projectId: this.testCase.projectId}, this);
} else { } else {
this.$error(this.$t("commons.project_permission")); this.$error(this.$t("commons.project_permission"));
} }

View File

@ -655,12 +655,9 @@ export default {
}, },
handleEdit(testCase, column) { handleEdit(testCase, column) {
let query = { let query = {
caseId: testCase.id,
projectId: testCase.projectId projectId: testCase.projectId
}; };
let path = '/track/case/edit/' + query.caseId; let path = '/track/case/edit/' + testCase.id;
delete query.projectId;
delete query.caseId;
let TestCaseData = this.$router.resolve({ let TestCaseData = this.$router.resolve({
path, path,
query, query,