fix: 脑图创建模块

This commit is contained in:
chenjianxing 2021-11-10 17:42:21 +08:00 committed by jianxing
parent fc39f4fb88
commit 6e23dd467b
4 changed files with 36 additions and 22 deletions

View File

@ -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",

View File

@ -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);

View File

@ -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;

View File

@ -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]);