diff --git a/test-track/frontend/src/business/case/components/TestCaseEdit.vue b/test-track/frontend/src/business/case/components/TestCaseEdit.vue index a5b27d9254..3c172d1cfa 100644 --- a/test-track/frontend/src/business/case/components/TestCaseEdit.vue +++ b/test-track/frontend/src/business/case/components/TestCaseEdit.vue @@ -635,7 +635,10 @@ export default { return this.isAdd || this.editableState; }, isCopy() { - return this.editType == 'copy'; + return this.editType === 'copy' || this.isPublicCopy; + }, + isPublicCopy() { + return this.editType === 'publicCopy'; }, showPublic() { return this.isPublic && this.isXpack; @@ -838,7 +841,7 @@ export default { }, copyPublicCase() { // 这里复制使用当前项目,不使用 projectId ,可能没有权限 - openCaseEdit({caseId: this.caseId, type: 'copy', projectId: getCurrentProjectID()}, this); + openCaseEdit({caseId: this.caseId, type: 'publicCopy', projectId: getCurrentProjectID()}, this); }, closePublicCase() { this.$emit("close"); @@ -998,9 +1001,6 @@ export default { document.title = this.$t('test_track.case.create_case'); let user = JSON.parse(localStorage.getItem(TokenKey)); - this.form.priority = "P3"; - this.form.type = "functional"; - this.form.method = "manual"; this.form.maintainer = user.id; this.form.tags = []; this.form.versionId = this.initLatestVersionId; @@ -1127,6 +1127,12 @@ export default { } this.casePublic = tmp.casePublic; + if (this.isPublicCopy) { + // 如果是 copy 用例库的用例,责任人设置成当前用户 + let user = JSON.parse(localStorage.getItem(TokenKey)); + this.form.maintainer = user.id; + } + //设置自定义熟悉默认值 this.customFieldForm = parseCustomField( this.form, @@ -1140,7 +1146,7 @@ export default { this.reloadForm(); }, resetSystemField() { - if (this.operationType === "add") { + if (!this.caseId) { return; } // 用例等级等字段以表中对应字段为准,后端复杂操作直接改表中对应字段即可 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 8c5fba39cd..5091f9f88d 100644 --- a/test-track/frontend/src/business/case/components/case/CaseBaseInfo.vue +++ b/test-track/frontend/src/business/case/components/case/CaseBaseInfo.vue @@ -496,21 +496,37 @@ export default { // 创建时设置选中的模块 this.form.nodeId = this.createNodeId; let node = this.findTreeNode(treeNodes); - this.form.nodePath = node ? node.path : ''; + if (node) { + this.form.nodePath = node.path; + } else { + // 如果模块已删除,设置为未规划模块 + this.setUnplannedModule(treeNodes); + } } else { // 创建不带模块ID,设置成为规划模块 - this.form.nodeId = treeNodes[0].id; - this.form.nodePath = treeNodes[0].path; + this.setUnplannedModule(treeNodes); } } } else { if (this.form.nodeId) { // 编辑重新设置下 nodePath let node = this.findTreeNode(treeNodes); - this.form.nodePath = node ? node.path : ''; + if (node) { + this.form.nodePath = node.path; + } else { + // 如果模块已删除,或者跨项目复制公共用例,设置为未规划模块 + this.setUnplannedModule(treeNodes); + } + } else { + this.setUnplannedModule(treeNodes); } } }, + setUnplannedModule(treeNodes) { + // 创建不带模块ID,设置成为规划模块 + this.form.nodeId = treeNodes[0].id; + this.form.nodePath = treeNodes[0].path; + }, getNodeTrees() { if (this.publicEnable || !this.projectId) { return; diff --git a/test-track/frontend/src/business/module/TestCasePublicNodeTree.vue b/test-track/frontend/src/business/module/TestCasePublicNodeTree.vue index 75db1c5998..e3bcbcd62a 100644 --- a/test-track/frontend/src/business/module/TestCasePublicNodeTree.vue +++ b/test-track/frontend/src/business/module/TestCasePublicNodeTree.vue @@ -1,5 +1,5 @@