Showing
3 changed files
with
178 additions
and
1 deletions
| ... | @@ -115,6 +115,11 @@ const router = createRouter({ | ... | @@ -115,6 +115,11 @@ const router = createRouter({ |
| 115 | name: 'snapshot', | 115 | name: 'snapshot', |
| 116 | component: () => import('../views/snapshot/index.vue') | 116 | component: () => import('../views/snapshot/index.vue') |
| 117 | }, | 117 | }, |
| 118 | + { | ||
| 119 | + path: '/dynamic-group', | ||
| 120 | + name: 'dynamic-group', | ||
| 121 | + component: () => import('../views/dynamic-group/index.vue') | ||
| 122 | + }, | ||
| 118 | ] | 123 | ] |
| 119 | }) | 124 | }) |
| 120 | 125 | ... | ... |
src/views/dynamic-group/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="container"> | ||
| 3 | + <div ref="container" class="flow-container"></div> | ||
| 4 | + <div class="control-panel"> | ||
| 5 | + <el-button @click="openSelectionSelect">选区</el-button> | ||
| 6 | + <div v-for="item in dndConfig" :key="item.type" class="dnd-item"> | ||
| 7 | + <img :src="item.icon" :alt="item.label" /> | ||
| 8 | + <span>{{ item.label }}</span> | ||
| 9 | + </div> | ||
| 10 | + </div> | ||
| 11 | + </div> | ||
| 12 | +</template> | ||
| 13 | + | ||
| 14 | +<script setup> | ||
| 15 | +import LogicFlow from "@logicflow/core"; | ||
| 16 | +import { DynamicGroup } from "@logicflow/extension"; | ||
| 17 | + | ||
| 18 | +const container = ref(null); | ||
| 19 | +let lf = null; | ||
| 20 | + | ||
| 21 | +// 拖拽面板配置 | ||
| 22 | +const dndConfig = [ | ||
| 23 | + { | ||
| 24 | + type: 'dynamic-group', | ||
| 25 | + label: '内置动态分组', | ||
| 26 | + text: 'DynamicGroup', | ||
| 27 | + icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/group/group.png', | ||
| 28 | + }, | ||
| 29 | + { | ||
| 30 | + type: 'circle', | ||
| 31 | + label: '圆形', | ||
| 32 | + text: 'Circle', | ||
| 33 | + icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/group/circle.png', | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + type: 'rect', | ||
| 37 | + label: '矩形', | ||
| 38 | + text: 'Rect', | ||
| 39 | + icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/group/rect.png', | ||
| 40 | + }, | ||
| 41 | +]; | ||
| 42 | + | ||
| 43 | +// 选区功能 | ||
| 44 | +const openSelectionSelect = () => { | ||
| 45 | + if (lf) { | ||
| 46 | + lf.openSelectionSelect(); | ||
| 47 | + lf.once('selection:selected', () => { | ||
| 48 | + lf.closeSelectionSelect(); | ||
| 49 | + }); | ||
| 50 | + } | ||
| 51 | +}; | ||
| 52 | + | ||
| 53 | +onMounted(() => { | ||
| 54 | + lf = new LogicFlow({ | ||
| 55 | + container: container.value, | ||
| 56 | + grid: true, | ||
| 57 | + multipleSelectKey: "alt", | ||
| 58 | + autoExpand: false, | ||
| 59 | + allowResize: true, | ||
| 60 | + allowRotate: true, | ||
| 61 | + nodeTextDraggable: false, | ||
| 62 | + keyboard: { | ||
| 63 | + enabled: true, | ||
| 64 | + }, | ||
| 65 | + plugins: [DynamicGroup], | ||
| 66 | + }); | ||
| 67 | + | ||
| 68 | + // 设置拖拽面板 | ||
| 69 | + const dndPanelConfig = [ | ||
| 70 | + { | ||
| 71 | + label: '选区', | ||
| 72 | + icon: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/examples/extension/bpmn/select.png', | ||
| 73 | + callback: openSelectionSelect, | ||
| 74 | + }, | ||
| 75 | + ...dndConfig, | ||
| 76 | + ]; | ||
| 77 | + lf.setPatternItems(dndPanelConfig); | ||
| 78 | + | ||
| 79 | + // 渲染数据 | ||
| 80 | + const graphData = { | ||
| 81 | + nodes: [ | ||
| 82 | + { | ||
| 83 | + id: 'circle_2', | ||
| 84 | + type: 'circle', | ||
| 85 | + x: 800, | ||
| 86 | + y: 140, | ||
| 87 | + text: { | ||
| 88 | + value: 'circle_2', | ||
| 89 | + x: 800, | ||
| 90 | + y: 140, | ||
| 91 | + editable: false, | ||
| 92 | + draggable: true, | ||
| 93 | + }, | ||
| 94 | + }, | ||
| 95 | + { | ||
| 96 | + id: 'dynamic-group_1', | ||
| 97 | + type: 'dynamic-group', | ||
| 98 | + x: 500, | ||
| 99 | + y: 140, | ||
| 100 | + text: 'dynamic-group_1', | ||
| 101 | + resizable: true, | ||
| 102 | + properties: { | ||
| 103 | + collapsible: true, | ||
| 104 | + width: 420, | ||
| 105 | + height: 250, | ||
| 106 | + radius: 5, | ||
| 107 | + isCollapsed: true, | ||
| 108 | + }, | ||
| 109 | + }, | ||
| 110 | + { | ||
| 111 | + id: 'dynamic-group_2', | ||
| 112 | + type: 'dynamic-group', | ||
| 113 | + x: 500, | ||
| 114 | + y: 220, | ||
| 115 | + text: 'dynamic-group_2', | ||
| 116 | + resizable: true, | ||
| 117 | + properties: { | ||
| 118 | + width: 420, | ||
| 119 | + height: 250, | ||
| 120 | + radius: 5, | ||
| 121 | + collapsible: false, | ||
| 122 | + isCollapsed: false, | ||
| 123 | + }, | ||
| 124 | + }, | ||
| 125 | + ], | ||
| 126 | + edges: [], | ||
| 127 | + }; | ||
| 128 | + | ||
| 129 | + lf.render(graphData); | ||
| 130 | +}); | ||
| 131 | +</script> | ||
| 132 | + | ||
| 133 | +<style scoped> | ||
| 134 | +.container { | ||
| 135 | + width: 100vw; | ||
| 136 | + height: 100vh; | ||
| 137 | + display: flex; | ||
| 138 | + flex-direction: column; | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +.flow-container { | ||
| 142 | + flex: 1; | ||
| 143 | + width: 100%; | ||
| 144 | + height: 100%; | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +.control-panel { | ||
| 148 | + position: absolute; | ||
| 149 | + top: 20px; | ||
| 150 | + left: 20px; | ||
| 151 | + display: flex; | ||
| 152 | + gap: 10px; | ||
| 153 | + align-items: center; | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +.dnd-item { | ||
| 157 | + display: flex; | ||
| 158 | + flex-direction: column; | ||
| 159 | + align-items: center; | ||
| 160 | + cursor: pointer; | ||
| 161 | + padding: 8px; | ||
| 162 | + border: 1px solid #ddd; | ||
| 163 | + border-radius: 4px; | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +.dnd-item img { | ||
| 167 | + width: 24px; | ||
| 168 | + height: 24px; | ||
| 169 | + margin-bottom: 4px; | ||
| 170 | +} | ||
| 171 | +</style> |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-10 14:37:31 | 2 | * @Date: 2025-03-10 14:37:31 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-13 23:00:31 | 4 | + * @LastEditTime: 2025-03-14 13:53:06 |
| 5 | * @FilePath: /logic-flow2/src/views/home.vue | 5 | * @FilePath: /logic-flow2/src/views/home.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -27,6 +27,7 @@ | ... | @@ -27,6 +27,7 @@ |
| 27 | <el-button type="primary" @click="goTo('mini-map')">mini-map</el-button> | 27 | <el-button type="primary" @click="goTo('mini-map')">mini-map</el-button> |
| 28 | <el-button type="primary" @click="goTo('selection-select')">selection-select</el-button> | 28 | <el-button type="primary" @click="goTo('selection-select')">selection-select</el-button> |
| 29 | <el-button type="primary" @click="goTo('snapshot')">snapshot</el-button> | 29 | <el-button type="primary" @click="goTo('snapshot')">snapshot</el-button> |
| 30 | + <el-button type="primary" @click="goTo('dynamic-group')">dynamic-group</el-button> | ||
| 30 | </template> | 31 | </template> |
| 31 | 32 | ||
| 32 | <script setup> | 33 | <script setup> | ... | ... |
-
Please register or login to post a comment