vue3集成bpmn.js

news2024/11/24 13:28:57

1 安装依赖

npm install bpmn-js
npm install bpmn-js-properties-panel
npm install camunda-bpmn-moddle

 注意依赖会有冲突,最好按照下列版本来安装:

"bpmn-js": "^7.3.1",
"bpmn-js-properties-panel": "^0.37.2",
"bpmn-moddle": "^6.0.0",
"camunda-bpmn-moddle": "^4.5.0",
"diagram-js-minimap": "2.0.4",

2 编写页面

(1)引入相关依赖

import { onMounted, markRaw } from 'vue';

// bpmn-js相关

import 'bpmn-js/dist/assets/diagram-js.css'; // 左边工具栏以及编辑节点的样式

import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';

import BpmnModeler from 'bpmn-js/lib/Modeler';

// bpmn-js-properties-panel相关

import 'bpmn-js-properties-panel/dist/assets/bpmn-js-properties-panel.css'

import propertiesPanelModule from 'bpmn-js-properties-panel'

import propertiesProviderModule from 'bpmn-js-properties-panel/lib/provider/camunda'

import camundaModdleDescriptor from 'camunda-bpmn-moddle/resources/camunda'

 (2)编写DIV

<div class="containerBox" style="position: relative;">
     <div id="container" style="width: calc(100vw - 750px); height: calc(100vh - 150px)">
        </div>
     <div id="js-properties-panel" class="panel"></div>
</div>

(3)DIV样式调整

<style>
.containerBox {
    height: calc(100vh - 160px);
    margin-top: 30px;
}

.containerBox #container {
    height: calc(100vh - 160px);
    border: 1px solid rgb(121, 121, 121);
}

.bpp-properties-panel [type=text] {
    box-sizing: border-box;
}

.panel {
    width: 400px;
    position: absolute;
    top: 1px;
    right: 1px;
    height: 100%;
    overflow: auto;
}

/* 右下角logo */
.bjs-powered-by {
    display: none;
}
</style>

 (4)页面初始化时,创建bpmn画板

onMounted(() => {
    const containerEl = document.getElementById('container');
    const bpmnModeler = markRaw(new BpmnModeler({
        container: containerEl,
        // 添加控制板
        propertiesPanel: {
            parent: '#js-properties-panel'
        },
        // 右侧属性面板
        additionalModules: [
            propertiesPanelModule,
            propertiesProviderModule
        ],
        moddleExtensions: {
            camunda: camundaModdleDescriptor
        }
    }));
    bpmnModeler.createDiagram(() => {
        bpmnModeler.get('canvas').zoom('fit-viewport');
    });
})

(5)汉化bpmn

assets/bpmn/zh.js

