From 21376c80a839d6e828922c9bb4d417f01e893698 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 20 Jan 2022 23:52:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20bpm=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=20outgoing=20=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-ui/package.json | 2 +- .../package/designer/ProcessViewer.vue | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/yudao-admin-ui/package.json b/yudao-admin-ui/package.json index f2d9145aa..9e01ad04f 100644 --- a/yudao-admin-ui/package.json +++ b/yudao-admin-ui/package.json @@ -85,7 +85,7 @@ "@vue/compiler-sfc": "^3.0.1", "@vue/eslint-config-prettier": "^5.0.0", "axios": "^0.21.1", - "bpmn-js": "^8.8.3", + "bpmn-js": "8.9.0", "bpmn-js-properties-panel": "^0.37.2", "camunda-bpmn-moddle": "^4.4.1", "compression-webpack-plugin": "^6.1.1", diff --git a/yudao-admin-ui/src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue b/yudao-admin-ui/src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue index ce0681432..9fbf08fec 100644 --- a/yudao-admin-ui/src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue +++ b/yudao-admin-ui/src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue @@ -109,7 +109,7 @@ export default { // return true; // } // }); - let activityList = this.activityList; + const activityList = this.activityList; if (activityList.length === 0) { return; } @@ -118,6 +118,8 @@ export default { let canvas = this.bpmnModeler.get('canvas'); let todoActivity = activityList.find(m => !m.endTime) // 找到待办的任务 let endActivity = activityList[activityList.length - 1] // 找到结束任务 + // debugger + console.log(this.bpmnModeler.getDefinitions().rootElements[0].flowElements); this.bpmnModeler.getDefinitions().rootElements[0].flowElements?.forEach(n => { let activity = activityList.find(m => m.key === n.id) // 找到对应的活动 if (n.$type === 'bpmn:UserTask') { // 用户任务 @@ -130,8 +132,9 @@ export default { canvas.addMarker(n.id, this.getTaskHighlightCss(task)); } - debugger - n.outgoing?.forEach(nn => { + // 处理 outgoing 出线 + const outgoing = this.getActivityOutgoing(activity); + outgoing?.forEach(nn => { debugger let targetActivity = activityList.find(m => m.key === nn.targetRef.id) if (targetActivity) { @@ -212,6 +215,24 @@ export default { } return ''; }, + getActivityOutgoing(activity) { + // 如果有 outgoing,则直接使用它 + if (activity.outgoing && activity.outgoing.length > 0) { + return activity.outgoing; + } + // 如果没有,则遍历获得起点为它的【bpmn:SequenceFlow】节点们。原因是:bpmn-js 的 UserTask 拿不到 outgoing + const flowElements = this.bpmnModeler.getDefinitions().rootElements[0].flowElements; + const outgoing = []; + flowElements.forEach(item => { + if (item.$type !== 'bpmn:SequenceFlow') { + return; + } + if (item.sourceRef.id === activity.key) { + outgoing.push(item); + } + }); + return outgoing; + }, initModelListeners() { const EventBus = this.bpmnModeler.get("eventBus"); const that = this;