Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
vue-flow-editor
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2023-11-20 13:08:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
36f909af452e36ae9bae9aa60cb6226d77d0156a
36f909af
1 parent
91e520c8
复制节点功能完善
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
doc/App.vue
src/editor/vue-flow-editor.tsx
doc/App.vue
View file @
36f909a
...
...
@@ -2,6 +2,7 @@
<div class="app" style="height: 100vh">
<vue-flow-editor
ref="editor"
menuWidth="180px"
modelWidth="300px"
:data="state.data"
:grid="showGrid"
...
...
@@ -653,6 +654,7 @@ export default {
/********** 流程图功能函数 **********/
let editor: {
clearStates(arg0: any): () => void
openModel: () => void
closeModel: () => void
addNode: (arg0: any) => void
...
...
@@ -1010,11 +1012,16 @@ export default {
const copyData = () => { // 复制节点回调
if (state.detailModel.control !== 'start' && state.detailModel.control !== 'end') {
editor.clearStates(state.detailModel.id); // 清除选中节点的状态
const timestamp = Date.now();
const random = timestamp + '';
state.detailModel.id = random; // ID需要重新生成
state.detailModel.y = state.detailModel.y + 50
editor.addNode(state.detailModel);
editor.closeModel();
// 保存流程图数据
state.data.nodes = editor.editorState.graph.save().nodes
state.data.edges = editor.editorState.graph.save().edges
} else {
ElNotification.error('开始或者结束节点不可以复制')
}
...
...
src/editor/vue-flow-editor.tsx
View file @
36f909a
...
...
@@ -109,6 +109,10 @@ export default {
} else {
console.warn('graph is not initialized')
}
},
clearStates: (id) => {
let item = editorState.graph.findById(id)
item.clearStates('selected')
}
}
provide(VueFlowEditorProvider, provideContext)
...
...
Please
register
or
login
to post a comment