mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 21:19:52 +08:00
fix: 脑图复制粘贴新增失败
This commit is contained in:
parent
9ea5c34c85
commit
0b828f4423
@ -52,7 +52,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.26",
|
||||
"vue-minder-editor-plus": "^1.0.27",
|
||||
"vue-papa-parse": "^2.0.0",
|
||||
"vue-pdf": "^4.2.0",
|
||||
"vue-router": "^3.1.3",
|
||||
|
@ -18,6 +18,7 @@
|
||||
<script>
|
||||
import MsModuleMinder from "@/business/components/common/components/MsModuleMinder";
|
||||
import {
|
||||
handleAfterSave,
|
||||
handleExpandToLevel, handleTestCaseAdd, handTestCaeEdit,
|
||||
listenBeforeExecCommand,
|
||||
listenNodeSelected,
|
||||
@ -81,29 +82,24 @@ name: "TestCaseMinder",
|
||||
methods: {
|
||||
handleAfterMount() {
|
||||
listenNodeSelected(() => {
|
||||
let param = {
|
||||
request: {
|
||||
projectId: this.projectId,
|
||||
},
|
||||
result: this.result,
|
||||
isDisable: false
|
||||
}
|
||||
loadSelectNodes(param, getTestCasesForMinder);
|
||||
loadSelectNodes(this.getParam(), getTestCasesForMinder);
|
||||
});
|
||||
listenBeforeExecCommand((even) => {
|
||||
if (even.commandName === 'expandtolevel') {
|
||||
let level = Number.parseInt(even.commandArgs);
|
||||
let param = {
|
||||
request: {
|
||||
projectId: this.projectId,
|
||||
},
|
||||
result: this.result,
|
||||
isDisable: false
|
||||
}
|
||||
handleExpandToLevel(level, even.minder.getRoot(), param, getTestCasesForMinder);
|
||||
handleExpandToLevel(level, even.minder.getRoot(), this.getParam(), getTestCasesForMinder);
|
||||
}
|
||||
});
|
||||
},
|
||||
getParam() {
|
||||
return {
|
||||
request: {
|
||||
projectId: this.projectId,
|
||||
},
|
||||
result: this.result,
|
||||
isDisable: false
|
||||
}
|
||||
},
|
||||
save(data) {
|
||||
let saveCases = [];
|
||||
let deleteCases = [];
|
||||
@ -115,6 +111,7 @@ name: "TestCaseMinder",
|
||||
}
|
||||
this.result = this.$post('/test/case/minder/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
handleAfterSave(window.minder.getRoot(), this.getParam());
|
||||
});
|
||||
},
|
||||
buildSaveCase(root, saveCases, deleteCases, parent) {
|
||||
@ -126,10 +123,15 @@ name: "TestCaseMinder",
|
||||
if (deleteChild && deleteChild.length > 0) {
|
||||
deleteCases.push(...deleteChild);
|
||||
}
|
||||
if (data.type !== 'node') {
|
||||
let tip = '用例(' + data.text + ')未添加用例标签!';
|
||||
this.$error(tip)
|
||||
throw new Error(tip);
|
||||
}
|
||||
if (root.children) {
|
||||
root.children.forEach((childNode) => {
|
||||
this.buildSaveCase(childNode, saveCases, deleteCases, root.data);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,4 +1,5 @@
|
||||
import i18n from "@/i18n/i18n";
|
||||
import {getTestCasesForMinder} from "@/network/testCase";
|
||||
|
||||
export function listenNodeSelected(callback) {
|
||||
let minder = window.minder;
|
||||
@ -222,7 +223,7 @@ function getNodeData(text, resource, isDisable) {
|
||||
* @param result
|
||||
*/
|
||||
export function appendCaseNodes(parent, testCases, param, setParamCallback) {
|
||||
wipeTmp(parent);
|
||||
clearChildren(parent);
|
||||
if (testCases) {
|
||||
for (let i = 0; i < testCases.length; i++) {
|
||||
appendCase(parent, testCases[i], param.isDisable, setParamCallback);
|
||||
@ -235,17 +236,17 @@ export function appendCaseNodes(parent, testCases, param, setParamCallback) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 去掉临时节点
|
||||
* 去掉已有节点
|
||||
* @param parent
|
||||
*/
|
||||
function wipeTmp(node) {
|
||||
function clearChildren(node) {
|
||||
let children = node.children;
|
||||
if (children) {
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let item = children[i];
|
||||
if (item.data.type === 'tmp') {
|
||||
if (item.data.type !== 'node') {
|
||||
window.minder.removeNode(item);
|
||||
break;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -334,3 +335,23 @@ export function priorityDisableCheck() {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function handleAfterSave(pNode, param) {
|
||||
let children = pNode.children;
|
||||
if (children) {
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let item = children[i];
|
||||
if (item.data.id === null || (item.data.id && item.data.id.length < 20)) {
|
||||
pNode.data.loaded = false;
|
||||
loadNode(pNode, param, getTestCasesForMinder);
|
||||
return;
|
||||
}
|
||||
if (item.data.changed) {
|
||||
item.data.changed = false;
|
||||
}
|
||||
if (item.data.type === 'node') {
|
||||
handleAfterSave(item, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user