hookehuyr

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

...@@ -410,7 +410,7 @@ ...@@ -410,7 +410,7 @@
410 </el-tooltip> --> 410 </el-tooltip> -->
411 <div class="toolbar-buttons"> 411 <div class="toolbar-buttons">
412 <div class="save-wrapper"> 412 <div class="save-wrapper">
413 - <div class="button-item" @click="saveData">保存</div> 413 + <div class="button-item" @click="saveData('manual')">保存</div>
414 </div> 414 </div>
415 <div class="preview-wrapper"> 415 <div class="preview-wrapper">
416 <div class="button-item" @click="openPreview">预览测试</div> 416 <div class="button-item" @click="openPreview">预览测试</div>
...@@ -1257,6 +1257,9 @@ export default { ...@@ -1257,6 +1257,9 @@ export default {
1257 * 启用版本 1257 * 启用版本
1258 */ 1258 */
1259 const setFLowVersionEnable = async () => { 1259 const setFLowVersionEnable = async () => {
1260 + // 启动前,自动保存操作
1261 + let is_pass = await saveData('auto');
1262 + if (is_pass !== false) { // 不通过后会返回false,不返回false就是通过了
1260 state.versionForm.type = 2; 1263 state.versionForm.type = 2;
1261 const { code, data } = await enableFlowVersionAPI(state.versionForm); 1264 const { code, data } = await enableFlowVersionAPI(state.versionForm);
1262 if (code) { 1265 if (code) {
...@@ -1275,6 +1278,7 @@ export default { ...@@ -1275,6 +1278,7 @@ export default {
1275 state.reloadLoading = false; 1278 state.reloadLoading = false;
1276 } 1279 }
1277 } 1280 }
1281 + }
1278 1282
1279 const copyFLowVersion = async () => { // 复制版本流程 1283 const copyFLowVersion = async () => { // 复制版本流程
1280 state.dialogVersionFormVisible = false; // 关闭弹框 1284 state.dialogVersionFormVisible = false; // 关闭弹框
...@@ -1949,7 +1953,7 @@ export default { ...@@ -1949,7 +1953,7 @@ export default {
1949 return models; 1953 return models;
1950 } 1954 }
1951 1955
1952 - const batchSaveForm = async () => { // 批量保存节点信息 1956 + const batchSaveForm = async (type) => { // 批量保存节点信息
1953 for (const key in state.node_tree) { 1957 for (const key in state.node_tree) {
1954 const element = state.node_tree[key]; 1958 const element = state.node_tree[key];
1955 // 把表单数据同步到提交数据(后端需要的字段和表单不是一个) 1959 // 把表单数据同步到提交数据(后端需要的字段和表单不是一个)
...@@ -1982,10 +1986,10 @@ export default { ...@@ -1982,10 +1986,10 @@ export default {
1982 // } else { 1986 // } else {
1983 // saveFlowData(); 1987 // saveFlowData();
1984 // } 1988 // }
1985 - saveFlowData(); 1989 + saveFlowData(type);
1986 } 1990 }
1987 1991
1988 - const saveFlowData = async () => { // 保存流程图结构信息 1992 + const saveFlowData = async (type) => { // 保存流程图结构信息
1989 let { nodes, edges } = editor.editorState.graph.save(); 1993 let { nodes, edges } = editor.editorState.graph.save();
1990 1994
1991 // 使用时需要把自定义节点的类型带过去 activity/control 1995 // 使用时需要把自定义节点的类型带过去 activity/control
...@@ -2028,10 +2032,12 @@ export default { ...@@ -2028,10 +2032,12 @@ export default {
2028 if (code) { 2032 if (code) {
2029 updateFlowId(data); // 更新缓存flow_id 2033 updateFlowId(data); // 更新缓存flow_id
2030 console.log(paths); // 输出满足条件的路径结果数组 2034 console.log(paths); // 输出满足条件的路径结果数组
2035 + if (type === 'manual') {
2031 ElMessage({ 2036 ElMessage({
2032 type: 'success', 2037 type: 'success',
2033 message: '保存流程图成功', 2038 message: '保存流程图成功',
2034 }); 2039 });
2040 + }
2035 rawFlowData.value = flowData.value; 2041 rawFlowData.value = flowData.value;
2036 // 2042 //
2037 if (!_.isEmpty(state.node_tree)) { 2043 if (!_.isEmpty(state.node_tree)) {
...@@ -2377,7 +2383,7 @@ export default { ...@@ -2377,7 +2383,7 @@ export default {
2377 } 2383 }
2378 return result.length; 2384 return result.length;
2379 } 2385 }
2380 - const saveData = async () => { 2386 + const saveData = async (type: string) => {
2381 // 清空错误提示 2387 // 清空错误提示
2382 let { nodes } = editor.editorState.graph.save(); 2388 let { nodes } = editor.editorState.graph.save();
2383 2389
...@@ -2396,17 +2402,17 @@ export default { ...@@ -2396,17 +2402,17 @@ export default {
2396 // TAG: 暂时不检查开始节点 2402 // TAG: 暂时不检查开始节点
2397 checkResult.data = checkResult.data.filter(item => item !== 'start-node'); 2403 checkResult.data = checkResult.data.filter(item => item !== 'start-node');
2398 if (noticeError(checkResult)) { 2404 if (noticeError(checkResult)) {
2399 - return; 2405 + return false;
2400 } 2406 }
2401 } else { 2407 } else {
2402 // 保存流程图结构 2408 // 保存流程图结构
2403 - saveFlowData(); 2409 + saveFlowData(type);
2404 } 2410 }
2405 } 2411 }
2406 2412
2407 // 节点点击后,使用本地数据检查 2413 // 节点点击后,使用本地数据检查
2408 if (checkNodeTree().length) { 2414 if (checkNodeTree().length) {
2409 - return; 2415 + return false;
2410 } 2416 }
2411 2417
2412 // TAG: 检查节点是否完整 2418 // TAG: 检查节点是否完整
...@@ -2416,10 +2422,11 @@ export default { ...@@ -2416,10 +2422,11 @@ export default {
2416 // TAG: 暂时不检查开始节点 2422 // TAG: 暂时不检查开始节点
2417 checkResult.data = checkResult.data.filter(item => item !== 'start-node'); 2423 checkResult.data = checkResult.data.filter(item => item !== 'start-node');
2418 if (noticeError(checkResult)) { 2424 if (noticeError(checkResult)) {
2419 - return; 2425 + return false;
2420 } 2426 }
2421 } 2427 }
2422 2428
2429 + if (type === 'manual') { // 手动触发保存按钮
2423 ElMessageBox.confirm( 2430 ElMessageBox.confirm(
2424 '是否确定保存流程?', 2431 '是否确定保存流程?',
2425 '温馨提示', 2432 '温馨提示',
...@@ -2430,10 +2437,13 @@ export default { ...@@ -2430,10 +2437,13 @@ export default {
2430 } 2437 }
2431 ) 2438 )
2432 .then(async () => { 2439 .then(async () => {
2433 - batchSaveForm(); 2440 + batchSaveForm(type);
2434 }) 2441 })
2435 .catch(() => { 2442 .catch(() => {
2436 }); 2443 });
2444 + } else { // 自动执行保存操作
2445 + batchSaveForm(type);
2446 + }
2437 } 2447 }
2438 2448
2439 const startFlow = () => { // 启用流程图 2449 const startFlow = () => { // 启用流程图
......