优化 bpm 高亮流程图的前端

This commit is contained in:
YunaiV 2022-01-20 01:14:10 +08:00
parent 348762ae6a
commit 5332e543d2
2 changed files with 83 additions and 57 deletions

View File

@ -14,25 +14,34 @@ export default {
name: "MyProcessViewer",
componentName: "MyProcessViewer",
props: {
value: String, // xml
prefix: {
value: { // BPMN XML
type: String,
default: "camunda"
},
taskData: {
prefix: { // 使
type: String,
default: "camunda",
},
activityData: { //
type: Array,
default: () => []
default: () => [],
},
processInstanceData: { //
type: Object,
},
taskData: { // UserTask
type: Array,
default: () => [],
}
},
data() {
return {
xml: '',
tasks: [],
activityList: [],
};
},
mounted() {
this.xml = this.value;
this.tasks = this.taskData;
this.activityList = this.activityData;
//
this.initBpmnModeler();
this.createNewDiagram(this.xml);
@ -49,8 +58,8 @@ export default {
this.xml = newValue;
this.createNewDiagram(this.xml);
},
taskData: function (newTaskData) {
this.tasks = newTaskData;
activityData: function (newActivityData) {
this.activityList = newActivityData;
this.createNewDiagram(this.xml);
}
},
@ -83,8 +92,9 @@ export default {
}
},
/* 高亮流程图 */
// TODO endActivity https://www.jdon.com/workflow/multi-events.html
async highlightDiagram() {
let activityList = this.tasks;
let activityList = this.activityList;
if (activityList.length === 0) {
return;
}
@ -99,6 +109,7 @@ export default {
if (!activity) {
return;
}
// TODO
if (activity.task) {
const result = activity.task.result;
if (result === 1) {
@ -111,16 +122,17 @@ export default {
canvas.addMarker(n.id, 'highlight-cancel');
}
}
n.outgoing?.forEach(nn => {
let targetTask = activityList.find(m => m.key === nn.targetRef.id)
if (targetTask) {
canvas.addMarker(nn.id, targetTask.endTime ? 'highlight' : 'highlight-todo');
let targetActivity = activityList.find(m => m.key === nn.targetRef.id)
if (targetActivity) {
debugger
canvas.addMarker(nn.id, targetActivity.endTime ? 'highlight' : 'highlight-todo');
} else if (nn.targetRef.$type === 'bpmn:ExclusiveGateway') {
// canvas.addMarker(nn.id, 'highlight');
debugger
canvas.addMarker(nn.id, activity.endTime ? 'highlight' : 'highlight-todo');
canvas.addMarker(nn.targetRef.id, activity.endTime ? 'highlight' : 'highlight-todo');
} else if (nn.targetRef.$type === 'bpmn:EndEvent') {
debugger
if (!todoActivity && endActivity.key === n.id) {
canvas.addMarker(nn.id, 'highlight');
canvas.addMarker(nn.targetRef.id, 'highlight');
@ -133,28 +145,33 @@ export default {
});
} else if (n.$type === 'bpmn:ExclusiveGateway') { //
n.outgoing?.forEach(nn => {
let targetTask = activityList.find(m => m.key === nn.targetRef.id)
let targetTask = activityList.find(m => m.key === nn.targetRef.id);
if (targetTask) {
canvas.addMarker(nn.id, targetTask.endTime ? 'highlight' : 'highlight-todo');
}
})
} else if (n.$type === 'bpmn:ParallelGateway') { //
if (activity) {
canvas.addMarker(n.id, activity.endTime ? 'highlight' : 'highlight-todo')
n.outgoing?.forEach(nn => {
const targetTask = activityList.find(m => m.key === nn.targetRef.id)
if (targetTask) {
canvas.addMarker(nn.id, targetTask.endTime ? 'highlight' : 'highlight-todo')
canvas.addMarker(nn.targetRef.id, targetTask.endTime ? 'highlight' : 'highlight-todo')
}
})
if (!activity) {
return
}
// bpmn:ParallelGateway
canvas.addMarker(n.id, this.getActivityHighlightCss(activity));
n.outgoing?.forEach(nn => {
// 线
const targetActivity = activityList.find(m => m.key === nn.targetRef.id)
if (targetActivity) {
canvas.addMarker(nn.id, this.getActivityHighlightCss(targetActivity)); // bpmn:SequenceFlow线
// ... ... bpm:UserTask bpm:UserTask
canvas.addMarker(nn.targetRef.id, this.getActivityHighlightCss(targetActivity));
}
})
} else if (n.$type === 'bpmn:StartEvent') { //
n.outgoing?.forEach(nn => { // outgoing bpmn:SequenceFlow线
let fromTask = activityList.find(m => m.key === nn.targetRef.id)
if (fromTask) {
canvas.addMarker(nn.id, 'highlight');
canvas.addMarker(n.id, 'highlight');
// 线
let targetActivity = activityList.find(m => m.key === nn.targetRef.id);
if (targetActivity) {
canvas.addMarker(nn.id, 'highlight'); // bpmn:SequenceFlow线
canvas.addMarker(n.id, 'highlight'); // bpmn:StartEvent
}
});
} else if (n.$type === 'bpmn:EndEvent') { //
@ -169,10 +186,19 @@ export default {
}
})
},
getActivityHighlightCss(activity) {
return activity.endTime ? 'highlight' : 'highlight-todo';
},
getTaskHighlightCss(task) {
if (!task) {
return '';
}
return '';
},
initModelListeners() {
const EventBus = this.bpmnModeler.get("eventBus");
const that = this;
// , . - ,
//
EventBus.on('element.hover', function(eventObj) {
let element = eventObj ? eventObj.element : null;
that.elementHover(element);
@ -209,6 +235,32 @@ export default {
<style>
/** 处理中 */
.highlight-todo.djs-connection > .djs-visual > path {
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
}
.highlight-todo.djs-shape .djs-visual > :nth-child(1) {
fill: orange !important;
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
}
/deep/.highlight-todo.djs-connection > .djs-visual > path {
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
marker-end: url(#sequenceflow-end-_E7DFDF-_E7DFDF-803g1kf6zwzmcig1y2ulm5egr);
}
/deep/.highlight-todo.djs-shape .djs-visual > :nth-child(1) {
fill: orange !important;
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
}
/** 通过 */
.highlight.djs-shape .djs-visual > :nth-child(1) {
fill: green !important;
@ -248,32 +300,6 @@ export default {
stroke: green !important;
}
/** 处理中 */
.highlight-todo.djs-connection > .djs-visual > path {
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
}
.highlight-todo.djs-shape .djs-visual > :nth-child(1) {
fill: orange !important;
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
}
/deep/.highlight-todo.djs-connection > .djs-visual > path {
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
marker-end: url(#sequenceflow-end-_E7DFDF-_E7DFDF-803g1kf6zwzmcig1y2ulm5egr);
}
/deep/.highlight-todo.djs-shape .djs-visual > :nth-child(1) {
fill: orange !important;
stroke: orange !important;
stroke-dasharray: 4px !important;
fill-opacity: 0.2 !important;
}
/** 不通过 */
.highlight-reject.djs-shape .djs-visual > :nth-child(1) {
fill: red !important;

View File

@ -74,7 +74,7 @@
<div slot="header" class="clearfix">
<span class="el-icon-picture-outline">流程图</span>
</div>
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" :taskData="activityList" />
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" :activityData="activityList"/>
</el-card>
<!-- 对话框(转派审批人) -->