bpmn2 vue 设计器_[完全自定义]使用vue+bpmn-js实现activiti的流程设计器

本文介绍了如何使用Vue和bpmn-js实现Activiti流程设计器,解决后端使用Activiti但bpmn-js默认适配Camunda的问题。作者详细讲解了自定义属性面板、适配Activiti、扩展BpmnModeler、监听属性变化以及与Activiti后端的集成。同时,还提供了部分关键代码示例。
摘要由CSDN通过智能技术生成

写在前面:大家都是给赞王

Hello 大家好,我是易样(容易不一样,我们不一样,一天一个样)。

好久没更新文章了,没更新文章的这些时间我都在闭关修炼,努力提升自身技术,毕竟我2020年的flag是成为大牛。

今天给大家带来的这篇文章是整理我使用bpmn-js实现activiti流程设计器的经验之谈,bpmn-js的中文文档不多,很多人都不如何入手开发,并且bpmn-js的后端使用的是Camunda,如何使用activiti也是困扰了很多开发。

不要怕,让小姐姐来教教你。

如果你是react技术栈或许这个项目更满足你的需求:

react + bpmn-js + antd实现流程设计器和流程跟踪: github.com/griabcrh/re…

问题

需要前后端分离、觉得activiti的设计器不好用、使用bpmn-js实现设计器,但后端用的是activiti,xml不兼容怎么办?

解决

不止我这一种解决方法,我这里只提供我的解决方法。

1 使用Bpmn-js开发设计器

关于bpmn-js如何使用建议搭建去github上面搜索,这里贴上官网地址: github.com/bpmn-io/bpm…

笔者开发设计器时参考了霖呆呆的关于bpmn-js从0开发的一系列文章,地址: juejin.im/post/684490…

相信大家看完以上我贴的文章,对bpmn-js已经很熟悉了;接下来我来解释一下我的项目:

环境:windows10

开发工具:vscode、IDEA

**技术:**前端:vue+webpack,后端springboot+activiti

1.1 自定义右边属性面板

如图,是我完全自定义的属性面板

部分代码如下:

复制代码

我是通过propsComponent属性的变化来显示不同事件的属性,比如用户任务的属性、网关的属性

propsComponent属性是通过监听modeler、element来改变值的,代码如下:

addModelerListener() {

// 监听 modeler

const bpmnjs = this.bpmnModeler

const that = this

// 'shape.removed', 'connect.end', 'connect.move'

const events = ['shape.added', 'shape.move.end', 'shape.removed']

events.forEach(function(event) {

that.bpmnModeler.on(event, e => {

var elementRegistry = bpmnjs.get('elementRegistry')

var shape = e.element ? elementRegistry.get(e.element.id) : e.shape

// console.log(shape)

if (event === 'shape.added') {

console.log('新增了shape');

// 展示新增图形的属性

that.key = e.element.id.replace('_label', '');

that.propsComponent = bpmnHelper.getComponentByEleType(shape.type);

that.element = e.element;

} else if (event === 'shape.move.end') {

console.log('移动了shape')

// 展示新增图形的属性

that.key = shape.id;

that.propsComponent = bpmnHelper.getComponentByEleType(shape.type);

that.element = e.shape;

} else if (event === 'shape.removed') {

console.log('删除了shape')

// 展示默认的属性

that.propsComponent = 'CommonProps'

}

})

})

},

addEventBusListener() {

// 监听 element

let that = this

const eventBus = this.bpmnModeler.get('eventBus')

const eventTypes = ['element.click', 'element.changed', 'selection.changed']

eventTypes.forEach(function(eventType) {

eventBus.on(eventType, function(e) {

if (eventType === 'element.changed') {

that.elementChanged(e)

} else if (eventType === 'element.click') {

console.log('点击了element');

if (!e || e.element.type == 'bpmn:Process') {

that.key = '1';

that.propsComponent = 'CommonProps'

that.element = e.element;

} else {

// 展示新增图形的属性

that.key = e.element.id;

that.propsComponent = bpmnHelper.getComponentByEleType(e.element.type);

that.element = e.element;

}

}

})

})

},

复制代码

由于

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值