工作流部分数据重构

This commit is contained in:
Binlin B Wang 2022-08-14 23:10:04 +08:00
parent c3268b5511
commit 5a6a4f6db3
1 changed files with 4 additions and 83 deletions

View File

@ -52,16 +52,11 @@ export default {
if (!(node && node.id)) {
return []
}
console.log(node.name, "node.name", node.id, "node.id")
if (this.isPrimaryNode(node)) {
//
console.log("node name", node.name, "id", node.id, "parentId", node.parentId)
let childDoms = this.getDomTree(h, node.id)
this.decodeAppendDom(h, node, childDoms)
return [h('div', {'class': {'primary-node': true}}, childDoms)];
} else if (this.isBranchNode(node)) {
let index = 0;
//
@ -97,52 +92,6 @@ export default {
}
return []
},
getDomTreeOld(h, node) {
this.toMapping(node);
if (this.isPrimaryNode(node)) {
//
let childDoms = this.getDomTreeOld(h, node.children)
this.decodeAppendDom(h, node, childDoms)
return [h('div', {'class': {'primary-node': true}}, childDoms)];
} else if (this.isBranchNode(node)) {
let index = 0;
//
let branchItems = node.branchs.map(branchNode => {
//
this.toMapping(branchNode);
let childDoms = this.getDomTreeOld(h, branchNode.children)
this.decodeAppendDom(h, branchNode, childDoms, {level: index + 1, size: node.branchs.length})
//4线线
this.insertCoverLine(h, index, childDoms, node.branchs)
//
index++;
return h('div', {'class': {'branch-node-item': true}}, childDoms);
})
///
branchItems.unshift(h('div', {'class': {'add-branch-btn': true}}, [
h('el-button', {
'class': {'add-branch-btn-el': true},
props: {size: 'small', round: true},
on: {click: () => this.addBranchNode(node)},
domProps: {innerHTML: `添加${this.isConditionNode(node) ? '条件' : '分支'}`},
}, [])
]));
let bchDom = [h('div', {'class': {'branch-node': true}}, branchItems)]
//
let afterChildDoms = this.getDomTreeOld(h, node.children)
return [h('div', {}, [bchDom, afterChildDoms])]
} else if (this.isEmptyNode(node)) {
//
let childDoms = this.getDomTreeOld(h, node.children)
this.decodeAppendDom(h, node, childDoms)
return [h('div', {'class': {'empty-node': true}}, childDoms)];
} else {
//
return [];
}
},
//dom
decodeAppendDom(h, node, dom, props = {}) {
props.config = node
@ -171,7 +120,6 @@ export default {
//idmap
toMapping(node) {
if (node && node.id) {
//console.log("node=> " + node.id + " name:" + node.name + " type:" + node.type)
let newNode = {
...node
}
@ -205,7 +153,7 @@ export default {
parentNode.branchs.splice(parentNode.branchs.indexOf(node), 0, branchNode)
this.$forceUpdate()
},
//
//
branchMove(node, offset) {
let parentNode = this.nodeMap.get(node.parentId)
let index = parentNode.branchs.indexOf(node)
@ -250,15 +198,12 @@ export default {
//
insertNode(type, parentNode) {
this.$refs['_root'].click()
//
console.log(parentNode)
//
let id = this.getRandomId();
this.updateParentId(id, parentNode.id)
let children = {
id: id,
parentId: parentNode.id,
// props: {},
type: type,
}
switch (type) {
@ -417,12 +362,6 @@ export default {
this.dom.push(emptyNode)
},
getBranchEndNode(conditionNode) {
if (!conditionNode.children || !conditionNode.children.id) {
return conditionNode;
}
return this.getBranchEndNode(conditionNode.children);
},
addBranchNode(node) {
if (node.branchs.length < 8) {
node.branchs.push({
@ -438,7 +377,6 @@ export default {
}
},
//
delNode(node) {
//
@ -494,7 +432,7 @@ export default {
//id
this.updateParentId(parentNode.parentId,sunNode.parentId)
//
let lastNode = this.getLastNode(sunNode.id)
let lastNode = this.getLastBranchNode(sunNode.id)
let emptyNode = this.parentMap.get(parentNode.id)
//id
this.updateParentId(lastNode.id,emptyNode.id)
@ -511,10 +449,10 @@ export default {
}
},
//
getLastNode(id){
getLastBranchNode(id){
let node = this.parentMap.get(id)
if (node){
return this.getLastNode(node.id)
return this.getLastBranchNode(node.id)
}else {
return this.nodeMap.get(id)
}
@ -582,23 +520,6 @@ export default {
}
})
},
validateOld(err, node) {
if (this.isPrimaryNode(node)) {
this.validateNode(err, node)
this.validate(err, node.children)
} else if (this.isBranchNode(node)) {
//
node.branchs.map(branchNode => {
//
this.validateNode(err, branchNode)
//
this.validate(err, branchNode.children)
})
this.validate(err, node.children)
} else if (this.isEmptyNode(node)) {
this.validate(err, node.children)
}
}
},
watch: {}
}