| | |
| | | import Subprocess from '@/views/common/process/nodes/SubprocessNode.vue' |
| | | |
| | | import DefaultProps from "./DefaultNodeProps" |
| | | |
| | | export default { |
| | | name: "ProcessTree", |
| | | components: {Node, Root, Approval, Task, Cc, Trigger, Concurrent, Condition, Inclusive, Delay, Empty, Subprocess}, |
| | |
| | | ])) |
| | | return h('div', {class:{'_root': true}, ref:'_root'}, processTrees) |
| | | }, |
| | | |
| | | methods: { |
| | | getDomTree(h, node) { |
| | | this.toMapping(node); |
| | |
| | | //解码渲染的时候插入dom到同级 |
| | | decodeAppendDom(h, node, dom, props = {}){ |
| | | props.config = node |
| | | console.log("decodeAppendDom",props) |
| | | dom.unshift(h(node.type.toLowerCase(), { |
| | | props: props, |
| | | ref: node.id, |
| | |
| | | //id映射到map,用来向上遍历 |
| | | toMapping(node){ |
| | | if (node && node.id){ |
| | | //console.log("node=> " + node.id + " name:" + node.name + " type:" + node.type) |
| | | this.nodeMap.set(node.id, node) |
| | | } |
| | | }, |
| | |
| | | return node.type === 'CONCURRENTS' |
| | | }, |
| | | getRandomId(){ |
| | | console.log("tree生成节点id") |
| | | return ''; |
| | | return ' '; |
| | | //return `HighDatas_${new Date().getTime().toString().substring(5)}${Math.round(Math.random()*9000+1000)}` |
| | | }, |
| | | //选中一个节点 |
| | | selectNode(node){ |
| | | this.$store.commit('selectedNode', node) |
| | | this.$store.commit('selectedNode', node); |
| | | this.$emit('selectedNode', node) |
| | | }, |
| | | //处理节点插入逻辑 |
| | | insertNode(type, parentNode){ |
| | | |
| | | this.$refs['_root'].click() |
| | | //缓存一下后面的节点 |
| | | let afterNode = parentNode.children |
| | | //插入新节点 |
| | | parentNode.children = { |
| | | |
| | | id: this.getRandomId(), |
| | | parentId: parentNode.id, |
| | | props: {}, |
| | | type: type, |
| | | type: type |
| | | |
| | | } |
| | | switch (type){ |
| | | |
| | | case 'APPROVAL': this.insertApprovalNode(parentNode, afterNode); break; |
| | | case 'SUBPROCESS' : this.insertApprovalNode(parentNode, afterNode); break; |
| | | case 'TASK': this.insertTaskNode(parentNode); break; |
| | |
| | | if (afterNode && afterNode.id){ |
| | | afterNode.parentId = parentNode.children.id |
| | | } |
| | | this.$set(parentNode.children, 'children', afterNode) |
| | | this.$set(parentNode.children, 'children', Object) |
| | | |
| | | } |
| | | this.$forceUpdate() |
| | | }, |
| | | insertApprovalNode(parentNode){ |
| | | console.log("tree 添加通过节点",parentNode.children) |
| | | this.$set(parentNode.children, "name", "审批人") |
| | | console.log("tree-DefaultProps.APPROVAL_PROPS)",DefaultProps.APPROVAL_PROPS) |
| | | |
| | | this.$set(parentNode.children, "props", this.$deepCopy(DefaultProps.APPROVAL_PROPS)) |
| | | |
| | | |
| | | }, |
| | | insertTaskNode(parentNode){ |
| | | this.$set(parentNode.children, "name", "办理人") |
| | |
| | | name: "条件1", |
| | | children:{} |
| | | },{ |
| | | |
| | | id: this.getRandomId(), |
| | | parentId: parentNode.children.id, |
| | | type: "CONDITION", |
| | |
| | | }, |
| | | //删除当前节点 |
| | | delNode(node){ |
| | | console.log("ProcessTree删除节点", node) |
| | | |
| | | //获取该节点的父节点 |
| | | let parentNode = this.nodeMap.get(node.parentId) |
| | | if (parentNode){ |