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,22 +1257,26 @@ export default { ...@@ -1257,22 +1257,26 @@ export default {
1257 * 启用版本 1257 * 启用版本
1258 */ 1258 */
1259 const setFLowVersionEnable = async () => { 1259 const setFLowVersionEnable = async () => {
1260 - state.versionForm.type = 2; 1260 + // 启动前,自动保存操作
1261 - const { code, data } = await enableFlowVersionAPI(state.versionForm); 1261 + let is_pass = await saveData('auto');
1262 - if (code) { 1262 + if (is_pass !== false) { // 不通过后会返回false,不返回false就是通过了
1263 - ElMessage({ 1263 + state.versionForm.type = 2;
1264 - type: 'success', 1264 + const { code, data } = await enableFlowVersionAPI(state.versionForm);
1265 - message: '启用成功', 1265 + if (code) {
1266 - }); 1266 + ElMessage({
1267 - state.current_enable_version = state.versionForm.code; // 当前选中的版本号 1267 + type: 'success',
1268 - state.dialogVersionFormVisible = false; // 关闭弹框 1268 + message: '启用成功',
1269 - state.reloadLoading = true; // 打开loading 1269 + });
1270 + state.current_enable_version = state.versionForm.code; // 当前选中的版本号
1271 + state.dialogVersionFormVisible = false; // 关闭弹框
1272 + state.reloadLoading = true; // 打开loading
1270 1273
1271 - getVersionList(); // 刷新版本列表 1274 + getVersionList(); // 刷新版本列表
1272 - updateFlowId(data); // 更新缓存flow_id 1275 + updateFlowId(data); // 更新缓存flow_id
1273 - getFlowData(data); // 更新流程图数据 1276 + getFlowData(data); // 更新流程图数据
1274 - } else { 1277 + } else {
1275 - state.reloadLoading = false; 1278 + state.reloadLoading = false;
1279 + }
1276 } 1280 }
1277 } 1281 }
1278 1282
...@@ -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); // 输出满足条件的路径结果数组
2031 - ElMessage({ 2035 + if (type === 'manual') {
2032 - type: 'success', 2036 + ElMessage({
2033 - message: '保存流程图成功', 2037 + type: 'success',
2034 - }); 2038 + message: '保存流程图成功',
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,24 +2422,28 @@ export default { ...@@ -2416,24 +2422,28 @@ 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
2423 - ElMessageBox.confirm( 2429 + if (type === 'manual') { // 手动触发保存按钮
2424 - '是否确定保存流程?', 2430 + ElMessageBox.confirm(
2425 - '温馨提示', 2431 + '是否确定保存流程?',
2426 - { 2432 + '温馨提示',
2427 - confirmButtonText: '确认', 2433 + {
2428 - cancelButtonText: '取消', 2434 + confirmButtonText: '确认',
2429 - type: 'warning', 2435 + cancelButtonText: '取消',
2430 - } 2436 + type: 'warning',
2431 - ) 2437 + }
2432 - .then(async () => { 2438 + )
2433 - batchSaveForm(); 2439 + .then(async () => {
2434 - }) 2440 + batchSaveForm(type);
2435 - .catch(() => { 2441 + })
2436 - }); 2442 + .catch(() => {
2443 + });
2444 + } else { // 自动执行保存操作
2445 + batchSaveForm(type);
2446 + }
2437 } 2447 }
2438 2448
2439 const startFlow = () => { // 启用流程图 2449 const startFlow = () => { // 启用流程图
......