Git Product home page Git Product logo

vue-super-flow's Introduction

vue-super-flow

  • A flowchart editor component base on Vue.
  • Vue flowchart.
  • Vue 流程图。
  • Demo
  • docs

Installation


npm install vue-super-flow

yarn add vue-super-flow

import SuperFlow from 'vue-super-flow'
import 'vue-super-flow/lib/index.css'

Vue.use(SuperFlow)

Attributes

属性 类型 默认值 描述
relationMark String "id" 可个性化 node 的标识
startMark String "startId" 可个性化 link 的起始标识
endMark String "endId" 可个性化 link 的终点标识
draggable Boolean true 是否开启节点拖拽
linkAddable Boolean true 是否开启快捷创建 link
linkEditable Boolean true link 是否可编辑
hasMarkLine Boolean true 是否开启拖拽辅助线
markLineColor String #55abfc 辅助线颜色
origin Array [0, 0] graph 的二维坐标系原点
nodeList Array [] 初始化节点列表
linkList Array [] 初始化连线列表
graphMenu Array [] graph 的右键菜单列表配置
nodeMenu Array [] node 右键菜单列表配置
linkMenu Array [] link 右键菜单配置
enterIntercept Function () => true 创建连线进入节点限制
outputIntercept Function () => true 节点生成连线限制函数
linkDesc Function null 生成 link 定制描述文字
linkStyle Function null 根据 link 定制样式
linkBaseStyle Object {} 连线默认样式配置

linkDesc

function linkDesc (link) {
  /**
   根据 link 对象的属性判断定制连线描述
   */
  return link.meta ? link.meta.info : ''
}

linkBaseStyle

/*
// 内置默认样式配置
{
   hover: '#FF0000',        // 连线 hover 时颜色
   color: '#666666',        // 连线颜色
   textColor: '#666666',    // 连线描述文字颜色
   textHover: '#FF0000',    // 连线 hover 时描述文字颜色
   font: '14px Arial',      // 连线 描述文字 font 参考 https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/font
   dotted: false,           // 连线 是否是虚线
   lineDash: [4, 4],        // 为虚线时 虚线参数  参考:https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
   background: 'rgba(255,255,255,0.6)'  // 描述文字背景  
}
*/

{
  // ... 可选属性 参考内置默认样式 用来覆盖连线样式的默认值
}

linkStyle

function linkStyle (link) {
  /**
   根据 link 对象的属性判断定制连线样式
   */
  return {
    // ... 可选属性 参考:[linkBaseStyle](#linkBaseStyle)
  }
}

Methods

方法名 说明 参数
selectAll 选中所有进行拖拽修改 origin ----
toJSON graph 对象转为普通 json 对象 ----
getMouseCoordinate 获取当前鼠标在 graph 坐标系的坐标 clientX, clientY
addNode 添加节点 options

Example

默认示例

进阶示例

vue-super-flow's People

Contributors

caohuatao avatar dependabot[bot] avatar tanglk avatar wuchenguang1998 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-super-flow's Issues

linkStyle方法参数link为undefined

<super-flow
    ref="superFlow"
    :link-style="linkStyle"
>
linkStyle(link) {
    console,log(link)      /// 这里报错了,undefined
    const style = {}
    return link.flag? style : ''
},

编辑单击无效

看了您的作品,很感兴趣,但是我发现demo里面的编辑按钮单击之后无效,是有bug吗

能否通过json生成可视化流程图?

能否通过类似如下的json生成可视化的流程图?
{
"id": "00000",
"meta": {
"prop": "start",
"name": "条件节点1"
}
children: [{
"id": "11111",
"meta": {
"prop": "start",
"name": "条件节点1"
}
},
{
"id": "22222",
"meta": {
"prop": "start",
"name": "条件节点2"
},
},

]

}

尝试在已有项目中集成,每个节点内容无法展示,右键菜单已经配置,也不能正常展示,有选项,但是无内容

项目采用iview-admin的样式库
在已有项目中引入 ,每个节点内容无法展示,右键菜单已经配置,也不能正常展示:有选项,但是无内容,报错如下:Property or method "meta" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

已经尝试把组件原码copy进项目,也有该问题
尝试搭建了新项目,可以正常使用。所以求作者大大解惑
iview-admin demo地址:https://github.com/view-design/iview-admin

node slot点击事件无法监听到第一次点击

      <template v-slot:node="{meta}">
        <div :class="`flow-node flow-node-${meta.prop}`" >
          <header class="ellipsis" @click.prevent="clickNode(meta.name)">{{meta.name}}</header>
          <section>{{meta.desc}}</section>
        </div>
      </template>

    const clickNode = (name: string) => {
      console.log(name);
    };

