1.0.3 • Published 1 year ago

bpmn-viewer-vue v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

bpmn-viewer-vue

基于bpmn2.0标准的工作流流程图渲染组件

bpmn-viewer-vue

安装

npm i bpmn-viewer-vue

快速上手

<template>
  <BpmnViewerVue :source="source" :timeData="timeData" :options="options">
  </BpmnViewerVue>
</template>
<script>
import BpmnViewerVue from 'bpmn-viewer-vue'
export default {
  components:{BpmnViewerVue},
  data(){
    return {
      source:"https://dev.dpark.com.cn/iplatform/sipsd-flow-modeler/rest/formdetail/getprocessXml/e6c573bcc99211eba5465e2c421612f0",
      timeData:[
        {
          "id": 1,
          "taskMaxDay": "4",
          "realName": null,
          "startTime": 1623292212527,
          "restTime": -12913873,
          "customTaskMaxDay": "4",
          "taskDefinitionKey": "jsqr",
          "taskName": "建设局人员现场确认",
          "duration": 0,
          "approveType": "审批",
          "status": "待办"
        },
        {
          "id": 2,
          "taskMaxDay": "1",
          "realName": null,
          "startTime": 1623291833921,
          "restTime": -13173452,
          "customTaskMaxDay": "1",
          "taskDefinitionKey": "widowsA",
          "taskName": "窗口",
          "duration": 282,
          "approveType": "审批",
          "status": "已办"
        }
      ],
      options:{
        timeLine:true
      }
    }
  }
}
</script>

配合flowable工作流后端使用

<template>
  <BpmnViewerVue :type="2"
                 :baseApi="baseApi"
                 :instanceId="instanceId"
                 :options="options"
                 :styl="styl">
  </BpmnViewerVue>
</template>
<script>
import BpmnViewerVue from 'bpmn-viewer-vue'
export default {
  components:{BpmnViewerVue},
  data(){
    return {
      baseApi:'https://example.com/flow-modeler/',
      instanceId:'e6c573bcc99211eba5465e2c421612f0',
      options:{
        timeLine:true
      }
    }
  }
}
</script>

属性

名称说明默认值
source流程图xml地址或者xml字符串null
baseApi工作流引擎后端地址,如果配置了source,则该属性不生效null
xmlId流程图ID,配合baseApi使用null
styl流程图主题,组件自带四种主题default、classic、dark、ccp,可以根据需要重写主题,也可以自己开发主题{theme:"default"}}
instanceIdflowable实例ID,配合baseApi使用null
type流程图显示模式1:流程图,2:流程实例,配合baseApi使用
timeData时间轴数据,此数据会替换接口获得的数据null
options控件配置{zoom:true,timeLine:false,center:true,setline:false}

options

名称说明默认值
zoom是否启用缩放控件true
timeLine是否启用时间轴false
fit流程图是否全部缩放在画布上false
static是否静态不可拖动false
setline是否显示动态线条(实验性功能,待完善)false
scrollZoom是否滚动缩放false
track时间轴和流程图是否追踪高亮false
focus流程图是否聚焦居中false
assigneeKey审批人字段assignee
taskMaxDayKey最大审批时间customTaskMaxDay

说明 1. 组件可以纯前端使用,也可以配合flowable工作流引擎进行使用 2. 纯前端使用不需要配置baseApi,xmlId,instanceId,type属性 3. 如果同时配置的source和baseApi,则忽略baseApi属性

方法

名称说明示例
reload重新加载流程图this.$refs.bpmnView.reload()
setTaskHighlight设置任务高亮this.$refs.bpmnObj.setTaskHighlight(ids, options)
clearTaskHighLight清除任务高亮this.$refs.bpmnObj.clearTaskHighLight(ids)

事件

名称说明参数
click元素点击事件Function(event,shape,taskData)
timeItemClick时间轴数据项点击事件Function(taskData)
viewChange画布变化事件Function(event)
loading流程图加载中Function()
loaded流程图加载完成Function()
loadError流程图加载失败Function(err)

插槽

  1. 自定义时间轴
// slotProps.item 为时间轴每项的数据对象
<BpmnViewerVue :type="2"
               :baseApi="baseApi"
               :instanceId="instanceId">
  <template v-slot:time="slotProps">
      <p>{{slotProps.item.taskName}}</p>
      <p>审批类型:{{slotProps.item.approveType}}</p>
      <p>状态:{{slotProps.item.status}}</p>
      <p>下载:<a target="_blank" href="http://www.baidu.com">baidu</a></p>
  </template>
</BpmnViewerVue>
<script>
export default {
  methods:{
  }
}
</script>
  1. 自定义顶部工具栏
<template>
  <BpmnViewerVue :type="1"
                 :baseApi="baseApi"
                 :xmlId="xmlId">
    <a-button-group>
      <a-button>btn1</a-button>
      <a-button>btn2</a-button>
      <a-button>btn3</a-button>
    </a-button-group>
  </BpmnViewerVue>
</template>