Lf工作流自定义html节点

1.定义js文件CustomCircle.js

import { HtmlNode, HtmlNodeModel } from "@logicflow/core";
class UmlModel extends HtmlNodeModel {
  setAttributes() {
    this.text.editable = false; // 禁止节点文本编辑
    // 设置节点宽高和锚点
    const width = 120;
    const height = 70;
    this.width = width;
    this.height = height;
    this.anchorsOffset = [
      [width / 2, 0],
      [0, height / 2],
      [-width / 2, 0],
      [0, -height / 2],
    ];
  }
}
class UmlNode extends HtmlNode {
  setHtml(rootEl) {
    const { properties } = this.props.model;
     console.log(3333,properties);
    const el = document.createElement("div");
    el.className = "uml-wrapper";
    const html = `
      <div class='allcontent'>
      ${properties.process}
      </div>
    `;
    el.innerHTML = html;
    // 需要先把之前渲染的子节点清除掉。
    rootEl.innerHTML = "";
    rootEl.appendChild(el);
  }
}

export default {
  type: "CustomCircleNode",
  view: UmlNode,
  model: UmlModel
};

2.其中 properties 值为 .vue文件中 

import { HtmlNode, HtmlNodeModel, LogicFlow } from "@logicflow/core";
import { Control, DndPanel, SelectionSelect, Menu } from "@logicflow/extension";
import CustomCircleNode from "./components/CustomCircle.js";
import "@logicflow/core/dist/style/index.css";
import "@logicflow/extension/lib/style/index.css";
data() {
    return {
      lf: "",
      graphData: {
        nodes: [],
        edges: []
      },
      width: "",
      height: ""
    };
  },
mounted() {
    this.lf = new LogicFlow({
      container: this.$refs.container,
      grid: true,
      plugins: [Control, DndPanel, SelectionSelect, Menu]
    });
    this.lf.register(CustomCircleNode);
    this.lf.extension.dndPanel.setPatternItems([
      {
        label: "选区",
        icon:
          "data:,
        callback: () => {
          this.lf.extension.selectionSelect.openSelectionSelect();
          this.lf.once("selection:selected", () => {
            this.lf.extension.selectionSelect.closeSelectionSelect();
          });
        }
      },
      {
        type: "CustomCircleNode",
        text: "",
        label: "电池箱装配",
        icon:
          "data:",
        properties: {
          process: "电池箱装配"
        }
      }
    ]);
    this.lf.render(this.graphData);
  },

 

相关推荐

  1. Lf工作定义html节点

    2024-06-07 04:46:03       25 阅读
  2. Android 定义解析html标签

    2024-06-07 04:46:03       37 阅读
  3. C++ LP 开头字符串定义类型

    2024-06-07 04:46:03       26 阅读
  4. Node-RED 规则引擎重构:添加定义节点

    2024-06-07 04:46:03       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-07 04:46:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-07 04:46:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-06-07 04:46:03       82 阅读
  4. Python语言-面向对象

    2024-06-07 04:46:03       91 阅读

热门阅读

  1. 023、键管理_数据库

    2024-06-07 04:46:03       27 阅读
  2. dubbo服务调用过程

    2024-06-07 04:46:03       28 阅读
  3. 数据计算的基本模式与范式

    2024-06-07 04:46:03       30 阅读
  4. matlab计算图像信噪比SNR

    2024-06-07 04:46:03       32 阅读
  5. 待定待定待定

    2024-06-07 04:46:03       35 阅读
  6. 原生js访问http获取数据的方法

    2024-06-07 04:46:03       27 阅读
  7. CSS中z-index不生效的原因和解决办法

    2024-06-07 04:46:03       32 阅读
  8. 21data 数据可视化

    2024-06-07 04:46:03       35 阅读
  9. Python 设计模式(行为型)

    2024-06-07 04:46:03       23 阅读
  10. 【设计模式】单例模式(创建型)⭐⭐⭐

    2024-06-07 04:46:03       29 阅读
  11. 完全背包(从二维数组到一维滚动数组)

    2024-06-07 04:46:03       29 阅读