export default {
  // Labels
  "Activate the global connect tool": "激活全局连接工具",
  "Append {type}": "追加 {type}",
  "Append EndEvent": "追加 结束事件 ",
  "Append Task": "追加 任务",
  "Append Gateway": "追加 网关",
  "Append Intermediate/Boundary Event": "追加 中间/边界 事件",
  "Add Lane above": "在上面添加道",
  "Divide into two Lanes": "分割成两个道",
  "Divide into three Lanes": "分割成三个道",
  "Add Lane below": "在下面添加道",
  "Append compensation activity": "追加补偿活动",
  "Change type": "修改类型",
  "Connect using Association": "使用关联连接",
  "Connect using Sequence/MessageFlow or Association":
    "使用顺序/消息流或者关联连接",
  "Connect using DataInputAssociation": "使用数据输入关联连接",
  "Remove": "移除",
  "Activate the hand tool": "激活抓手工具",
  "Activate the lasso tool": "激活套索工具",
  "Activate the create/remove space tool": "激活创建/删除空间工具",
  "Create expanded SubProcess": "创建扩展子过程",
  "Create IntermediateThrowEvent/BoundaryEvent": "创建中间抛出事件/边界事件",
  "Create Pool/Participant": "创建池/参与者",
  "Parallel Multi Instance": "并行多重事件",
  "Sequential Multi Instance": "时序多重事件",
  "DataObjectReference": "数据对象参考",
  "DataStoreReference": "数据存储参考",
  "Loop": "循环",
  "Ad-hoc": "即席",
  "Create {type}": "创建 {type}",
  "Create Task": "创建任务",
  "Create StartEvent": "创建开始事件",
  "Create EndEvent": "创建结束事件",
  "Create Group": "创建组",
  "Task": "任务",
  "Send Task": "发送任务",
  "Receive Task": "接收任务",
  "User Task": "用户任务",
  "Manual Task": "手工任务",
  "Business Rule Task": "业务规则任务",
  "Service Task": "服务任务",
  "Script Task": "脚本任务",
  "Call Activity": "调用活动",
  "Sub Process (collapsed)": "子流程(折叠的)",
  "Sub Process (expanded)": "子流程(展开的)",
  "Start Event": "开始事件",
  "StartEvent": "开始事件",
  "Intermediate Throw Event": "中间事件",
  "End Event": "结束事件",
  "EndEvent": "结束事件",
  "Create Gateway": "创建网关",
  "GateWay": "网关",
  "Create Intermediate/Boundary Event": "创建中间/边界事件",
  "Message Start Event": "消息开始事件",
  "Timer Start Event": "定时开始事件",
  "Conditional Start Event": "条件开始事件",
  "Signal Start Event": "信号开始事件",
  "Error Start Event": "错误开始事件",
  "Escalation Start Event": "升级开始事件",
  "Compensation Start Event": "补偿开始事件",
  "Message Start Event (non-interrupting)": "消息开始事件(非中断)",
  "Timer Start Event (non-interrupting)": "定时开始事件(非中断)",
  "Conditional Start Event (non-interrupting)": "条件开始事件(非中断)",
  "Signal Start Event (non-interrupting)": "信号开始事件(非中断)",
  "Escalation Start Event (non-interrupting)": "升级开始事件(非中断)",
  "Message Intermediate Catch Event": "消息中间捕获事件",
  "Message Intermediate Throw Event": "消息中间抛出事件",
  "Timer Intermediate Catch Event": "定时中间捕获事件",
  "Escalation Intermediate Throw Event": "升级中间抛出事件",
  "Conditional Intermediate Catch Event": "条件中间捕获事件",
  "Link Intermediate Catch Event": "链接中间捕获事件",
  "Link Intermediate Throw Event": "链接中间抛出事件",
  "Compensation Intermediate Throw Event": "补偿中间抛出事件",
  "Signal Intermediate Catch Event": "信号中间捕获事件",
  "Signal Intermediate Throw Event": "信号中间抛出事件",
  "Message End Event": "消息结束事件",
  "Escalation End Event": "定时结束事件",
  "Error End Event": "错误结束事件",
  "Cancel End Event": "取消结束事件",
  "Compensation End Event": "补偿结束事件",
  "Signal End Event": "信号结束事件",
  "Terminate End Event": "终止结束事件",
  "Message Boundary Event": "消息边界事件",
  "Message Boundary Event (non-interrupting)": "消息边界事件(非中断)",
  "Timer Boundary Event": "定时边界事件",
  "Timer Boundary Event (non-interrupting)": "定时边界事件(非中断)",
  "Escalation Boundary Event": "升级边界事件",
  "Escalation Boundary Event (non-interrupting)": "升级边界事件(非中断)",
  "Conditional Boundary Event": "条件边界事件",
  "Conditional Boundary Event (non-interrupting)": "条件边界事件(非中断)",
  "Error Boundary Event": "错误边界事件",
  "Cancel Boundary Event": "取消边界事件",
  "Signal Boundary Event": "信号边界事件",
  "Signal Boundary Event (non-interrupting)": "信号边界事件(非中断)",
  "Compensation Boundary Event": "补偿边界事件",
  "Exclusive Gateway": "互斥网关",
  "Parallel Gateway": "并行网关",
  "Inclusive Gateway": "相容网关",
  "Complex Gateway": "复杂网关",
  "Event based Gateway": "事件网关",
  "Transaction": "转运",
  "Sub Process": "子流程",
  "Event Sub Process": "事件子流程",
  "Collapsed Pool": "折叠池",
  "Expanded Pool": "展开池",
  // Errors
  "no parent for {element} in {parent}": "在{parent}里,{element}没有父类",
  "no shape type specified": "没有指定的形状类型",
  "flow elements must be children of pools/participants":
    "流元素必须是池/参与者的子类",
  "out of bounds release": "out of bounds release",
  "more than {count} child lanes": "子道大于{count} ",
  "element required": "元素不能为空",
  "diagram not part of bpmn:Definitions": "流程图不符合bpmn规范",
  "no diagram to display": "没有可展示的流程图",
  "no process or collaboration to display": "没有可展示的流程/协作",
  "element {element} referenced by {referenced}#{property} not yet drawn":
    "由{referenced}#{property}引用的{element}元素仍未绘制",
  "already rendered {element}": "{element} 已被渲染",
  "failed to import {element}": "导入{element}失败",
  //属性面板的参数
  "Id": "编号",
  "Name": "名称",
  "General": "常规",
  "Details": "详情",
  "Message Name": "消息名称",
  "Message": "消息",
  "Initiator": "创建者",
  "Asynchronous Continuations": "持续异步",
  "Asynchronous Before": "异步前",
  "Asynchronous After": "异步后",
  "Job Configuration": "工作配置",
  "Exclusive": "排除",
  "Job Priority": "工作优先级",
  "Retry Time Cycle": "重试时间周期",
  "Documentation": "文档",
  "Element Documentation": "元素文档",
  "History Configuration": "历史配置",
  "History Time To Live": "历史的生存时间",
  "Forms": "表单",
  "Form Key": "表单key",
  "Form Fields": "表单字段",
  "Business Key": "业务key",
  "Form Field": "表单字段",
  "ID": "编号",
  "Type": "类型",
  "Label": "名称",
  "Default Value": "默认值",
  "Validation": "校验",
  "Add Constraint": "添加约束",
  "Config": "配置",
  "Properties": "属性",
  "Add Property": "添加属性",
  "Value": "值",
  "Add": "添加",
  "Values": "值",
  "Add Value": "添加值",
  "Listeners": "监听器",
  "Execution Listener": "执行监听",
  "Event Type": "事件类型",
  "Listener Type": "监听器类型",
  "Java Class": "Java类",
  "Expression": "表达式",
  "Must provide a value": "必须提供一个值",
  "Delegate Expression": "代理表达式",
  "Script": "脚本",
  "Script Format": "脚本格式",
  "Script Type": "脚本类型",
  "Inline Script": "内联脚本",
  "External Script": "外部脚本",
  "Resource": "资源",
  "Field Injection": "字段注入",
  "Extensions": "扩展",
  "Input/Output": "输入/输出",
  "Input Parameters": "输入参数",
  "Output Parameters": "输出参数",
  "Parameters": "参数",
  "Output Parameter": "输出参数",
  "Timer Definition Type": "定时器定义类型",
  "Timer Definition": "定时器定义",
  "Date": "日期",
  "Duration": "持续",
  "Cycle": "循环",
  "Signal": "信号",
  "Signal Name": "信号名称",
  "Escalation": "升级",
  "Error": "错误",
  "Link Name": "链接名称",
  "Condition": "条件名称",
  "Variable Name": "变量名称",
  "Variable Event": "变量事件",
  "Specify more than one variable change event as a comma separated list.":
    "多个变量事件以逗号隔开",
  "Wait for Completion": "等待完成",
  "Activity Ref": "活动参考",
  "Version Tag": "版本标签",
  "Executable": "可执行文件",
  "External Task Configuration": "扩展任务配置",
  "Task Priority": "任务优先级",
  "External": "外部",
  "Connector": "连接器",
  "Must configure Connector": "必须配置连接器",
  "Connector Id": "连接器编号",
  "Implementation": "实现方式",
  "Field Injections": "字段注入",
  "Fields": "字段",
  "Result Variable": "结果变量",
  "Topic": "主题",
  "Configure Connector": "配置连接器",
  "Input Parameter": "输入参数",
  "Assignee": "代理人",
  "Candidate Users": "候选用户",
  "Candidate Groups": "候选组",
  "Due Date": "到期时间",
  "Follow Up Date": "跟踪日期",
  "Priority": "优先级",
  "The follow up date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)":
    "跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00",
  "The due date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)":
    "跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00",
    "Variables": "变量",
  "Candidate Starter Configuration": "候选开始配置",
  "Task Listener": "任务监听器",
  "Candidate Starter Groups": "候选开始组",
  "Candidate Starter Users": "候选开始用户",
  "Tasklist Configuration": "任务列表配置",
  "Startable": "启动",
  "Specify more than one group as a comma separated list.":
    "指定多个组,用逗号分隔",
  "Specify more than one user as a comma separated list.":
    "指定多个用户,用逗号分隔",
  "This maps to the process definition key.": "这会映射为流程定义的键",
  "CallActivity Type": "调用活动类型",
  "Condition Type": "条件类型",
  "Create UserTask": "创建用户任务",
  "Create CallActivity": "创建调用活动",
  "Called Element": "调用元素",
  "Create DataObjectReference": "创建数据对象引用",
  "Create DataStoreReference": "创建数据存储引用",
  "Multi Instance": "多实例",
  "Loop Cardinality": "实例数量",
  "Collection": "任务参与人列表",
  "Element Variable": "元素变量",
  "Completion Condition": "完成条件",
  "Open minimap": "打开小地图",
  "Close minimap": "关闭小地图",
};

