Showing
1 changed file
with
50 additions
and
54 deletions
| ... | @@ -319,11 +319,21 @@ | ... | @@ -319,11 +319,21 @@ |
| 319 | <div style="position: absolute; top:20px; right: 15px;"> | 319 | <div style="position: absolute; top:20px; right: 15px;"> |
| 320 | <el-dropdown trigger="click"> | 320 | <el-dropdown trigger="click"> |
| 321 | <div style="margin-left: 15px;"> | 321 | <div style="margin-left: 15px;"> |
| 322 | - <div style="width: 10px; height: 10px; background-color: #009688; border-radius: 50%; display: inline-block;"></div> <span style="font-size: 13px;">流程版本 (V{{ state.flow_version }})</span> | 322 | + <div v-if="state.flow_version === state.current_version_code" style="width: 10px; height: 10px; background-color: #009688; border-radius: 50%; display: inline-block; margin-right: 8px;"></div> |
| 323 | + <div v-else style="width: 10px; height: 10px; background-color: #f0a800; border-radius: 50%; display: inline-block; margin-right: 8px;"></div> | ||
| 324 | + <span style="font-size: 13px;">流程版本 (V{{ state.flow_version }})</span> | ||
| 323 | </div> | 325 | </div> |
| 324 | <template #dropdown> | 326 | <template #dropdown> |
| 325 | <el-dropdown-menu> | 327 | <el-dropdown-menu> |
| 326 | - <el-dropdown-item @click.native="onSelectFlowVersion(item.id, item.code, item.note)" v-for="(item, index) in state.flow_version_list" :key="index">流程版本 (V{{ item.code }})</el-dropdown-item> | 328 | + <el-dropdown-item @click.native="onSelectFlowVersion(item.id, item.code, item.note)" v-for="(item, index) in state.version_list" :key="index"> |
| 329 | + <i v-if="item.code === state.flow_version" class="el-icon-check" style="color: #009688; margin-right: 8px;"></i> | ||
| 330 | + <div v-else style="width: 15px; height: 15px;display: inline-block; margin-right: 8px;"></div> | ||
| 331 | + <span>流程版本 (V{{ item.code }})</span> | ||
| 332 | + <span v-if="item.code === state.current_version_code" style="background: #edf9f1; border-color: #46c26f; color: #46c26f;font-size: 10px; padding: 0 5px; border-radius: 3px; margin-left: 8px;">启用中</span> | ||
| 333 | + <!-- <span @click="showEditFlowVersion(item.id, item.code, item.note)" style="margin-left: 10px;"> | ||
| 334 | + <i class="el-icon-edit-outline"></i> | ||
| 335 | + </span> --> | ||
| 336 | + </el-dropdown-item> | ||
| 327 | <el-dropdown-item @click.native="addFlowVersion" style="justify-content: center;"><i class="el-icon-circle-plus-outline"></i>新增流程</el-dropdown-item> | 337 | <el-dropdown-item @click.native="addFlowVersion" style="justify-content: center;"><i class="el-icon-circle-plus-outline"></i>新增流程</el-dropdown-item> |
| 328 | </el-dropdown-menu> | 338 | </el-dropdown-menu> |
| 329 | </template> | 339 | </template> |
| ... | @@ -348,7 +358,7 @@ | ... | @@ -348,7 +358,7 @@ |
| 348 | <template #footer> | 358 | <template #footer> |
| 349 | <span class="dialog-footer"> | 359 | <span class="dialog-footer"> |
| 350 | <el-popconfirm | 360 | <el-popconfirm |
| 351 | - v-if="state.flow_version !== state.versionForm.code" | 361 | + v-if="state.current_version_code !== state.versionForm.code" |
| 352 | title="是否确认启用该版本流程?" | 362 | title="是否确认启用该版本流程?" |
| 353 | width="220px" | 363 | width="220px" |
| 354 | confirm-button-text="确认" | 364 | confirm-button-text="确认" |
| ... | @@ -359,7 +369,7 @@ | ... | @@ -359,7 +369,7 @@ |
| 359 | </template> | 369 | </template> |
| 360 | </el-popconfirm> | 370 | </el-popconfirm> |
| 361 | <el-popconfirm | 371 | <el-popconfirm |
| 362 | - v-if="state.flow_version !== state.versionForm.code" | 372 | + v-if="state.current_version_code !== state.versionForm.code" |
| 363 | title="是否确认删除该版本流程?" | 373 | title="是否确认删除该版本流程?" |
| 364 | width="220px" | 374 | width="220px" |
| 365 | confirm-button-text="确认" | 375 | confirm-button-text="确认" |
| ... | @@ -561,6 +571,7 @@ export default { | ... | @@ -561,6 +571,7 @@ export default { |
| 561 | auth_all_edit: false, | 571 | auth_all_edit: false, |
| 562 | field_auths: [], | 572 | field_auths: [], |
| 563 | field_extend: [], | 573 | field_extend: [], |
| 574 | + current_version_code: 0, | ||
| 564 | flow_version: 0, | 575 | flow_version: 0, |
| 565 | flow_version_list: [], | 576 | flow_version_list: [], |
| 566 | version_list: [], | 577 | version_list: [], |
| ... | @@ -574,10 +585,10 @@ export default { | ... | @@ -574,10 +585,10 @@ export default { |
| 574 | }); | 585 | }); |
| 575 | 586 | ||
| 576 | /** | 587 | /** |
| 577 | - * 更新URL | 588 | + * 更新URL中的flow_id |
| 578 | * @param flowId | 589 | * @param flowId |
| 579 | */ | 590 | */ |
| 580 | - const updateUrl = (flowId: string) => { | 591 | + const updateUrl = (flowId: any) => { |
| 581 | // 获取当前 URL | 592 | // 获取当前 URL |
| 582 | const url = new URL(window.location.href); | 593 | const url = new URL(window.location.href); |
| 583 | 594 | ||
| ... | @@ -635,6 +646,7 @@ export default { | ... | @@ -635,6 +646,7 @@ export default { |
| 635 | const urlQuery = getQueryParams(location.href); | 646 | const urlQuery = getQueryParams(location.href); |
| 636 | let form_id = urlQuery.form_id? urlQuery.form_id : ''; // 表单id | 647 | let form_id = urlQuery.form_id? urlQuery.form_id : ''; // 表单id |
| 637 | let flow_id = urlQuery.flow_id? urlQuery.flow_id : ''; // 流程id,如果是新的流程,则为空 | 648 | let flow_id = urlQuery.flow_id? urlQuery.flow_id : ''; // 流程id,如果是新的流程,则为空 |
| 649 | + | ||
| 638 | /** | 650 | /** |
| 639 | * 获取版本信息列表 | 651 | * 获取版本信息列表 |
| 640 | */ | 652 | */ |
| ... | @@ -647,7 +659,9 @@ export default { | ... | @@ -647,7 +659,9 @@ export default { |
| 647 | if (ele.status === '1') { | 659 | if (ele.status === '1') { |
| 648 | flow_id = ele.code; | 660 | flow_id = ele.code; |
| 649 | updateUrl(ele.id); // 更新url | 661 | updateUrl(ele.id); // 更新url |
| 662 | + // 版本显示信息 | ||
| 650 | state.flow_version = ele.code; | 663 | state.flow_version = ele.code; |
| 664 | + state.current_version_code = ele.code; | ||
| 651 | state.versionForm = { // 当前版本信息 | 665 | state.versionForm = { // 当前版本信息 |
| 652 | code: ele.code, | 666 | code: ele.code, |
| 653 | id: ele.id, | 667 | id: ele.id, |
| ... | @@ -662,6 +676,19 @@ export default { | ... | @@ -662,6 +676,19 @@ export default { |
| 662 | state.flow_version_list = res.data.data.filter((ele) => { | 676 | state.flow_version_list = res.data.data.filter((ele) => { |
| 663 | return ele.status !== '1'; | 677 | return ele.status !== '1'; |
| 664 | }); | 678 | }); |
| 679 | + // 如果列表里没有启用的版本 | ||
| 680 | + if (state.version_list.length && !state.flow_version_list) { | ||
| 681 | + let ele = state.version_list[0]; | ||
| 682 | + flow_id = ele.code; | ||
| 683 | + updateUrl(ele.id); // 更新url | ||
| 684 | + state.flow_version = ele.code; | ||
| 685 | + state.versionForm = { // 当前版本信息 | ||
| 686 | + code: ele.code, | ||
| 687 | + id: ele.id, | ||
| 688 | + note: ele.note, | ||
| 689 | + type: null, | ||
| 690 | + } | ||
| 691 | + } | ||
| 665 | // 没有默认版本列表,自动新增流程 | 692 | // 没有默认版本列表,自动新增流程 |
| 666 | if (!state.version_list.length) { | 693 | if (!state.version_list.length) { |
| 667 | axios.post('/admin/?a=save_flow', qs.stringify({ | 694 | axios.post('/admin/?a=save_flow', qs.stringify({ |
| ... | @@ -671,8 +698,8 @@ export default { | ... | @@ -671,8 +698,8 @@ export default { |
| 671 | })) | 698 | })) |
| 672 | .then(res => { | 699 | .then(res => { |
| 673 | if (res.data.code) { | 700 | if (res.data.code) { |
| 674 | - flow_id = res.data.data; // 更新flow_id | 701 | + // 刷新版本列表显示 |
| 675 | - updateUrl(flow_id); // 更新url | 702 | + getVersionList(); |
| 676 | } | 703 | } |
| 677 | }) | 704 | }) |
| 678 | .catch(err => { | 705 | .catch(err => { |
| ... | @@ -750,6 +777,15 @@ export default { | ... | @@ -750,6 +777,15 @@ export default { |
| 750 | /***************** 版本操作 ***************/ | 777 | /***************** 版本操作 ***************/ |
| 751 | const onSelectFlowVersion = (id: number, code: number, note: string) => { | 778 | const onSelectFlowVersion = (id: number, code: number, note: string) => { |
| 752 | // 切换版本信息 | 779 | // 切换版本信息 |
| 780 | + updateUrl(id); // 更新URL | ||
| 781 | + getFlowData(id); // 更新流程图数据 | ||
| 782 | + state.flow_version = code; | ||
| 783 | + state.versionForm.id = id; | ||
| 784 | + state.versionForm.code = code; | ||
| 785 | + state.versionForm.note = note; | ||
| 786 | + } | ||
| 787 | + const showEditFlowVersion = (id: number, code: number, note: string) => { | ||
| 788 | + // 切换版本信息 | ||
| 753 | state.dialogVersionFormVisible = true; | 789 | state.dialogVersionFormVisible = true; |
| 754 | state.versionForm = { // 当前版本信息 | 790 | state.versionForm = { // 当前版本信息 |
| 755 | code, | 791 | code, |
| ... | @@ -770,52 +806,11 @@ export default { | ... | @@ -770,52 +806,11 @@ export default { |
| 770 | flow_id = res.data.data; // 更新flow_id | 806 | flow_id = res.data.data; // 更新flow_id |
| 771 | updateUrl(flow_id); // 更新url | 807 | updateUrl(flow_id); // 更新url |
| 772 | getFlowData(flow_id); | 808 | getFlowData(flow_id); |
| 773 | - // 获取版本列表 | ||
| 774 | - axios.get('/admin/?a=flow_version&form_id=' + form_id) | ||
| 775 | - .then(version => { | ||
| 776 | - if (version.data.code) { | ||
| 777 | - // 启用的版本号 | ||
| 778 | - version.data.data.forEach((ele) => { | ||
| 779 | - if (ele.id === flow_id) { | ||
| 780 | - state.flow_version = ele.code; | ||
| 781 | - state.versionForm = { // 当前版本信息 | ||
| 782 | - code: ele.code, | ||
| 783 | - id: ele.id, | ||
| 784 | - note: ele.note, | ||
| 785 | - type: 2, | ||
| 786 | - } | ||
| 787 | - axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm)) | ||
| 788 | - .then(res => { | ||
| 789 | - if (res.data.code) { | ||
| 790 | - getVersionList(); // 刷新版本列表 | ||
| 791 | - } else { | ||
| 792 | ElMessage({ | 809 | ElMessage({ |
| 793 | - type: 'error', | 810 | + type: 'success', |
| 794 | - message: res.data.msg, | 811 | + message: '新增成功', |
| 795 | - }); | ||
| 796 | - } | ||
| 797 | - }) | ||
| 798 | - .catch(err => { | ||
| 799 | - console.error(err); | ||
| 800 | - }); | ||
| 801 | - } | ||
| 802 | - }); | ||
| 803 | - // 版本列表 | ||
| 804 | - state.version_list = version.data.data; | ||
| 805 | - // 版本列表不含有启用的版本 | ||
| 806 | - state.flow_version_list = version.data.data.filter((ele) => { | ||
| 807 | - return ele.status !== '1'; | ||
| 808 | - }); | ||
| 809 | - } else { | ||
| 810 | - ElMessage({ | ||
| 811 | - type: 'error', | ||
| 812 | - message: res.data.msg, | ||
| 813 | - }); | ||
| 814 | - } | ||
| 815 | - }) | ||
| 816 | - .catch(err => { | ||
| 817 | - console.error(err); | ||
| 818 | }); | 812 | }); |
| 813 | + getVersionList(); // 刷新版本列表 | ||
| 819 | } | 814 | } |
| 820 | }) | 815 | }) |
| 821 | .catch(err => { | 816 | .catch(err => { |
| ... | @@ -828,6 +823,7 @@ export default { | ... | @@ -828,6 +823,7 @@ export default { |
| 828 | axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm)) | 823 | axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm)) |
| 829 | .then(res => { | 824 | .then(res => { |
| 830 | if (res.data.code) { | 825 | if (res.data.code) { |
| 826 | + state.current_version_code = state.versionForm.code; | ||
| 831 | state.dialogVersionFormVisible = false; | 827 | state.dialogVersionFormVisible = false; |
| 832 | ElMessage({ | 828 | ElMessage({ |
| 833 | type: 'success', | 829 | type: 'success', |
| ... | @@ -845,10 +841,9 @@ export default { | ... | @@ -845,10 +841,9 @@ export default { |
| 845 | } | 841 | } |
| 846 | 842 | ||
| 847 | const editFlowVersion = () => { // 编辑版本 | 843 | const editFlowVersion = () => { // 编辑版本 |
| 848 | - console.warn('编辑版本'); | ||
| 849 | state.dialogVersionFormVisible = true; | 844 | state.dialogVersionFormVisible = true; |
| 850 | state.version_list.forEach((ele) => { | 845 | state.version_list.forEach((ele) => { |
| 851 | - if (ele.status === '1') { | 846 | + if (ele.code === state.flow_version) { |
| 852 | state.versionForm.id = ele.id; | 847 | state.versionForm.id = ele.id; |
| 853 | state.versionForm.code = ele.code; | 848 | state.versionForm.code = ele.code; |
| 854 | state.versionForm.note = ele.note; | 849 | state.versionForm.note = ele.note; |
| ... | @@ -1723,6 +1718,7 @@ export default { | ... | @@ -1723,6 +1718,7 @@ export default { |
| 1723 | handleAfterAdd, | 1718 | handleAfterAdd, |
| 1724 | 1719 | ||
| 1725 | onSelectFlowVersion, | 1720 | onSelectFlowVersion, |
| 1721 | + showEditFlowVersion, | ||
| 1726 | addFlowVersion, | 1722 | addFlowVersion, |
| 1727 | setFLowVersionEnable, | 1723 | setFLowVersionEnable, |
| 1728 | editFlowVersion, | 1724 | editFlowVersion, | ... | ... |
-
Please register or login to post a comment