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-12-04 11:14:48 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ddc5f7ef0e533b1f0cd23837ac145107aabce5b4
ddc5f7ef
1 parent
410ebb60
新增流程版本复制功能
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
1 deletions
doc/App.vue
doc/App.vue
View file @
ddc5f7e
...
...
@@ -324,7 +324,7 @@
<span v-if="item.code === state.current_enable_version" style="background: #edf9f1; border-color: #46c26f; color: #46c26f; font-size: 10px; padding: 0 5px; border-radius: 3px; margin-left: 8px;">启用中</span>
<!-- <span @click="showEditFlowVersion(item.id, item.code, item.note)" style="margin-left: 10px;">
<i class="el-icon-edit-outline"></i>
</span>
-->
-->
</el-dropdown-item>
<el-dropdown-item @click.native="addFlowVersion" style="justify-content: center;">
<i class="el-icon-circle-plus-outline"></i>新增流程
...
...
@@ -364,6 +364,17 @@
</el-popconfirm>
<el-popconfirm
v-if="state.current_enable_version !== state.versionForm.code"
title="是否确认复制该版本流程?"
width="220px"
confirm-button-text="确认"
cancel-button-text="取消"
@confirm="copyFLowVersion">
<template #reference>
<el-button type="warning">复制流程</el-button>
</template>
</el-popconfirm>
<el-popconfirm
v-if="state.current_enable_version !== state.versionForm.code"
title="是否确认删除该版本流程?"
width="220px"
confirm-button-text="确认"
...
...
@@ -768,6 +779,70 @@ export default {
}
}
const copyFLowVersion = async () => { // 复制版本流程
let { nodes, edges } = editor.editorState.graph.save();
// 使用时需要把自定义节点的类型带过去 activity/control
nodes.forEach((node: { [x: string]: string; shape: string }) => {
if (node.shape === 'control') {
node['control'] = node['control']
}
});
nodes = nodes.map(
({ data, id, label, shape, x, y, text, desc, img, control }) => ({
data,
id,
label,
shape,
x,
y,
text,
desc,
img,
control,
}),
);
edges = edges.map(({ shape, source, sourceAnchor, target, targetAnchor }) => ({
shape,
source,
sourceAnchor,
target,
targetAnchor,
}));
// 检查路径有效性
const paths = [];
findPathsToEndNode(edges, 'start-node', [], paths);
state.dialogVersionFormVisible = false; // 关闭弹框
if (paths.length) {
const { code, data } = await saveFlowAPI({ form_id: +form_id, flow_id: '', data: JSON.stringify({ nodes, edges }) });
if (code) {
state.reloadLoading = true; // 打开 loading
ElMessage({
type: 'success',
message: '复制成功',
});
updateFlowId(data); // 更新缓存 flow_id
getFlowData(data); // 更新流程图数据
const flow_version = await flowVersionAPI({ form_id });
if (flow_version.code) {
state.version_list = flow_version.data; // 更新版本列表
state.version_list.forEach((ele) => {
if (ele.id === +data) {
state.select_flow_version = ele.code; // 选中新增的版本
}
});
}
}
} else {
ElNotification.error('缺少一条从开始节点到结束节点的完整流程!');
}
}
/**
* 编辑版本
*/
...
...
@@ -1569,6 +1644,7 @@ export default {
showEditFlowVersion,
addFlowVersion,
setFLowVersionEnable,
copyFLowVersion,
editFlowVersion,
deleteFlowVersion,
saveFlowVersionNote,
...
...
Please
register
or
login
to post a comment