assets/bpmn/translate.js

import translations from "./zh";

export default function customTranslate(template, replacements) {
  replacements = replacements || {};

  // Translate
  template = translations[template] || template;

  // Replace
  return template.replace(/{([^}]+)}/g, function(_, key) {
    let str = replacements[key];
    if (
      translations[replacements[key]] !== null &&
      translations[replacements[key]] !== "undefined"
    ) {
      // eslint-disable-next-line no-mixed-spaces-and-tabs
      str = translations[replacements[key]];
      // eslint-disable-next-line no-mixed-spaces-and-tabs
    }
    return str || "{" + key + "}";
  });
}

index.vue中,引入translate.js'

new BpmnModel时,加入汉化组件

// 引入汉化js

import translate from '@/assets/bpmn/translate.js'

var customTranslateModule = {
    translate: ['value', translate]
}

const bpmnModeler = markRaw(new BpmnModeler({
        additionalModules: [
            customTranslateModule
        ],
}));

页面效果图如下:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/949909.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

量子计算机使模拟化学反应减慢了1000亿倍!

悉尼大学(University of Sydney)的科学家们首次利用量子计算机设计并直接观测了化学反应中的一个关键过程&#xff0c;将其速度减慢了1000亿倍。 “Direct observation of geometric-phase interference in dynamics around a conical intersection” 主要作者Vanessa Olaya Ag…

