Showing
1 changed file
with
153 additions
and
10 deletions
| ... | @@ -323,10 +323,58 @@ | ... | @@ -323,10 +323,58 @@ |
| 323 | </div> | 323 | </div> |
| 324 | <template #dropdown> | 324 | <template #dropdown> |
| 325 | <el-dropdown-menu> | 325 | <el-dropdown-menu> |
| 326 | - <el-dropdown-item @click.native="onSelectFlowVersion(item.id)" v-for="(item, index) in state.flow_version_list" :key="index">流程版本 (V{{ item.code }})</el-dropdown-item> | 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> |
| 327 | </el-dropdown-menu> | 327 | </el-dropdown-menu> |
| 328 | </template> | 328 | </template> |
| 329 | </el-dropdown> | 329 | </el-dropdown> |
| 330 | + <el-tooltip content="编辑版本" placement="bottom"> | ||
| 331 | + <i class="el-icon-chat-line-square" @click="editFlowVersion" style="font-size: 18px; margin-left: 8px;"></i> | ||
| 332 | + </el-tooltip> | ||
| 333 | + <el-dialog v-model="state.dialogVersionFormVisible" title="版本描述"> | ||
| 334 | + <el-form :model="state.versionForm" label-width="80px"> | ||
| 335 | + <el-form-item label="版本号"> | ||
| 336 | + 流程版本(V{{ state.versionForm.code }}) | ||
| 337 | + </el-form-item> | ||
| 338 | + <el-form-item label="版本描述"> | ||
| 339 | + <el-input | ||
| 340 | + v-model="state.versionForm.note" | ||
| 341 | + :autosize="{ minRows: 2, maxRows: 4 }" | ||
| 342 | + type="textarea" | ||
| 343 | + placeholder="请输入版本描述" | ||
| 344 | + /> | ||
| 345 | + </el-form-item> | ||
| 346 | + </el-form> | ||
| 347 | + <template #footer> | ||
| 348 | + <span class="dialog-footer"> | ||
| 349 | + <el-popconfirm | ||
| 350 | + v-if="state.flow_version !== state.versionForm.code" | ||
| 351 | + placement="top" | ||
| 352 | + icon="el-icon-warning" | ||
| 353 | + title="是否确认启用该版本流程?" | ||
| 354 | + width="220px" | ||
| 355 | + confirm-button-text="确认" | ||
| 356 | + cancel-button-text="取消" | ||
| 357 | + @confirm="setFLowVersionEnable"> | ||
| 358 | + <template #reference> | ||
| 359 | + <el-button type="success">启用流程</el-button> | ||
| 360 | + </template> | ||
| 361 | + </el-popconfirm> | ||
| 362 | + <el-popconfirm | ||
| 363 | + v-if="state.flow_version !== state.versionForm.code" | ||
| 364 | + title="是否确认删除该版本流程?" | ||
| 365 | + width="220px" | ||
| 366 | + confirm-button-text="确认" | ||
| 367 | + cancel-button-text="取消" | ||
| 368 | + @confirm="deleteFlowVersion"> | ||
| 369 | + <template #reference> | ||
| 370 | + <el-button type="danger">删除流程</el-button> | ||
| 371 | + </template> | ||
| 372 | + </el-popconfirm> | ||
| 373 | + <el-button type="primary" color="#009688" @click="saveFlowVersionNote">保存描述</el-button> | ||
| 374 | + <el-button @click="state.dialogVersionFormVisible = false">关闭</el-button> | ||
| 375 | + </span> | ||
| 376 | + </template> | ||
| 377 | + </el-dialog> | ||
| 330 | </div> | 378 | </div> |
| 331 | </template> | 379 | </template> |
| 332 | <!-- 表单底部按钮 --> | 380 | <!-- 表单底部按钮 --> |
| ... | @@ -367,6 +415,7 @@ import { extend } from '@vue/shared' | ... | @@ -367,6 +415,7 @@ import { extend } from '@vue/shared' |
| 367 | import { v4 as uuidv4 } from 'uuid'; | 415 | import { v4 as uuidv4 } from 'uuid'; |
| 368 | import type { FormInstance, FormRules } from 'element-plus' | 416 | import type { FormInstance, FormRules } from 'element-plus' |
| 369 | import qs from 'qs' | 417 | import qs from 'qs' |
| 418 | +import { after } from 'lodash-es'; | ||
| 370 | // import { VueSpinner } from 'vue3-spinners'; | 419 | // import { VueSpinner } from 'vue3-spinners'; |
| 371 | 420 | ||
| 372 | const G6 = (window as any).G6.default as any | 421 | const G6 = (window as any).G6.default as any |
| ... | @@ -513,9 +562,17 @@ export default { | ... | @@ -513,9 +562,17 @@ export default { |
| 513 | auth_all_edit: false, | 562 | auth_all_edit: false, |
| 514 | field_auths: [], | 563 | field_auths: [], |
| 515 | field_extend: [], | 564 | field_extend: [], |
| 516 | - flow_version: '', | 565 | + flow_version: 0, |
| 517 | flow_version_list: [], | 566 | flow_version_list: [], |
| 518 | - }) | 567 | + version_list: [], |
| 568 | + dialogVersionFormVisible: false, | ||
| 569 | + versionForm: { | ||
| 570 | + code: 0, | ||
| 571 | + id: 0, | ||
| 572 | + note: '', | ||
| 573 | + type: null, // 操作方式 0:仅保存流程说明 1:删除,2:启用 | ||
| 574 | + } | ||
| 575 | + }); | ||
| 519 | 576 | ||
| 520 | /** | 577 | /** |
| 521 | * 更新URL | 578 | * 更新URL |
| ... | @@ -627,8 +684,8 @@ export default { | ... | @@ -627,8 +684,8 @@ export default { |
| 627 | getFlowData(flow_id); | 684 | getFlowData(flow_id); |
| 628 | 685 | ||
| 629 | // 显示提示框的标志位 | 686 | // 显示提示框的标志位 |
| 630 | - var showConfirmation = true; | ||
| 631 | onMounted(async () => { | 687 | onMounted(async () => { |
| 688 | + var showConfirmation = true; | ||
| 632 | document.title = '可视化流程设计器' | 689 | document.title = '可视化流程设计器' |
| 633 | // 监听 beforeunload 事件 | 690 | // 监听 beforeunload 事件 |
| 634 | window.addEventListener('beforeunload', function (event) { | 691 | window.addEventListener('beforeunload', function (event) { |
| ... | @@ -650,8 +707,12 @@ export default { | ... | @@ -650,8 +707,12 @@ export default { |
| 650 | getVersionList(); | 707 | getVersionList(); |
| 651 | }); | 708 | }); |
| 652 | 709 | ||
| 710 | + /***************** 版本操作 ***************/ | ||
| 711 | + | ||
| 712 | + /** | ||
| 713 | + * 获取版本信息列表 | ||
| 714 | + */ | ||
| 653 | const getVersionList = () => { | 715 | const getVersionList = () => { |
| 654 | - // 获取版本信息列表 | ||
| 655 | axios.get('/admin/?a=flow_version&form_id=' + form_id) | 716 | axios.get('/admin/?a=flow_version&form_id=' + form_id) |
| 656 | .then(res => { | 717 | .then(res => { |
| 657 | if (res.data.code) { | 718 | if (res.data.code) { |
| ... | @@ -659,9 +720,17 @@ export default { | ... | @@ -659,9 +720,17 @@ export default { |
| 659 | res.data.data.forEach((ele) => { | 720 | res.data.data.forEach((ele) => { |
| 660 | if (ele.status === '1') { | 721 | if (ele.status === '1') { |
| 661 | state.flow_version = ele.code; | 722 | state.flow_version = ele.code; |
| 723 | + state.versionForm = { // 当前版本信息 | ||
| 724 | + code: ele.code, | ||
| 725 | + id: ele.id, | ||
| 726 | + note: ele.note, | ||
| 727 | + type: null, | ||
| 728 | + } | ||
| 662 | } | 729 | } |
| 663 | }); | 730 | }); |
| 664 | // 版本列表 | 731 | // 版本列表 |
| 732 | + state.version_list = res.data.data; | ||
| 733 | + // 版本列表不含有启用的版本 | ||
| 665 | state.flow_version_list = res.data.data.filter((ele) => { | 734 | state.flow_version_list = res.data.data.filter((ele) => { |
| 666 | return ele.status !== '1'; | 735 | return ele.status !== '1'; |
| 667 | }); | 736 | }); |
| ... | @@ -677,15 +746,61 @@ export default { | ... | @@ -677,15 +746,61 @@ export default { |
| 677 | }); | 746 | }); |
| 678 | } | 747 | } |
| 679 | 748 | ||
| 680 | - const onSelectFlowVersion = (id: string) => { | 749 | + const onSelectFlowVersion = (id: number, code: number, note: string) => { |
| 681 | // 切换版本信息 | 750 | // 切换版本信息 |
| 682 | - axios.post('/admin/?a=enable_flow_version', qs.stringify({ id: +id })) | 751 | + state.dialogVersionFormVisible = true; |
| 752 | + state.versionForm = { // 当前版本信息 | ||
| 753 | + code, | ||
| 754 | + id, | ||
| 755 | + note, | ||
| 756 | + type: null, | ||
| 757 | + } | ||
| 758 | + } | ||
| 759 | + | ||
| 760 | + const setFLowVersionEnable = () => { // 启用版本 | ||
| 761 | + state.versionForm.type = 2; | ||
| 762 | + axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm)) | ||
| 763 | + .then(res => { | ||
| 764 | + if (res.data.code) { | ||
| 765 | + state.dialogVersionFormVisible = false; | ||
| 766 | + ElMessage({ | ||
| 767 | + type: 'success', | ||
| 768 | + message: '启用成功', | ||
| 769 | + }); | ||
| 770 | + getVersionList(); // 刷新版本列表 | ||
| 771 | + updateUrl(res.data.data); // 更新URL | ||
| 772 | + state.reloadLoading = true; // 打开loading | ||
| 773 | + getFlowData(res.data.data); // 更新流程图数据 | ||
| 774 | + } | ||
| 775 | + }) | ||
| 776 | + .catch(err => { | ||
| 777 | + console.error(err); | ||
| 778 | + }); | ||
| 779 | + } | ||
| 780 | + | ||
| 781 | + const editFlowVersion = () => { // 编辑版本 | ||
| 782 | + console.warn('编辑版本'); | ||
| 783 | + state.dialogVersionFormVisible = true; | ||
| 784 | + state.version_list.forEach((ele) => { | ||
| 785 | + if (ele.status === '1') { | ||
| 786 | + state.versionForm.id = ele.id; | ||
| 787 | + state.versionForm.code = ele.code; | ||
| 788 | + state.versionForm.note = ele.note; | ||
| 789 | + } | ||
| 790 | + }); | ||
| 791 | + } | ||
| 792 | + | ||
| 793 | + const deleteFlowVersion = () => { // 删除版本 | ||
| 794 | + state.versionForm.type = 1; | ||
| 795 | + axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm)) | ||
| 683 | .then(res => { | 796 | .then(res => { |
| 684 | if (res.data.code) { | 797 | if (res.data.code) { |
| 798 | + state.dialogVersionFormVisible = false; | ||
| 799 | + ElMessage({ | ||
| 800 | + type: 'success', | ||
| 801 | + message: '删除成功', | ||
| 802 | + }); | ||
| 685 | getVersionList(); | 803 | getVersionList(); |
| 686 | - updateUrl(res.data.data); | ||
| 687 | - state.reloadLoading = true; | ||
| 688 | - getFlowData(res.data.data); | ||
| 689 | } else { | 804 | } else { |
| 690 | ElMessage({ | 805 | ElMessage({ |
| 691 | type: 'error', | 806 | type: 'error', |
| ... | @@ -698,6 +813,30 @@ export default { | ... | @@ -698,6 +813,30 @@ export default { |
| 698 | }); | 813 | }); |
| 699 | } | 814 | } |
| 700 | 815 | ||
| 816 | + const saveFlowVersionNote = () => { // 保存版本描述 | ||
| 817 | + state.versionForm.type = 0; | ||
| 818 | + axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm)) | ||
| 819 | + .then(res => { | ||
| 820 | + if (res.data.code) { | ||
| 821 | + state.dialogVersionFormVisible = false; | ||
| 822 | + ElMessage({ | ||
| 823 | + type: 'success', | ||
| 824 | + message: '保存成功', | ||
| 825 | + }); | ||
| 826 | + } else { | ||
| 827 | + ElMessage({ | ||
| 828 | + type: 'error', | ||
| 829 | + message: res.data.msg, | ||
| 830 | + }); | ||
| 831 | + } | ||
| 832 | + }) | ||
| 833 | + .catch(err => { | ||
| 834 | + console.error(err); | ||
| 835 | + }); | ||
| 836 | + } | ||
| 837 | + | ||
| 838 | + /***************** END *******************/ | ||
| 839 | + | ||
| 701 | function handleActiveChange(name: any) { | 840 | function handleActiveChange(name: any) { |
| 702 | console.warn(name) | 841 | console.warn(name) |
| 703 | } | 842 | } |
| ... | @@ -1516,6 +1655,10 @@ export default { | ... | @@ -1516,6 +1655,10 @@ export default { |
| 1516 | handleAfterAdd, | 1655 | handleAfterAdd, |
| 1517 | 1656 | ||
| 1518 | onSelectFlowVersion, | 1657 | onSelectFlowVersion, |
| 1658 | + setFLowVersionEnable, | ||
| 1659 | + editFlowVersion, | ||
| 1660 | + deleteFlowVersion, | ||
| 1661 | + saveFlowVersionNote, | ||
| 1519 | handleActiveChange, | 1662 | handleActiveChange, |
| 1520 | onAuthVisibleChange, | 1663 | onAuthVisibleChange, |
| 1521 | onAuthEditableChange, | 1664 | onAuthEditableChange, | ... | ... |
-
Please register or login to post a comment