日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

      歡迎訪問 生活随笔!

      生活随笔

      當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

      综合教程

      bpmn-js画流程图 (一)基本安装使用

      發(fā)布時間:2024/1/4 综合教程 34 生活家
      生活随笔 收集整理的這篇文章主要介紹了 bpmn-js画流程图 (一)基本安装使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

      1. 在頁面上直接引用bpmn.js

      <!DOCTYPE html>
      <html lang="en">
      
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <title>BPMNJS</title>
          <!--CDN-->
          <script src="https://unpkg.com/bpmn-js@6.0.2/dist/bpmn-viewer.development.js"></script>
          <style>
              #canvas {
                  height: 400px;
              }
          </style>
      </head>
      
      <body>
          <div id="canvas"></div>
          <script>
              var bpmnJS = new BpmnJS({
                  container: '#canvas'
              });
      
              bpmnXML='<?xml version="1.0" encoding="UTF-8"?>
      ' +
                  '<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="6.3.3">
      ' +
                  '  <process id="Process_1" isExecutable="false">
      ' +
                  '    <startEvent id="StartEvent_1y45yut" name="hunger noticed">
      ' +
                  '      <outgoing>SequenceFlow_0h21x7r</outgoing>
      ' +
                  '    </startEvent>
      ' +
                  '    <task id="Task_1hcentk" name="choose recipe">
      ' +
                  '      <incoming>SequenceFlow_0h21x7r</incoming>
      ' +
                  '      <outgoing>SequenceFlow_0wnb4ke</outgoing>
      ' +
                  '    </task>
      ' +
                  '    <sequenceFlow id="SequenceFlow_0h21x7r" sourceRef="StartEvent_1y45yut" targetRef="Task_1hcentk" />
      ' +
                  '    <exclusiveGateway id="ExclusiveGateway_15hu1pt" name="desired dish?">
      ' +
                  '      <incoming>SequenceFlow_0wnb4ke</incoming>
      ' +
                  '    </exclusiveGateway>
      ' +
                  '    <sequenceFlow id="SequenceFlow_0wnb4ke" sourceRef="Task_1hcentk" targetRef="ExclusiveGateway_15hu1pt" />
      ' +
                  '  </process>
      ' +
                  '  <bpmndi:BPMNDiagram id="BpmnDiagram_1">
      ' +
                  '    <bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Process_1">
      ' +
                  '      <bpmndi:BPMNShape id="StartEvent_1y45yut_di" bpmnElement="StartEvent_1y45yut">
      ' +
                  '        <omgdc:Bounds x="152" y="102" width="36" height="36" />
      ' +
                  '        <bpmndi:BPMNLabel>
      ' +
                  '          <omgdc:Bounds x="134" y="145" width="73" height="14" />
      ' +
                  '        </bpmndi:BPMNLabel>
      ' +
                  '      </bpmndi:BPMNShape>
      ' +
                  '      <bpmndi:BPMNShape id="Task_1hcentk_di" bpmnElement="Task_1hcentk">
      ' +
                  '        <omgdc:Bounds x="240" y="80" width="100" height="80" />
      ' +
                  '      </bpmndi:BPMNShape>
      ' +
                  '      <bpmndi:BPMNEdge id="SequenceFlow_0h21x7r_di" bpmnElement="SequenceFlow_0h21x7r">
      ' +
                  '        <omgdi:waypoint x="188" y="120" />
      ' +
                  '        <omgdi:waypoint x="240" y="120" />
      ' +
                  '      </bpmndi:BPMNEdge>
      ' +
                  '      <bpmndi:BPMNShape id="ExclusiveGateway_15hu1pt_di" bpmnElement="ExclusiveGateway_15hu1pt" isMarkerVisible="true">
      ' +
                  '        <omgdc:Bounds x="395" y="95" width="50" height="50" />
      ' +
                  '        <bpmndi:BPMNLabel>
      ' +
                  '          <omgdc:Bounds x="388" y="152" width="65" height="14" />
      ' +
                  '        </bpmndi:BPMNLabel>
      ' +
                  '      </bpmndi:BPMNShape>
      ' +
                  '      <bpmndi:BPMNEdge id="SequenceFlow_0wnb4ke_di" bpmnElement="SequenceFlow_0wnb4ke">
      ' +
                  '        <omgdi:waypoint x="340" y="120" />
      ' +
                  '        <omgdi:waypoint x="395" y="120" />
      ' +
                  '      </bpmndi:BPMNEdge>
      ' +
                  '    </bpmndi:BPMNPlane>
      ' +
                  '  </bpmndi:BPMNDiagram>
      ' +
                  '</definitions>';
      
               // import diagram
              bpmnJS.importXML(bpmnXML, function(err) {
                  if (!err) {
                      console.log('success!');
                      //
                      var canvas = bpmnJS.get('canvas')
                      canvas.zoom('fit-viewport')
                  } else {
                      return console.error('could not import BPMN 2.0 diagram', err);
                  }
              });
          </script>
      </body>
      
      </html>

      如上所示, 使用DNS加速直接引入bpmn.js, 然后本地指定一個容器(id為canvas的那個div), 接著用bpmn.js提供的方法importXML就可以解析xml字符串生成對應的工作流圖。

      2.使用npm安裝bpmn.js

      首先需要安裝bpmn-js

      npm install bpmn-js --save-dev

      安裝好這個只能支持在線繪制工作流,而不能對工作流上的每個節(jié)點進行屬性設置,這個時候需要安裝bpmn-js的一個panel插件。

      npm install  bpmn-js-properties-panel --save-dev

      示例代碼可參見 https://github.com/-io/bpmn-js-examples 里的properties-panel示例工程。

      運行效果如下

      npm run dev

      總結

      以上是生活随笔為你收集整理的bpmn-js画流程图 (一)基本安装使用的全部內容,希望文章能夠幫你解決所遇到的問題。

      如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。