免费可商用的高清视频素材库分享~

找视频素材绝对不能错过这个6个网站&#xff0c;免费可商用&#xff0c;视频剪辑、自媒体必备&#xff0c;赶紧收藏~ 1、菜鸟图库 https://www.sucai999.com/video.html?vNTYwNDUx 菜鸟图库不仅是一个设计网站&#xff0c;它还有非常丰富的视频和音频素材&#xff0c;视频素材…

[JDK8下的HashMap类应用及源码分析] 数据结构、哈希碰撞、链表变红黑树

系列文章目录 [Java基础] StringBuffer 和 StringBuilder 类应用及源码分析 [Java基础] 数组应用及源码分析 [Java基础] String&#xff0c;分析内存地址&#xff0c;源码 [JDK8环境下的HashMap类应用及源码分析] 第一篇 空构造函数初始化 [JDK8环境下的HashMap类应用及源码分…

Java 复习笔记 - 方法篇

文章目录 一&#xff0c;方法的定义二&#xff0c;最简单的方法定义和调用三&#xff0c;带参数的方法定义和调用四&#xff0c;带返回值方法的定义和调用五&#xff0c;小结六&#xff0c;方法的重载七&#xff0c;方法简单练习1&#xff0c;数组遍历2&#xff0c;数组最大值3…

【深入解读Redis系列】Redis系列(五):切片集群详解

首发博客地址 https://blog.zysicyj.top/ 系列文章地址[1] 如果 Redis 内存很大怎么办&#xff1f; 假设一台 32G 内存的服务器部署了一个 Redis&#xff0c;内存占用了 25G&#xff0c;会发生什么&#xff1f; 此时最明显的表现是 Redis 的响应变慢&#xff0c;甚至非常慢。 这…

Spring框架中如何处理事务管理

文章目录 **1. 声明式事务管理&#xff1a;****定义事务管理器&#xff1a;****配置事务通知&#xff1a;****将事务通知应用到方法&#xff1a;** **2. 编程式事务管理&#xff1a;****通过编程方式启动事务&#xff1a;** **3. 配置事务属性&#xff1a;** &#x1f388;个人…

S32K324芯片学习笔记-实时控制系统-ADC

文章目录 Analog-to-Digital Converter (ADC)用于内部供应监控的ANAMUXBCTU接口硬件触发ADC多路模式通道功能框图特点功能描述时钟转换正常触发注入触发BCTU接口BCTU Trigger modeBCTU Control mode 配置ADC时钟分压器和采样时间设置预采样启用每个通道的预采样 模拟看门狗功能…

阿里云轻量应用服务器Linux-Centos7下MySQL8.0.19的使用

初始环境&#xff1a;阿里云轻量应用服务器已经安装MySQL8.0.19 具体目标&#xff1a;使用MySQL 8.0.19 目录 第一步&#xff1a;初始化第二步&#xff1a;创建一些表第三步&#xff1a;添加一些数据第四步&#xff1a;详情一览第五步&#xff1a;检索数据第六步&#xff1a;排…

