Showing
1 changed file
with
77 additions
and
1 deletions
| ... | @@ -324,7 +324,7 @@ | ... | @@ -324,7 +324,7 @@ |
| 324 | <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> | 324 | <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> |
| 325 | <!-- <span @click="showEditFlowVersion(item.id, item.code, item.note)" style="margin-left: 10px;"> | 325 | <!-- <span @click="showEditFlowVersion(item.id, item.code, item.note)" style="margin-left: 10px;"> |
| 326 | <i class="el-icon-edit-outline"></i> | 326 | <i class="el-icon-edit-outline"></i> |
| 327 | - </span> --> | 327 | + --> |
| 328 | </el-dropdown-item> | 328 | </el-dropdown-item> |
| 329 | <el-dropdown-item @click.native="addFlowVersion" style="justify-content: center;"> | 329 | <el-dropdown-item @click.native="addFlowVersion" style="justify-content: center;"> |
| 330 | <i class="el-icon-circle-plus-outline"></i>新增流程 | 330 | <i class="el-icon-circle-plus-outline"></i>新增流程 |
| ... | @@ -364,6 +364,17 @@ | ... | @@ -364,6 +364,17 @@ |
| 364 | </el-popconfirm> | 364 | </el-popconfirm> |
| 365 | <el-popconfirm | 365 | <el-popconfirm |
| 366 | v-if="state.current_enable_version !== state.versionForm.code" | 366 | v-if="state.current_enable_version !== state.versionForm.code" |
| 367 | + title="是否确认复制该版本流程?" | ||
| 368 | + width="220px" | ||
| 369 | + confirm-button-text="确认" | ||
| 370 | + cancel-button-text="取消" | ||
| 371 | + @confirm="copyFLowVersion"> | ||
| 372 | + <template #reference> | ||
| 373 | + <el-button type="warning">复制流程</el-button> | ||
| 374 | + </template> | ||
| 375 | + </el-popconfirm> | ||
| 376 | + <el-popconfirm | ||
| 377 | + v-if="state.current_enable_version !== state.versionForm.code" | ||
| 367 | title="是否确认删除该版本流程?" | 378 | title="是否确认删除该版本流程?" |
| 368 | width="220px" | 379 | width="220px" |
| 369 | confirm-button-text="确认" | 380 | confirm-button-text="确认" |
| ... | @@ -768,6 +779,70 @@ export default { | ... | @@ -768,6 +779,70 @@ export default { |
| 768 | } | 779 | } |
| 769 | } | 780 | } |
| 770 | 781 | ||
| 782 | + const copyFLowVersion = async () => { // 复制版本流程 | ||
| 783 | + let { nodes, edges } = editor.editorState.graph.save(); | ||
| 784 | + | ||
| 785 | + // 使用时需要把自定义节点的类型带过去 activity/control | ||
| 786 | + nodes.forEach((node: { [x: string]: string; shape: string }) => { | ||
| 787 | + if (node.shape === 'control') { | ||
| 788 | + node['control'] = node['control'] | ||
| 789 | + } | ||
| 790 | + }); | ||
| 791 | + | ||
| 792 | + nodes = nodes.map( | ||
| 793 | + ({ data, id, label, shape, x, y, text, desc, img, control }) => ({ | ||
| 794 | + data, | ||
| 795 | + id, | ||
| 796 | + label, | ||
| 797 | + shape, | ||
| 798 | + x, | ||
| 799 | + y, | ||
| 800 | + text, | ||
| 801 | + desc, | ||
| 802 | + img, | ||
| 803 | + control, | ||
| 804 | + }), | ||
| 805 | + ); | ||
| 806 | + edges = edges.map(({ shape, source, sourceAnchor, target, targetAnchor }) => ({ | ||
| 807 | + shape, | ||
| 808 | + source, | ||
| 809 | + sourceAnchor, | ||
| 810 | + target, | ||
| 811 | + targetAnchor, | ||
| 812 | + })); | ||
| 813 | + // 检查路径有效性 | ||
| 814 | + const paths = []; | ||
| 815 | + findPathsToEndNode(edges, 'start-node', [], paths); | ||
| 816 | + | ||
| 817 | + state.dialogVersionFormVisible = false; // 关闭弹框 | ||
| 818 | + | ||
| 819 | + if (paths.length) { | ||
| 820 | + const { code, data } = await saveFlowAPI({ form_id: +form_id, flow_id: '', data: JSON.stringify({ nodes, edges }) }); | ||
| 821 | + if (code) { | ||
| 822 | + state.reloadLoading = true; // 打开 loading | ||
| 823 | + ElMessage({ | ||
| 824 | + type: 'success', | ||
| 825 | + message: '复制成功', | ||
| 826 | + }); | ||
| 827 | + | ||
| 828 | + updateFlowId(data); // 更新缓存 flow_id | ||
| 829 | + getFlowData(data); // 更新流程图数据 | ||
| 830 | + | ||
| 831 | + const flow_version = await flowVersionAPI({ form_id }); | ||
| 832 | + if (flow_version.code) { | ||
| 833 | + state.version_list = flow_version.data; // 更新版本列表 | ||
| 834 | + state.version_list.forEach((ele) => { | ||
| 835 | + if (ele.id === +data) { | ||
| 836 | + state.select_flow_version = ele.code; // 选中新增的版本 | ||
| 837 | + } | ||
| 838 | + }); | ||
| 839 | + } | ||
| 840 | + } | ||
| 841 | + } else { | ||
| 842 | + ElNotification.error('缺少一条从开始节点到结束节点的完整流程!'); | ||
| 843 | + } | ||
| 844 | + } | ||
| 845 | + | ||
| 771 | /** | 846 | /** |
| 772 | * 编辑版本 | 847 | * 编辑版本 |
| 773 | */ | 848 | */ |
| ... | @@ -1569,6 +1644,7 @@ export default { | ... | @@ -1569,6 +1644,7 @@ export default { |
| 1569 | showEditFlowVersion, | 1644 | showEditFlowVersion, |
| 1570 | addFlowVersion, | 1645 | addFlowVersion, |
| 1571 | setFLowVersionEnable, | 1646 | setFLowVersionEnable, |
| 1647 | + copyFLowVersion, | ||
| 1572 | editFlowVersion, | 1648 | editFlowVersion, |
| 1573 | deleteFlowVersion, | 1649 | deleteFlowVersion, |
| 1574 | saveFlowVersionNote, | 1650 | saveFlowVersionNote, | ... | ... |
-
Please register or login to post a comment