Commit 21376c80a839d6e828922c9bb4d417f01e893698
1 parent
72c465be
解决 bpm 用户任务的 outgoing 为空的情况~
Showing
2 changed files
with
25 additions
and
4 deletions
yudao-admin-ui/package.json
| ... | ... | @@ -85,7 +85,7 @@ |
| 85 | 85 | "@vue/compiler-sfc": "^3.0.1", |
| 86 | 86 | "@vue/eslint-config-prettier": "^5.0.0", |
| 87 | 87 | "axios": "^0.21.1", |
| 88 | - "bpmn-js": "^8.8.3", | |
| 88 | + "bpmn-js": "8.9.0", | |
| 89 | 89 | "bpmn-js-properties-panel": "^0.37.2", |
| 90 | 90 | "camunda-bpmn-moddle": "^4.4.1", |
| 91 | 91 | "compression-webpack-plugin": "^6.1.1", | ... | ... |
yudao-admin-ui/src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue
| ... | ... | @@ -109,7 +109,7 @@ export default { |
| 109 | 109 | // return true; |
| 110 | 110 | // } |
| 111 | 111 | // }); |
| 112 | - let activityList = this.activityList; | |
| 112 | + const activityList = this.activityList; | |
| 113 | 113 | if (activityList.length === 0) { |
| 114 | 114 | return; |
| 115 | 115 | } |
| ... | ... | @@ -118,6 +118,8 @@ export default { |
| 118 | 118 | let canvas = this.bpmnModeler.get('canvas'); |
| 119 | 119 | let todoActivity = activityList.find(m => !m.endTime) // 找到待办的任务 |
| 120 | 120 | let endActivity = activityList[activityList.length - 1] // 找到结束任务 |
| 121 | + // debugger | |
| 122 | + console.log(this.bpmnModeler.getDefinitions().rootElements[0].flowElements); | |
| 121 | 123 | this.bpmnModeler.getDefinitions().rootElements[0].flowElements?.forEach(n => { |
| 122 | 124 | let activity = activityList.find(m => m.key === n.id) // 找到对应的活动 |
| 123 | 125 | if (n.$type === 'bpmn:UserTask') { // 用户任务 |
| ... | ... | @@ -130,8 +132,9 @@ export default { |
| 130 | 132 | canvas.addMarker(n.id, this.getTaskHighlightCss(task)); |
| 131 | 133 | } |
| 132 | 134 | |
| 133 | - debugger | |
| 134 | - n.outgoing?.forEach(nn => { | |
| 135 | + // 处理 outgoing 出线 | |
| 136 | + const outgoing = this.getActivityOutgoing(activity); | |
| 137 | + outgoing?.forEach(nn => { | |
| 135 | 138 | debugger |
| 136 | 139 | let targetActivity = activityList.find(m => m.key === nn.targetRef.id) |
| 137 | 140 | if (targetActivity) { |
| ... | ... | @@ -212,6 +215,24 @@ export default { |
| 212 | 215 | } |
| 213 | 216 | return ''; |
| 214 | 217 | }, |
| 218 | + getActivityOutgoing(activity) { | |
| 219 | + // 如果有 outgoing,则直接使用它 | |
| 220 | + if (activity.outgoing && activity.outgoing.length > 0) { | |
| 221 | + return activity.outgoing; | |
| 222 | + } | |
| 223 | + // 如果没有,则遍历获得起点为它的【bpmn:SequenceFlow】节点们。原因是:bpmn-js 的 UserTask 拿不到 outgoing | |
| 224 | + const flowElements = this.bpmnModeler.getDefinitions().rootElements[0].flowElements; | |
| 225 | + const outgoing = []; | |
| 226 | + flowElements.forEach(item => { | |
| 227 | + if (item.$type !== 'bpmn:SequenceFlow') { | |
| 228 | + return; | |
| 229 | + } | |
| 230 | + if (item.sourceRef.id === activity.key) { | |
| 231 | + outgoing.push(item); | |
| 232 | + } | |
| 233 | + }); | |
| 234 | + return outgoing; | |
| 235 | + }, | |
| 215 | 236 | initModelListeners() { |
| 216 | 237 | const EventBus = this.bpmnModeler.get("eventBus"); |
| 217 | 238 | const that = this; | ... | ... |