在示例上增加了一个node click事件,结果第一次点击node不触发,第二次点击才能出发clickNode事件,请问这个可以解决吗

根据josn能生成图形吗?

直接把json赋值给this.$refs.superFlow.graph并不能展示

"origin": [
0,
0
],
"nodeList": [
{
"id": "node43bEDxs4QYLxYqA8",
"width": 120,
"height": 40,
"coordinate": [
293.11109924316406,
115.24305725097656
],
"meta": {
"nodeSn": "20201117155528475709",
"nodeType": 12,
"name": "swooptask222",
"retryTimes": "2"
}
},
{
"id": "nodex3J2Ah7U3lf3ohnK",
"width": 120,
"height": 40,
"coordinate": [
214.11109924316406,
212.24305725097656
],
"meta": {
"nodeType": 1,
"processInfoSn": "20201118144643126323",
"name": "qwe",
"flag": 1,
"isSubProcess": 1,
"releaseState": 1,
"processLevel": 1,
"runStrategy": 2,
"projectSn": "20201111151301378332",
"hasEvent": 1
}
}
],
"linkList": [
{
"id": "linkqUDpYBsyXW857ojR",
"startId": "node43bEDxs4QYLxYqA8",
"endId": "nodex3J2Ah7U3lf3ohnK",
"startAt": [
60,
40
],
"endAt": [
120,
20
],
"meta": null
}
]
}

节点插槽v-slot传递的值怎么改成node,而不是node.meta对象

我对vue的插槽不是很理解,我需要把节点插槽中原本v-slot:node="{meta}”,原来是node.meta对象,想改成是node对象。
我目前需要修改源码node.vue里面的代码

<div
    tabindex="-1"
    class="super-flow__node"
    :class="{'can-move': nodeDrop}"
    :style="style"
    @mousedown.left="nodeMousedown"
    @mouseenter="nodeMouseenter"
    @mouseleave="nodeMouseleave"
    @mouseup="nodeMouseup"
    @contextmenu.prevent.stop="nodeContextmenu">

    // **把这里改成<slot :meta="node"></slot>**
    <slot :meta="node.meta"></slot>

    <div
      v-for="(dir, key) in direction"
      v-show="output && lineDrop"
      :class="`node-side node-side-${key}`"
      @contextmenu.stop.prevent
      @mousedown.left.prevent.stop="evt => sideMousedown(evt, dir)">
    </div>
  </div>

能不能在不修改源代码的前提下,在使用template插槽的时候改成node对象?
如果不行,我是不是要自己修改源代码,然后打包插件自己使用呢?

可编辑的节点

大佬,有没有可编辑输入的例子。小白太可怜了,刚进公司就被搞这种流程图

vue 2.5加载失败

error in ./node_modules/vue-super-flow/lib/index.css

Module build failed: BrowserslistError: Unknown browser query dead
at D:\work\subway\node_modules\browserslist\index.js:164:11
at Array.reduce ()
at resolve (D:\work\subway\node_modules\browserslist\index.js:132:18)
at browserslist (D:\work\subway\node_modules\browserslist\index.js:224:16)
at Browsers.parse (D:\work\subway\node_modules\autoprefixer\lib\browsers.js:61:16)
at new Browsers (D:\work\subway\node_modules\autoprefixer\lib\browsers.js:52:30)
at loadPrefixes (D:\work\subway\node_modules\autoprefixer\lib\autoprefixer.js:70:24)
at plugin (D:\work\subway\node_modules\autoprefixer\lib\autoprefixer.js:81:24)
at LazyResult.run (D:\work\subway\node_modules\postcss\lib\lazy-result.js:277:20)
at LazyResult.asyncTick (D:\work\subway\node_modules\postcss\lib\lazy-result.js:192:32)
at LazyResult.asyncTick (D:\work\subway\node_modules\postcss\lib\lazy-result.js:204:22)
at D:\work\subway\node_modules\postcss\lib\lazy-result.js:197:27

@ ./node_modules/vue-super-flow/lib/index.css 4:14-118 13:3-17:5 14:22-126
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

这是报错内容

关于css引入的问题

尊敬的大佬,您好,
请问一下
`Failed to compile.

./node_modules/css-loader??ref--5-1!./node_modules/postcss-loader/lib??ref--5-2!./node_modules/vue-super-flow/lib/index.css
Module build failed: BrowserslistError: Unknown browser query `dead``

请问这个是什么问题哈

browserslist no dead 报错

删掉 no dead 参数才不报错
否则 Module build failed: BrowserslistError: Unknown browser query dead

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.