bpmnjs 多实例 - 手动设置

前言

项目上使用了bpmn,在配置多实例时不会写,于是在网上找各种资料,只找到一些稀稀疏疏的,头疼了一天。终于自己写出来了。代码注释就不写了,看一看就能知道大概意思了。
哪里不了解也可以评论区问我。

直接上代码

const moddle = this.bpmnModeler.get("moddle")
const elementFactory = this.bpmnModeler.get("elementFactory")
const bpmnFactory = this.bpmnModeler.get("bpmnFactory")

let loopCharacteristics = moddle.create("bpmn:MultiInstanceLoopCharacteristics");
loopCharacteristics.$attrs['isSequential'] = false;

let loopCardinality = bpmnFactory.create("bpmn:Expression",{
   body: "4"
});

let completionCondition = bpmnFactory.create(
  "bpmn:FormalExpression",
  {
    body: "${nrOfCompletedInstances/nrOfInstances >= 0.50}"
  }
);

completionCondition.$parent = this.activeBpmn
loopCardinality.$parent = this.activeBpmn
loopCharacteristics["completionCondition"] = completionCondition;
loopCharacteristics["loopCardinality"] = loopCardinality;

this.modeling.updateProperties(this.activeBpmn, {
  loopCharacteristics: loopCharacteristics
});

你可能感兴趣的:(web前端,javascript,js,vue)