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
2024-07-17 11:47:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b72c3b9858ba0e65b11c6fb71af08879d119a65d
b72c3b98
1 parent
f731c910
fix 启动流程之前会检查流程保存情况,如果条件允许自动保存流程信息
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
42 deletions
doc/index.vue
doc/index.vue
View file @
b72c3b9
...
...
@@ -410,7 +410,7 @@
</el-tooltip> -->
<div class="toolbar-buttons">
<div class="save-wrapper">
<div class="button-item" @click="saveData">保存</div>
<div class="button-item" @click="saveData
('manual')
">保存</div>
</div>
<div class="preview-wrapper">
<div class="button-item" @click="openPreview">预览测试</div>
...
...
@@ -1257,22 +1257,26 @@ export default {
* 启用版本
*/
const setFLowVersionEnable = async () => {
state.versionForm.type = 2;
const { code, data } = await enableFlowVersionAPI(state.versionForm);
if (code) {
ElMessage({
type: 'success',
message: '启用成功',
});
state.current_enable_version = state.versionForm.code; // 当前选中的版本号
state.dialogVersionFormVisible = false; // 关闭弹框
state.reloadLoading = true; // 打开loading
// 启动前,自动保存操作
let is_pass = await saveData('auto');
if (is_pass !== false) { // 不通过后会返回false,不返回false就是通过了
state.versionForm.type = 2;
const { code, data } = await enableFlowVersionAPI(state.versionForm);
if (code) {
ElMessage({
type: 'success',
message: '启用成功',
});
state.current_enable_version = state.versionForm.code; // 当前选中的版本号
state.dialogVersionFormVisible = false; // 关闭弹框
state.reloadLoading = true; // 打开loading
getVersionList(); // 刷新版本列表
updateFlowId(data); // 更新缓存flow_id
getFlowData(data); // 更新流程图数据
} else {
state.reloadLoading = false;
getVersionList(); // 刷新版本列表
updateFlowId(data); // 更新缓存flow_id
getFlowData(data); // 更新流程图数据
} else {
state.reloadLoading = false;
}
}
}
...
...
@@ -1949,7 +1953,7 @@ export default {
return models;
}
const batchSaveForm = async () => { // 批量保存节点信息
const batchSaveForm = async (
type
) => { // 批量保存节点信息
for (const key in state.node_tree) {
const element = state.node_tree[key];
// 把表单数据同步到提交数据(后端需要的字段和表单不是一个)
...
...
@@ -1982,10 +1986,10 @@ export default {
// } else {
// saveFlowData();
// }
saveFlowData();
saveFlowData(
type
);
}
const saveFlowData = async () => { // 保存流程图结构信息
const saveFlowData = async (
type
) => { // 保存流程图结构信息
let { nodes, edges } = editor.editorState.graph.save();
// 使用时需要把自定义节点的类型带过去 activity/control
...
...
@@ -2028,10 +2032,12 @@ export default {
if (code) {
updateFlowId(data); // 更新缓存flow_id
console.log(paths); // 输出满足条件的路径结果数组
ElMessage({
type: 'success',
message: '保存流程图成功',
});
if (type === 'manual') {
ElMessage({
type: 'success',
message: '保存流程图成功',
});
}
rawFlowData.value = flowData.value;
//
if (!_.isEmpty(state.node_tree)) {
...
...
@@ -2377,7 +2383,7 @@ export default {
}
return result.length;
}
const saveData = async () => {
const saveData = async (
type: string
) => {
// 清空错误提示
let { nodes } = editor.editorState.graph.save();
...
...
@@ -2396,17 +2402,17 @@ export default {
// TAG: 暂时不检查开始节点
checkResult.data = checkResult.data.filter(item => item !== 'start-node');
if (noticeError(checkResult)) {
return;
return
false
;
}
} else {
// 保存流程图结构
saveFlowData();
saveFlowData(
type
);
}
}
// 节点点击后,使用本地数据检查
if (checkNodeTree().length) {
return;
return
false
;
}
// TAG: 检查节点是否完整
...
...
@@ -2416,24 +2422,28 @@ export default {
// TAG: 暂时不检查开始节点
checkResult.data = checkResult.data.filter(item => item !== 'start-node');
if (noticeError(checkResult)) {
return;
return
false
;
}
}
ElMessageBox.confirm(
'是否确定保存流程?',
'温馨提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(async () => {
batchSaveForm();
})
.catch(() => {
});
if (type === 'manual') { // 手动触发保存按钮
ElMessageBox.confirm(
'是否确定保存流程?',
'温馨提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(async () => {
batchSaveForm(type);
})
.catch(() => {
});
} else { // 自动执行保存操作
batchSaveForm(type);
}
}
const startFlow = () => { // 启用流程图
...
...
Please
register
or
login
to post a comment