fix: 模块树拖拽

This commit is contained in:
chenjianxing 2020-08-05 10:13:56 +08:00
parent bca1ef13cb
commit 7de5205b99
2 changed files with 14 additions and 7 deletions

View File

@ -415,7 +415,7 @@ public class TestCaseNodeService {
List<TestCaseNode> updateNodes = new ArrayList<>(); List<TestCaseNode> updateNodes = new ArrayList<>();
buildUpdateTestCase(nodeTree, testCases, updateNodes, "/", null, 1); buildUpdateTestCase(nodeTree, testCases, updateNodes, "/", "0", 1);
updateNodes = updateNodes.stream() updateNodes = updateNodes.stream()
.filter(item -> nodeIds.contains(item.getId())) .filter(item -> nodeIds.contains(item.getId()))

View File

@ -107,6 +107,16 @@ export default {
}, },
methods: { methods: {
handleDragEnd(draggingNode, dropNode, dropType, ev) { handleDragEnd(draggingNode, dropNode, dropType, ev) {
let param = this.buildParam(draggingNode, dropNode, dropType);
console.log(this.treeNodes);
this.$post("/case/node/drag", param, () => {
draggingNode.data.level = param.level;
this.refreshTable();
}, (error) => {
this.refreshNode();
});
},
buildParam(draggingNode, dropNode, dropType) {
let param = {}; let param = {};
param.id = draggingNode.data.id; param.id = draggingNode.data.id;
param.name = draggingNode.data.name; param.name = draggingNode.data.name;
@ -115,7 +125,7 @@ export default {
param.parentId = dropNode.data.id; param.parentId = dropNode.data.id;
param.level = dropNode.data.level + 1; param.level = dropNode.data.level + 1;
} else { } else {
if (dropNode.parent.id === 0) { if (!dropNode.parent.id || dropNode.parent.id === 0) {
param.parentId = 0; param.parentId = 0;
param.level = 1; param.level = 1;
} else { } else {
@ -135,12 +145,9 @@ export default {
} }
} }
} }
param.nodeIds = nodeIds; param.nodeIds = nodeIds;
this.$post("/case/node/drag", param, () => { return param;
this.refreshTable();
}, (error) => {
this.refreshNode();
});
}, },
refreshTable() { refreshTable() {
this.$emit('refreshTable'); this.$emit('refreshTable');