前端:js实现提示框(自动消失)

效果&#xff1a; 代码&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content&q…

正交实验如何进行方差分析?

一、案例介绍 欲研究温度&#xff08;℃&#xff09;、时间&#xff08;min&#xff09;、催化剂含量&#xff08;%&#xff09;对某物质转化率的影响&#xff0c;当前使用正交试验设计进行试验&#xff0c;试探究3个因素对转化率的影响是否显著&#xff0c;并找到能使转化率达…

Source Insight查看源码

新建一个工程 Project -> Synchnorize Files 有可能找不到文件 Options -> File Type Option 查看或者设置快捷键

IDEA新建SpringBoot项目时启动编译报错:Error:java: 无效的源发行版: 17

文章目录 原因检查解决步骤修改jdk修改SpringBoot版本 原因 出现这种错误的原因可能是&#xff1a; 本机默认使用&#xff08;编译&#xff09;的jdk与该项目所使用的jdk版本不同。 jdk版本不适用于这个Idea&#xff0c;很典型的一个例子就是使用的Idea是2020的&#xff0c;而…

C语言每日一练--------Day(11)

本专栏为c语言练习专栏&#xff0c;适合刚刚学完c语言的初学者。本专栏每天会不定时更新&#xff0c;通过每天练习&#xff0c;进一步对c语言的重难点知识进行更深入的学习。 今日练习题关键字&#xff1a;找到数组中消失的数字 哈希表 &#x1f493;博主csdn个人主页&#xff…

【java】【项目实战】[外卖七]短信验证码、手机短信登录开发

目录 一、发送短信 1 短信服务介绍 2 阿里云短信服务&#xff08;个人现在不太好申请了&#xff09; 2.1 介绍 2.2 注册账号 2.3 设置短信签名 2.4 设置短信模版 2.5 设置AccessKey 3 代码开发 3.1 导包 3.2 短信发送工具类SMSUtils 二、手机验证码登录 1 需求分析 …

C++自创题目——第一期

一、题目描述&#xff1a; 在一段时间内&#xff0c;到达港口的船有n艘&#xff0c;其中每艘船的信息包括:到达时间t(表示第t秒)&#xff0c;船上乘客数k&#xff0c;以及k名乘客的国籍。输出前3600s内每艘船上国籍种数&#xff0c;并输出国籍种数最少的船只的到达时间。 二、…

ThreeJS模型加载动画——从下向上加载

从下向上动态加载模型,模型本身是由点-线-面组成,setDynamic动态控制模型每个point的位置,让模型出现一个动态加载的效果,如下图: 1、首先将模型压扁,获取point的position位置,然后设置y轴的高度为0,并将原始高度记录到modelPositons用于后面还原高度。 //将物…

华为鲲鹏服务器

1.简介 鲲鹏通用计算平台提供基于鲲鹏处理器的TaiShan服务器、鲲鹏主板及开发套件。硬件厂商可以基于鲲鹏主板发展自有品牌的产品和解决方案&#xff1b;软件厂商基于openEuler开源OS以及配套的数据库、中间件等平台软件发展应用软件和服务&#xff1b;鲲鹏开发套件可帮助开发…

前端刷题-深浅拷贝

深拷贝 function deepClone(obj) {if (obj null || typeof obj ! "object") {return obj;}if (obj instanceof Date) {return new Date(obj);}if (obj instanceof Array) {const cloneArray [];for (let i 0; i < obj.length; i) {cloneArray[i] deepClone(o…

Android修改默认gradle路径

Android Studio每次新建项目&#xff0c;都会默认在C盘生成并下载gradle相关文件&#xff0c;由于C盘空间有限&#xff0c;没多久C盘就飘红了&#xff0c;于是就需要把gradle相关文件转移到其他盘 1、到C盘找到gradle文件 具体路径一般是&#xff1a;C:\Users\用户\ .gradle …

Python+PIL+qrcode实现二维码自由—普通二维码+彩色二维码+logo二维码+动态二维码(附完整代码)

有时候我们需要自己制作一个二维码&#xff0c;然后进行打印下来&#xff0c;或者说在二维码中提前写上一段话比如搞笑的话&#xff0c;然后印在衣服上&#xff0c;然后穿出去玩&#xff01;的&#x1f923; 那么今天我们分享一下制作二维码的几种方式&#xff1a; 哎&#x…