From 6e23dd467b7ad7c6ca57a46b178a35024f605f35 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 10 Nov 2021 17:42:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=84=91=E5=9B=BE=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package.json | 2 +- .../track/case/components/TestCaseEdit.vue | 9 +++---- .../track/common/minder/TestCaseMinder.vue | 26 ++++++++++++++----- .../track/common/minder/minderUtils.js | 21 ++++++++------- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 8aabb05eea..04abffbcf9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -54,7 +54,7 @@ "vue-float-action-button": "^0.6.6", "vue-i18n": "^8.15.3", "vue-jsonpath-picker": "^1.1.5", - "vue-minder-editor-plus": "1.0.33", + "vue-minder-editor-plus": "1.0.35", "vue-papa-parse": "^2.0.0", "vue-pdf": "^4.2.0", "vue-router": "^3.1.3", diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index bbcb60df5b..2ed2ce8a08 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -660,15 +660,14 @@ this.$emit("refreshTestCase",); //this.tableType = 'edit'; this.$emit("refresh", this.form); - this.form.id = response.data.id; - - if (this.type === 'add' || this.type === 'copy') { + if (this.form.id) { + this.$emit("caseEdit", param); + } else { param.id = response.data.id; this.$emit("caseCreate", param); this.close(); - } else { - this.$emit("caseEdit", param); } + this.form.id = response.data.id; if (callback) { callback(this); diff --git a/frontend/src/business/components/track/common/minder/TestCaseMinder.vue b/frontend/src/business/components/track/common/minder/TestCaseMinder.vue index 8afc87444b..121c9a265e 100644 --- a/frontend/src/business/components/track/common/minder/TestCaseMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestCaseMinder.vue @@ -22,7 +22,7 @@ import MsModuleMinder from "@/business/components/common/components/MsModuleMind import { getChildNodeId, handleAfterSave, - handleExpandToLevel, handleTestCaseAdd, handTestCaeEdit, + handleExpandToLevel, handleTestCaseAdd, handTestCaeEdit, isModuleNode, isModuleNodeData, listenBeforeExecCommand, listenDblclick, listenNodeSelected, loadSelectNodes, @@ -181,6 +181,12 @@ name: "TestCaseMinder", if (data.type !== 'tmp' && data.changed) { if (data.contextChanged && data.resource && data.resource.indexOf(this.$t('test_track.module.module')) > -1) { this.buildSaveModules(root, data, parent); + root.children && root.children.forEach(i => { + if (isModuleNode(i)) { + i.data.changed = true; + i.data.contextChanged = true; // 如果当前节点有变化,下面的模块节点也需要level也可能需要变化 + } + }); } else { // 保存临时节点 this.buildExtraNode(data, parent, root); @@ -190,15 +196,15 @@ name: "TestCaseMinder", if (root.children) { for (let i = 0; i < root.children.length; i++) { let childNode = root.children[i]; - let preNode = null; - let nextNode = null; + let preNodeTmp = null; + let nextNodeTmp = null; if (i != 0) { - preNode = root.children[i - 1]; + preNodeTmp = root.children[i - 1]; } if (i + 1 < root.children.length) { - nextNode = root.children[i + 1]; + nextNodeTmp = root.children[i + 1]; } - this.buildSaveParam(childNode, root.data, preNode, nextNode); + this.buildSaveParam(childNode, root.data, preNodeTmp, nextNodeTmp); } } } @@ -209,10 +215,16 @@ name: "TestCaseMinder", } let pId = parent ? (parent.newId ? parent.newId : parent.id) : null; + if (!isModuleNodeData(parent)) { + let tip = data.text + '不能创建非模块节点下'; + this.$error(tip) + throw new Error(tip); + } + let module = { id: data.id, name: data.text, - level: data.level ? data.level : (parent.level + 1), + level: parent.level + 1, parentId: pId }; data.level = module.level; diff --git a/frontend/src/business/components/track/common/minder/minderUtils.js b/frontend/src/business/components/track/common/minder/minderUtils.js index 4cd805a8f8..d532941ed3 100644 --- a/frontend/src/business/components/track/common/minder/minderUtils.js +++ b/frontend/src/business/components/track/common/minder/minderUtils.js @@ -1,6 +1,4 @@ import i18n from "@/i18n/i18n"; -import {getTestCasesForMinder} from "@/network/testCase"; -import {getMinderExtraNode} from "@/network/testCase"; import {getCurrentProjectID} from "../../../../../common/js/utils"; export function listenNodeSelected(callback) { @@ -356,9 +354,13 @@ export function tagBatch(distinctTags) { }); } -function parentIsModule(parentNode) { - let lastNodeResource = parentNode ? parentNode.data.resource : null; - return parentNode.data.type === 'node' || (lastNodeResource && lastNodeResource.indexOf('模块') > -1); +export function isModuleNode(node) { + return isModuleNodeData(node.data); +} + +export function isModuleNodeData(data) { + let resource = data ? data.resource : null; + return data.type === 'node' || (resource && resource.indexOf(i18n.t('test_track.module.module')) > -1); } export function tagEditCheck(resourceName) { @@ -369,12 +371,12 @@ export function tagEditCheck(resourceName) { if (type === 'case' || type === 'node') {// 已存在的模块和用例不能修改标签 return false; } - let parentIsModuleNode = parentIsModule(selectNodes[0].getParent()); - if (resourceName === '用例' && !parentIsModuleNode) { + let parentIsModuleNode = isModuleNode(selectNodes[0].getParent()); + if (resourceName === i18n.t('api_test.definition.request.case') && !parentIsModuleNode) { return false; } // 父节点必须是模块 - if (resourceName === '模块' && !parentIsModuleNode) { + if (resourceName === i18n.t('test_track.module.module') && !parentIsModuleNode) { return false; } } @@ -388,7 +390,7 @@ export function priorityDisableCheck() { if (selectNodes && selectNodes.length > 0) { let parentNode = selectNodes[0].getParent(); let resource = parentNode ? parentNode.data.resource : null; - if (resource && resource.indexOf('用例') > -1) { + if (resource && resource.indexOf(i18n.t('api_test.definition.request.case')) > -1) { return true; } } @@ -402,6 +404,7 @@ export function handleAfterSave(rootNode) { } rootNode.data.deleteChild = null; rootNode.data.changed = false; + rootNode.data.contextChanged = false; if (rootNode.children) { for (let i = 0; i < rootNode.children.length; i++) { handleAfterSave(rootNode.children[i]);