vue实现流程图拖拽连线编排示例代码
代码语言:html
所属分类:拖放
代码描述:vue实现流程图拖拽连线编排示例代码,没有使用插件,vue原生实现,模仿了ai智能体的工作流编排。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Vue Drag and Drop Flowchart</title> <style> body { font-family: Arial, sans-serif; } .container { position: relative; width: 100vw; height: 100vh; background-color: #f0f0f0; overflow: hidden; } .node { position: absolute; width: 100px; height: 100px; background-color: #fff; border: 1px solid #ccc; box-shadow: 2px 2px 3px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center; cursor: grab; } .connector { width: 10px; height: 10px; background-color: red; position: absolute; cursor: pointer; } .connector-left { left: -5px; top: 50%; transform: translateY(-50%); } .connector-right { right: -5px; top: 50%; transform: translateY(-50%); } svg { position: absolute; top: 0; left: 0; overflow: visible; } path { stroke: black; stroke-width: 2; fill: none; } </style> </head> <body> <div id="app"> <div class="container" ref="container" @mousedown="onCanvasMouseDown($event)"> <div v-for="node in nodes" :key="node.id" :style="{ left: node.x + 'px', top: node.y + 'px' }" class="node" @mousedown.stop="onNodeMouseDown(node, $event)" :data-node-id="node.id"> {{ node.name }} <div class="connector connector-left"></div> <div class="connector connector-right" @mousedown.stop="startConnecting(node, 'right', $event)"></div> </div> <svg v-for="line in lines" :key="line.id"> <path :d="generatePath(line)"></path> </svg> <svg v-if="connecting"> <path :d="generateTempPath()"></path> </svg> </div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2..........完整代码请登录后点击上方下载按钮下载查看
网友评论0