| | |
| | | }, |
| | | getRandomId(){ |
| | | console.log("tree生成节点id") |
| | | return ''; |
| | | return ' '; |
| | | //return `HighDatas_${new Date().getTime().toString().substring(5)}${Math.round(Math.random()*9000+1000)}` |
| | | }, |
| | | //选中一个节点 |
| | |
| | | }, |
| | | //处理节点插入逻辑 |
| | | insertNode(type, parentNode){ |
| | | console.log("insertNode-parentNode",parentNode) |
| | | this.$refs['_root'].click() |
| | | //缓存一下后面的节点 |
| | | let afterNode = parentNode.children |
| | | console.log("afterNode",afterNode) |
| | | //插入新节点 |
| | | parentNode.children = { |
| | | id: this.getRandomId(), |
| | | parentId: parentNode.id, |
| | | props: {}, |
| | | type: type, |
| | | type: type |
| | | |
| | | } |
| | | switch (type){ |
| | | case 'APPROVAL': this.insertApprovalNode(parentNode, afterNode); break; |
| | |
| | | if (afterNode && afterNode.id){ |
| | | afterNode.parentId = parentNode.children.id |
| | | } |
| | | this.$set(parentNode.children, 'children', afterNode) |
| | | this.$set(parentNode.children, 'children', Object) |
| | | console.log("parentNode.children",parentNode.children) |
| | | } |
| | | 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)) |
| | | console.log("parentNode.children",parentNode.children) |
| | | }, |
| | | insertTaskNode(parentNode){ |
| | | this.$set(parentNode.children, "name", "办理人") |