背景:流程跟踪查看的时候,需要看到当前节点具体的处理人是谁,效果如图

直接上代码

<template><div class="my-process-designer"><div class="my-process-designer__container"><div class="my-process-status"><span class="intro">状态:</span><div class="finish">已完成</div><div class="processing">流程中</div><div class="todo">未进行</div></div><div class="my-process-designer__canvas" ref="bpmn-canvas" v-bind:style="{width: 100 * scale + '%',height: 100 * scale + '%'}"></div><div class="session-info" v-show="selection"><div class="title-container"><img src="@/assets/images/Union.svg" class="avatra-ic" /><span>{{ selection.activityName }}</span></div><div class="approval-container"><div class="extra">处理人:</div><div class="people-info"><img src="@/assets/images/logo1.svg" class="avatra"><div><!-- <div> --><span class="name">{{ selection.createBy }}</span><!-- <span class="num">({{selection.No}})</span> --><!-- </div> --><!-- <div><span class="title">{{ selection.title}}</span></div> --></div></div></div></div><div class="my-process-handler"><img class="process-hander-ic" src="@/assets/images/boost.svg"  @click="handleZoom(0.1)" /><img class="process-hander-ic" src="@/assets/images/reduce.svg"  @click="handleZoom(-0.1)" /></div></div></div>
</template><script>
import BpmnModeler from 'bpmn-js/lib/Modeler'import kuailuModdleDescriptor from '../../plugin/descriptor/kuailuDescriptor.json'
export default {name: 'flow',props: {processID: {type: String,default: ''},approveRecs: {type: Array,default () {return []}}},watch: {processID (val) {if (!val) returnthis.processDefDetail()}},mounted () {this.initBpmnModeler()},data () {return {bpmnModeler: '',prefix: 'kuailu',selection: '',approvalPeople: [],scale: 1}},computed: {additionalModules () {return [{paletteProvider: ['value', ''], // 禁用/清空左侧工具栏labelEditingProvider: ['value', ''], // 禁用节点编辑contextPadProvider: ['value', ''], // 禁用图形菜单bendpoints: ['value', {}], // 禁用连线拖动move: ['value', ''] // 禁用单个图形拖动}]}},methods: {initBpmnModeler () {if (this.bpmnModeler) returnthis.bpmnModeler = new BpmnModeler({container: this.$refs['bpmn-canvas'],keyboard: this.keyboard ? { bindTo: document } : null,additionalModules: this.additionalModules,moddleExtensions: this.moddleExtensions})},subscribeBpmnEvent () {let that = thisthat.bpmnModeler.on('selection.changed', ({ newSelection }) => {const id = newSelection[0] && newSelection[0].idconst list = that.approveRecs.filter(item => item.taskDefinitionKey === id)if (list.length) {that.selection = list[0]} else {that.selection = ''}})const eventBus = this.bpmnModeler.get('eventBus')// 注册节点事件,eventTypes中可以写多个事件const eventTypes = ['element.click', 'element.hover']eventTypes.forEach((eventType) => {eventBus.on(eventType, (e) => {const {element} = eif (!element.parent) returnif (!e || element.type === 'bpmn:Process') {return false} else {if (eventType === 'element.hover') {// debugger// 鼠标滑过节点后想要做的处理console.log('鼠标经过节点啦~')const id = element.idconst list = that.approveRecs.filter(item => item.taskDefinitionKey === id)if (list.length) {that.selection = list[0]} else {that.selection = ''}}}})})},// 获取流程图中所有节点信息getNodeInfoList () {const elementRegistry = this.bpmnModeler.get('elementRegistry')const userTaskList = elementRegistry.filter((item) => item.type === 'bpmn:UserTask')const modeling = this.bpmnModeler.get('modeling')userTaskList.forEach(v => {// 更改节点名称modeling.updateLabel(v, '具体的处理人,不是节点名称')})},moddleExtensions () {const Extensions = {}if (this.prefix === 'kuailu') {Extensions.kuailu = kuailuModdleDescriptor}return Extensions},// 详情processDefDetail () {const that = thisthis.$apiRequest.processDefDetail(this.processID).then(async (res = {}) => {const {bpmnSnapshotBack, id, processDefNo, processDefName} = res.data || {}let xmlStr = bpmnSnapshotBack // 新取值that.fileDate = res.datathat.processIdFromDetail = id // 流程idthat.processNoFromDetail = processDefNo // 流程编码that.processNameFromDetail = processDefName // 流程名称if (that.processIdFromDetail && that.processIdFromDetail.indexOf('Process_') === -1) {that.processIdFromDetail = 'Process_' + that.processIdFromDetail}if (that.processNameFromDetail && that.processNameFromDetail.indexOf('Name_') === -1) {that.processNameFromDetail = 'Name_' + that.processNameFromDetail}await that.createNewDiagram(xmlStr)this.setCurrentSept()this.getNodeInfoList()})},/* 创建新的流程图 */async createNewDiagram (xml) {let that = this// 将字符串转换成图显示出来let newId = that.processIdFromDetail || `Process_${new Date().getTime()}`let newNo = that.processNoFromDetail || `No_${new Date().getTime()}`let newName = that.processNameFromDetail || `Name_${new Date().getTime()}`let xmlString = xml || this.getDefaultEmptyXML(newId, newNo, newName, that.prefix)try {let { warnings } = await that.bpmnModeler.importXML(xmlString)if (warnings && warnings.length) {warnings.forEach(warn => console.warn(warn))}if (document.getElementsByClassName('bjs-powered-by').length) {document.getElementsByClassName('bjs-powered-by')[0].style.display = 'none'}this.subscribeBpmnEvent()} catch (e) {console.error(`[Process Designer Warn]:`)}},setCurrentSept () {const elementRegistry = this.bpmnModeler.get('elementRegistry')const nodeList = elementRegistry.filter((item) => {return ['bpmn:UserTask', 'bpmn:ServiceTask'].includes(item.type)})let modeling = this.bpmnModeler.get('modeling')const completedNode = this.approveRecs.filter(_ => _.status === 'completed').map(_ => _.taskDefinitionKey)const activeNode = this.approveRecs.filter(_ => _.status === 'active').map(_ => _.taskDefinitionKey)nodeList.forEach((item, index) => {if (completedNode.includes(item.id)) {modeling.setColor(nodeList[index], {fill: '#E8FFEA'})} else if (activeNode.includes(item.id)) {modeling.setColor(nodeList[index], {fill: '#BFDBFD'})} else {modeling.setColor(nodeList[index], {fill: '#ECEDEE'})}})},getDefaultEmptyXML (key, no, name, type) {if (!type) type = 'kuailu'const TYPE_TARGET = {activiti: 'http://activiti.org/bpmn',camunda: 'http://bpmn.io/schema/bpmn',kuailu: 'http://www.kuailu.com/1.0/bpmn'}return `<?xml version="1.0" encoding="UTF-8"?><bpmn2:definitionsxmlns:camunda="http://camunda.org/schema/1.0/bpmn"exporter="Camunda Modeler"exporterVersion="1.10.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL"xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"xmlns:di="http://www.omg.org/spec/DD/20100524/DI"xmlns:kuailu="http://www.kuailu.com/1.0/bpmn"xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"id="diagram_${key}"targetNamespace="${TYPE_TARGET[type]}"><bpmn2:process id="${key}" no="${no}" name="${name}" isExecutable="true"></bpmn2:process><bpmndi:BPMNDiagram id="BPMNDiagram_1"><bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="${key}"></bpmndi:BPMNPlane></bpmndi:BPMNDiagram></bpmn2:definitions>`},handleZoom (flag) {this.scale += flagthis.$nextTick(() => {this.bpmnModeler.get('canvas').zoom(this.scale)})}}
}
</script><style lang="less" scoped>
.my-process-designer {display: flex;position: relative;flex-direction: column;width: 100%;height: 500px;box-sizing: border-box;margin-top: 20px;.my-process-designer__container {display: inline-flex;width: 100%;flex: 1;.my-process-designer__canvas {flex: 1;height: 100%;position: relative;background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImEiIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTTAgMTBoNDBNMTAgMHY0ME0wIDIwaDQwTTIwIDB2NDBNMCAzMGg0ME0zMCAwdjQwIiBmaWxsPSJub25lIiBzdHJva2U9IiNlMGUwZTAiIG9wYWNpdHk9Ii4yIi8+PHBhdGggZD0iTTQwIDBIMHY0MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZTBlMGUwIi8+PC9wYXR0ZXJuPjwvZGVmcz48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSJ1cmwoI2EpIi8+PC9zdmc+")repeat !important;div.toggle-mode {display: none;}}.my-process-status {position: absolute;display: flex;top: 20px;left: 20px;font-size: 12px;.intro {color: #999999;margin-top: 3px;}.finish {background-color: #E8FFEA;padding: 4px;border: 1px solid rgba(0, 180, 42, 0.1);border-radius: 3px;color: #00B42A;margin-right: 8px;}.processing {background-color: #E8F3FE;padding: 4px;border: 1px solid #BFDBFD;border-radius: 3px;color: #165DFF;margin-right: 8px;}.todo {padding: 4px;background: #ECEDEE;border: 1px solid rgba(204, 204, 204, 0.1);border-radius: 3px;color: #666666;margin-right: 5px;}}svg {width: 100%;height: 100%;min-height: 100%;overflow: hidden;}.session-info {position: absolute;width: 200px;height: 300px;background: #FFFFFF;border: 1px solid #ECEDF2;box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.2);border-radius: 3px;right: 20px;top: 10px;.title-container {padding: 18px;display: flex;align-items: center;font-size: 16px;color: #333333;font-weight: 500;height: 50px;border-bottom: 1px solid #ECEDF2;.avatra-ic {margin-right: 5px;width: 15px;height: 15px;margin-top: 2px;}}.approval-container {padding: 12px 16px;.extra {font-size: 12px;color: #333333;margin-bottom: 10px;}.avatra {width: 32px;height: 32px;border-radius: 32px;margin-right: 10px;}.people-info {display: flex;font-size: 12px;margin-bottom: 10px;align-items: center;}.name {color: #333333;}.num {color: #999999;}.title {color: #999999;}}}.my-process-handler {display: flex;bottom: 50px;position: absolute;right: 20px;width: 92px;height: 42px;border-radius: 30px;align-items: center;background-color: #525252;.process-hander-ic {flex: 1;width: 20px;height: 20px;cursor: pointer;}}}
}</style>

参考文章
http://t.zoukankan.com/lemoncool-p-12746217.html

BPMN - 自定义任务节点名称相关推荐

  1. 【Groovy】自定义 Xml 生成器 BuilderSupport ( 继承 BuilderSupport 抽象类 | 在 createNode 方法中获取节点名称、节点属性、节点值信息 )

    文章目录 一.继承 BuilderSupport 抽象类 二.在 createNode 方法中获取节点名称.节点属性.节点值信息 三.完整代码示例 1.MyBuilderSupport 生成器代码 2 ...

  2. 【Groovy】自定义 Xml 生成器 BuilderSupport ( 构造 Xml 节点类 | 封装节点名称、节点值、节点属性、子节点 | 将封装的节点数据转为 Xml 字符串 )

    文章目录 一.构造 Xml 节点类 1.封装节点名称.节点值.节点属性.子节点 2.将封装的节点数据转为 Xml 字符串 二.Xml 节点类完整代码 一.构造 Xml 节点类 生成 Xml 数据前 , ...

  3. app.config自定义配置节点

    本来一直用xml保存配置文件的,但有一个组件就写一个好麻烦.于是想起了自定义配置节点哈哈~~我撒娇了复习了下 首先我在ConfigManager.Instance使用单例模式,其次Reflection ...

  4. android 自定义apk名,Android Studio多渠道打包、自定义打包APK名称

    现在为了推广产品,会在多个渠道应用市场发布应用,为了统计不同渠道的数据,需要在应用中表明渠道,如果一个一个去修改打包效率会很低.AS为我们提供了简便的方法,可以多渠道打包,一次打包所有的渠道包. 1. ...

  5. ASP.NET系列:自定义配置节点的复用

    appSettings太简单,为每个程序自定义配置节点太复杂,因此要解决app.config&web.config自定义配置的复用问题. 1.读取不依赖SectionName,根节点可以定义为 ...

  6. UE4 创建自定义动画节点

    创建自定义动画节点需要两个类: 一个是您在编辑器中看到的图表节点 一个是真正在运行时工作的行为节点 动画图表节点,派生自:UAnimGraphNode_Base 例如:class UAnimGraph ...

  7. 长安链ChainMaker:一、使用自定义组织节点docker启动链

    长安链ChainMaker:一.使用自定义组织节点docker启动链 文章目录 长安链ChainMaker:一.使用自定义组织节点docker启动链 0.整体步骤: 1.下载chainmaker-go ...

  8. cloudflare速度怎么样_CloudFlare自定义加速节点优化网站速度小技巧

    本文转载自小俊博客https://www.xjisme.com/archives/2265.html CloudFlare 官网虽然不提供 CNAME / AAAA / A 记录接入 CloudFla ...

  9. 获取json的节点名称

    好几次想取json的节点名称,今天搞定了. procedure GetJsonNames(o: ISuperObject; Strs: TStrings); varite: TSuperAvlIter ...

最新文章

  1. 2!=5 or 0在python中是否正确-不吹不擂,你想要的Python面试都在这里了【315+道题】...
  2. C++ 模板详解(一)
  3. 支付宝支付回调异常_支付宝崩了是怎么回事 支付宝崩了部分用户使用异常现已恢复...
  4. Firefox下代码触发a标签的click事件无效
  5. 时尚的基因是创新 -- 旺旺平台产品线员工大会即兴发言提要
  6. Avalonia跨平台入门第十三篇之Expander控件
  7. 【LeetCode笔记】312. 戳气球(Java、动态规划)
  8. C/S架构网络聊天软件——Java Chat Application 用java做一个聊天机器人
  9. POJ 3422 Kaka's Matrix Travels
  10. VirtualBox 如何重复使用复制的硬盘文件
  11. win10改成ahci后无法开机怎么办,win10开不了机
  12. Linux运维(三)
  13. c语言cg平台答案,【2017年整理】非常好的C语言习题集带答案.doc
  14. SQL语法提示工具SQL Prompt 发布v10.6
  15. excel导出时报错 “文件格式和扩展名不匹配,文件可能已损坏或不安全”解决办法
  16. 云计算中的Server Consolidation
  17. Matplotlib设置坐标轴日期格式
  18. php 百度网盘上传文件大小限制吗,百度云存储,curl_百度云存储如何上传数G超大文件(视频类)和防盗链等一系列问题,百度云存储,curl - phpStudy...
  19. JavaScript期末大作业 罗兰永恒花园动漫价绍网页 7页,含有table表格,js表单验证还有首页视频
  20. Win10 如何隐藏控制面板里面的BitLocker 驱动器加密功能

热门文章

  1. 如何linux搭建vpn服务器
  2. ArcGIS:如何新建图层组并添加数据、切换数据视图和布局视图、修改符号系统?
  3. fallguy服务器维护,糖豆人fallguys
  4. EXCEL之快速选中一列
  5. 红客联盟是什么?红客需要传承!
  6. 龙尚科技助力煤矿智能化建设进入新发展阶段
  7. 联发科mt6757处理器介绍,Helio P20芯片资料
  8. 通过企业名称生成随机背景名称标识头像
  9. 股票交易android开发(十二)
  10. 拿什么拯救我的远程办公?