hookehuyr

fix 启动流程之前会检查流程保存情况,如果条件允许自动保存流程信息

......@@ -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 = () => { // 启用流程图
......