基于Bpmn-js的流程设计器校验实现(1)-获取所有问题

251 阅读1分钟

基于上一篇《基于Bpmn-js的流程设计器校验实现》

源码分析中发现

image.png

看到issues 这个单词是不有点冲动

大概率是获取问题列表的,下边我们进行验证一下 参考他的代码我们也来个监听

      const eventBus = this.bpmnModeler.get('eventBus');
      eventBus.once('linting.completed', function (event) {
        // then
        const issues = event.issues;
        console.log("issues:", issues);
      });

输出结果 这不就我们想要的嘛

{
    "process_381822156625809408": [
        {
            "id": "process_381822156625809408",
            "message": "Process is missing end event",
            "category": "error",
            "rule": "end-event-required"
        }
    ],
    "StartEvent_01ydzqe": [
        {
            "id": "StartEvent_01ydzqe",
            "message": "Element is not connected",
            "category": "error",
            "rule": "no-disconnected"
        }
    ]
}

有了这个我们就能做很多事情了,像这个就可以定义成我们能想到任何格式了.

image.png

你要做成什么样我也不知道,我做的也不一定是你想要的.

所有下边就需要你自由发挥吧, 加油吧少年

下一步计划

  • 研究下,他的提示能改成中文吗? (反正我的英文不好,看着英文别扭)

如果感觉不错,请点个赞