Commit 348762ae6aea60989c31e8fe7d6dcbc8c5b290ea

Authored by YunaiV
1 parent 1425f7df

1. 修复 ProcessViewer 找不到 taskList 报错,= = 变量名改了。

2. 增加事件监听器,悬浮可以展示部分信息
yudao-admin-ui/src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue
@@ -41,6 +41,8 @@ export default { @@ -41,6 +41,8 @@ export default {
41 this.$emit("destroy", this.bpmnModeler); 41 this.$emit("destroy", this.bpmnModeler);
42 this.bpmnModeler = null; 42 this.bpmnModeler = null;
43 }); 43 });
  44 + // 初始模型的监听器
  45 + this.initModelListeners();
44 }, 46 },
45 watch: { 47 watch: {
46 value: function (newValue) { // 在 xmlString 发生变化时,重新创建,从而绘制流程图 48 value: function (newValue) { // 在 xmlString 发生变化时,重新创建,从而绘制流程图
@@ -140,7 +142,7 @@ export default { @@ -140,7 +142,7 @@ export default {
140 if (activity) { 142 if (activity) {
141 canvas.addMarker(n.id, activity.endTime ? 'highlight' : 'highlight-todo') 143 canvas.addMarker(n.id, activity.endTime ? 'highlight' : 'highlight-todo')
142 n.outgoing?.forEach(nn => { 144 n.outgoing?.forEach(nn => {
143 - const targetTask = this.taskList.find(m => m.key === nn.targetRef.id) 145 + const targetTask = activityList.find(m => m.key === nn.targetRef.id)
144 if (targetTask) { 146 if (targetTask) {
145 canvas.addMarker(nn.id, targetTask.endTime ? 'highlight' : 'highlight-todo') 147 canvas.addMarker(nn.id, targetTask.endTime ? 'highlight' : 'highlight-todo')
146 canvas.addMarker(nn.targetRef.id, targetTask.endTime ? 'highlight' : 'highlight-todo') 148 canvas.addMarker(nn.targetRef.id, targetTask.endTime ? 'highlight' : 'highlight-todo')
@@ -166,7 +168,41 @@ export default { @@ -166,7 +168,41 @@ export default {
166 } 168 }
167 } 169 }
168 }) 170 })
169 - } 171 + },
  172 + initModelListeners() {
  173 + const EventBus = this.bpmnModeler.get("eventBus");
  174 + const that = this;
  175 + // 注册需要的监听事件, 将. 替换为 - , 避免解析异常
  176 + EventBus.on('element.hover', function(eventObj) {
  177 + let element = eventObj ? eventObj.element : null;
  178 + that.elementHover(element);
  179 + });
  180 + EventBus.on('element.out', function(eventObj) {
  181 + let element = eventObj ? eventObj.element : null;
  182 + that.elementOut(element);
  183 + });
  184 + },
  185 + // 流程图的元素被 hover
  186 + elementHover(element) {
  187 + this.element = element;
  188 + !this.elementOverlayIds && (this.elementOverlayIds = {});
  189 + !this.overlays && (this.overlays = this.bpmnModeler.get("overlays"));
  190 + // 展示信息
  191 + if (!this.elementOverlayIds[element.id] && element.type !== "bpmn:Process") {
  192 + this.elementOverlayIds[element.id] = this.overlays.add(element, {
  193 + position: { left: 0, bottom: 0 },
  194 + html: `<div class="element-overlays">
  195 + <p>Elemet id: ${element.id}</p>
  196 + <p>Elemet type: ${element.type}</p>
  197 + </div>`
  198 + });
  199 + }
  200 + },
  201 + // 流程图的元素被 out
  202 + elementOut(element) {
  203 + this.overlays.remove({ element });
  204 + this.elementOverlayIds[element.id] = null;
  205 + },
170 } 206 }
171 }; 207 };
172 </script> 208 </script>
yudao-admin-ui/src/views/bpm/processInstance/detail.vue
@@ -68,7 +68,8 @@ @@ -68,7 +68,8 @@
68 </div> 68 </div>
69 </el-col> 69 </el-col>
70 </el-card> 70 </el-card>
71 - <!-- TODO 流程图 --> 71 +
  72 + <!-- 高亮流程图 -->
72 <el-card class="box-card" v-loading="processInstanceLoading"> 73 <el-card class="box-card" v-loading="processInstanceLoading">
73 <div slot="header" class="clearfix"> 74 <div slot="header" class="clearfix">
74 <span class="el-icon-picture-outline">流程图</span> 75 <span class="el-icon-picture-outline">流程图</span>