Showing
1 changed file
with
121 additions
and
34 deletions
| ... | @@ -72,7 +72,6 @@ | ... | @@ -72,7 +72,6 @@ |
| 72 | <el-form | 72 | <el-form |
| 73 | v-if="!!state.detailModel" | 73 | v-if="!!state.detailModel" |
| 74 | ref="formRef" | 74 | ref="formRef" |
| 75 | - :rules="rules" | ||
| 76 | :model="state.detailModel" | 75 | :model="state.detailModel" |
| 77 | label-position="top" | 76 | label-position="top" |
| 78 | label-width="100px" | 77 | label-width="100px" |
| ... | @@ -91,7 +90,7 @@ | ... | @@ -91,7 +90,7 @@ |
| 91 | </div> | 90 | </div> |
| 92 | <el-input v-model="state.node_name" /> | 91 | <el-input v-model="state.node_name" /> |
| 93 | </el-form-item> | 92 | </el-form-item> |
| 94 | - <div> | 93 | + <div class="node-user"> |
| 95 | <div style="font-size: 14px; margin-bottom: 10px;"> | 94 | <div style="font-size: 14px; margin-bottom: 10px;"> |
| 96 | 节点负责人 <span style="color: red;">*</span> | 95 | 节点负责人 <span style="color: red;">*</span> |
| 97 | </div> | 96 | </div> |
| ... | @@ -157,6 +156,7 @@ | ... | @@ -157,6 +156,7 @@ |
| 157 | :disabled="field.visible.disabled" | 156 | :disabled="field.visible.disabled" |
| 158 | label="" | 157 | label="" |
| 159 | size="large" | 158 | size="large" |
| 159 | + @change="onAuthVisibleChange(field, index)" | ||
| 160 | /></el-col> | 160 | /></el-col> |
| 161 | <el-col :span="6" style="padding-left: 5px;" | 161 | <el-col :span="6" style="padding-left: 5px;" |
| 162 | ><el-checkbox | 162 | ><el-checkbox |
| ... | @@ -164,6 +164,7 @@ | ... | @@ -164,6 +164,7 @@ |
| 164 | :disabled="field.editable.disabled" | 164 | :disabled="field.editable.disabled" |
| 165 | label="" | 165 | label="" |
| 166 | size="large" | 166 | size="large" |
| 167 | + @change="onAuthEditableChange(field, index)" | ||
| 167 | /></el-col> | 168 | /></el-col> |
| 168 | </el-row> | 169 | </el-row> |
| 169 | </el-form-item> | 170 | </el-form-item> |
| ... | @@ -389,8 +390,8 @@ export default { | ... | @@ -389,8 +390,8 @@ export default { |
| 389 | { | 390 | { |
| 390 | name: '字段1', | 391 | name: '字段1', |
| 391 | visible: { | 392 | visible: { |
| 392 | - checked: true, | 393 | + checked: false, |
| 393 | - disabled: false, | 394 | + disabled: true, |
| 394 | }, | 395 | }, |
| 395 | editable: { | 396 | editable: { |
| 396 | checked: false, | 397 | checked: false, |
| ... | @@ -411,7 +412,7 @@ export default { | ... | @@ -411,7 +412,7 @@ export default { |
| 411 | { | 412 | { |
| 412 | name: '字段3', | 413 | name: '字段3', |
| 413 | visible: { | 414 | visible: { |
| 414 | - checked: true, | 415 | + checked: false, |
| 415 | disabled: false, | 416 | disabled: false, |
| 416 | }, | 417 | }, |
| 417 | editable: { | 418 | editable: { |
| ... | @@ -424,32 +425,51 @@ export default { | ... | @@ -424,32 +425,51 @@ export default { |
| 424 | 425 | ||
| 425 | onMounted(() => { | 426 | onMounted(() => { |
| 426 | document.title = '可视化流程设计器' | 427 | document.title = '可视化流程设计器' |
| 427 | - // // 显示提示框的标志位 | 428 | + // 显示提示框的标志位 |
| 428 | - // var showConfirmation = true; | 429 | + var showConfirmation = true; |
| 429 | - // // 监听 beforeunload 事件 | 430 | + // 监听 beforeunload 事件 |
| 430 | - // window.addEventListener('beforeunload', function (event) { | 431 | + window.addEventListener('beforeunload', function (event) { |
| 431 | - // if (showConfirmation) { | 432 | + if (showConfirmation) { |
| 432 | - // // 取消事件的默认行为(弹出确认对话框) | 433 | + // 取消事件的默认行为(弹出确认对话框) |
| 433 | - // event.preventDefault(); | 434 | + event.preventDefault(); |
| 434 | - // // Chrome 和 Firefox 需要返回一个值以显示确认对话框 | 435 | + // Chrome 和 Firefox 需要返回一个值以显示确认对话框 |
| 435 | - // event.returnValue = ''; | 436 | + event.returnValue = ''; |
| 436 | - // // 显示自定义的提示信息 | 437 | + // 显示自定义的提示信息 |
| 437 | - // var confirmationMessage = '确定要离开此页面吗?'; | 438 | + var confirmationMessage = '确定要离开此页面吗?'; |
| 438 | - // (event || window.event).returnValue = confirmationMessage; // 兼容旧版浏览器 | 439 | + (event || window.event).returnValue = confirmationMessage; // 兼容旧版浏览器 |
| 439 | - // return confirmationMessage; | 440 | + return confirmationMessage; |
| 440 | - // } | 441 | + } |
| 441 | - // }); | 442 | + }); |
| 442 | - // // 监听 unload 事件 | 443 | + // 监听 unload 事件 |
| 443 | - // window.addEventListener('unload', function () { | 444 | + window.addEventListener('unload', function () { |
| 444 | - // // 设置标志位为 false,避免在刷新页面时再次显示提示框 | 445 | + // 设置标志位为 false,避免在刷新页面时再次显示提示框 |
| 445 | - // showConfirmation = false; | 446 | + showConfirmation = false; |
| 446 | - // }); | 447 | + }); |
| 447 | }) | 448 | }) |
| 448 | 449 | ||
| 449 | function handleActiveChange(name) { | 450 | function handleActiveChange(name) { |
| 450 | console.warn(name) | 451 | console.warn(name) |
| 451 | } | 452 | } |
| 452 | 453 | ||
| 454 | + /************** 字段权限操作 ***************/ | ||
| 455 | + const onAuthVisibleChange = (val: any, index: number) => { | ||
| 456 | + // 可见按钮回调 | ||
| 457 | + console.log('onAuthVisibleChange', val, index); | ||
| 458 | + let count = state.field_auths.filter((ele) => { | ||
| 459 | + if (ele.visible.checked && !ele.visible.disabled) { | ||
| 460 | + return ele; | ||
| 461 | + } | ||
| 462 | + }); | ||
| 463 | + if (count.length === state.field_auths.length) { | ||
| 464 | + state.auth_all_checked = true; | ||
| 465 | + } else { | ||
| 466 | + state.auth_all_checked = false; | ||
| 467 | + } | ||
| 468 | + } | ||
| 469 | + const onAuthEditChange = (val: any, index: number) => { | ||
| 470 | + console.log('onAuthEditChange', val, index) | ||
| 471 | + } | ||
| 472 | + | ||
| 453 | const onAuthAllChange = (val: any) => { | 473 | const onAuthAllChange = (val: any) => { |
| 454 | // 全选可见按钮回调 | 474 | // 全选可见按钮回调 |
| 455 | if (val) { | 475 | if (val) { |
| ... | @@ -468,6 +488,7 @@ export default { | ... | @@ -468,6 +488,7 @@ export default { |
| 468 | // 全选可编辑按钮回调 | 488 | // 全选可编辑按钮回调 |
| 469 | console.warn(val) | 489 | console.warn(val) |
| 470 | } | 490 | } |
| 491 | + /******************* END *******************/ | ||
| 471 | 492 | ||
| 472 | /****** 用户选择控件弹框 ******/ | 493 | /****** 用户选择控件弹框 ******/ |
| 473 | const openUserForm = () => { | 494 | const openUserForm = () => { |
| ... | @@ -479,6 +500,7 @@ export default { | ... | @@ -479,6 +500,7 @@ export default { |
| 479 | state.dialogUserFormVisible = status | 500 | state.dialogUserFormVisible = status |
| 480 | } | 501 | } |
| 481 | const onConfirmUserView = (data: any) => { | 502 | const onConfirmUserView = (data: any) => { |
| 503 | + state.userTags = data; | ||
| 482 | console.log(data) | 504 | console.log(data) |
| 483 | } | 505 | } |
| 484 | /******************* END *******************/ | 506 | /******************* END *******************/ |
| ... | @@ -534,7 +556,32 @@ export default { | ... | @@ -534,7 +556,32 @@ export default { |
| 534 | // 判断是否是流程节点 | 556 | // 判断是否是流程节点 |
| 535 | let model_id = model.id | 557 | let model_id = model.id |
| 536 | if (model_id !== 'start-node' && model_id!== 'end-node') { | 558 | if (model_id !== 'start-node' && model_id!== 'end-node') { |
| 537 | - state.detailModel = model | 559 | + state.detailModel = model; |
| 560 | + // 获取节点名称 | ||
| 561 | + state.node_name = state.detailModel.text; | ||
| 562 | + // // 检查字段权限选中情况 | ||
| 563 | + // let checked_count = state.field_auths.filter((ele) => { | ||
| 564 | + // if (ele.visible.checked && !ele.visible.disabled) { | ||
| 565 | + // return ele; | ||
| 566 | + // } | ||
| 567 | + // }); | ||
| 568 | + // if (checked_count.length === state.field_auths.length) { | ||
| 569 | + // state.auth_all_checked = true; | ||
| 570 | + // } else { | ||
| 571 | + // state.auth_all_checked = false; | ||
| 572 | + // } | ||
| 573 | + // let edit_count = state.field_auths.filter((ele) => { | ||
| 574 | + // if (ele.editable.checked && !ele.editable.disabled) { | ||
| 575 | + // return ele; | ||
| 576 | + // } | ||
| 577 | + // }); | ||
| 578 | + // if (edit_count.length === state.field_auths.length) { | ||
| 579 | + // state.auth_all_edit = true; | ||
| 580 | + // } else { | ||
| 581 | + // state.auth_all_edit = false; | ||
| 582 | + // } | ||
| 583 | + | ||
| 584 | + // 打开属性表单 | ||
| 538 | editor.openModel() | 585 | editor.openModel() |
| 539 | } else { | 586 | } else { |
| 540 | editor.closeModel() | 587 | editor.closeModel() |
| ... | @@ -583,11 +630,15 @@ export default { | ... | @@ -583,11 +630,15 @@ export default { |
| 583 | // return false | 630 | // return false |
| 584 | // } | 631 | // } |
| 585 | // }) | 632 | // }) |
| 586 | - // editor.updateModel(state.detailModel) | 633 | + state.detailModel.text = state.node_name |
| 634 | + | ||
| 635 | + // state.detailModel.label = state.node_name | ||
| 636 | + // 更新流程图信息 | ||
| 637 | + editor.updateModel(state.detailModel) | ||
| 587 | // editor.closeModel() | 638 | // editor.closeModel() |
| 588 | - console.log(state.node_name) | 639 | + console.log('节点名称', state.node_name) |
| 589 | - console.log(state.userTags) | 640 | + console.log('节点负责人', state.userTags) |
| 590 | - console.log(state.field_auths) | 641 | + console.log('字段权限', state.field_auths) |
| 591 | } | 642 | } |
| 592 | 643 | ||
| 593 | /** | 644 | /** |
| ... | @@ -601,14 +652,48 @@ export default { | ... | @@ -601,14 +652,48 @@ export default { |
| 601 | model: myObj, | 652 | model: myObj, |
| 602 | type: string, | 653 | type: string, |
| 603 | ): Promise<any> { | 654 | ): Promise<any> { |
| 655 | + let { nodes, edges } = editor.editorState.graph.save(); | ||
| 656 | + // 不可以删除开始与结束连接线 | ||
| 657 | + let node_id = model.id; | ||
| 658 | + for (let index = 0; index < edges.length; index++) { | ||
| 659 | + const element = edges[index] | ||
| 660 | + if( | ||
| 661 | + (element.target === node_id && element.source === 'start-node') || | ||
| 662 | + (element.source === node_id && element.target === 'end-node') | ||
| 663 | + ) | ||
| 664 | + { | ||
| 665 | + ElNotification.error('不可以删除【开始】与【结束】连接线') | ||
| 666 | + return Promise.reject('reject') | ||
| 667 | + } | ||
| 668 | + } | ||
| 604 | if (type === 'node') { | 669 | if (type === 'node') { |
| 605 | - if (model.label === '开始') { | 670 | + if (model.id === 'start-node') { |
| 606 | - state.editorLoading = true | 671 | + // state.editorLoading = true |
| 607 | - await delay(1000) | 672 | + // await delay(1000) |
| 608 | - state.editorLoading = false | 673 | + // state.editorLoading = false |
| 609 | ElNotification.error('不可以删除【开始】节点') | 674 | ElNotification.error('不可以删除【开始】节点') |
| 610 | return Promise.reject('reject') | 675 | return Promise.reject('reject') |
| 611 | } | 676 | } |
| 677 | + if (model.id === 'end-node') { | ||
| 678 | + ElNotification.error('不可以删除【结束】节点') | ||
| 679 | + return Promise.reject('reject') | ||
| 680 | + } | ||
| 681 | + // 流程图中必须有一个流程节点 | ||
| 682 | + let is_flow_node = nodes.filter(node => node.control === 'flow'); | ||
| 683 | + if (is_flow_node.length === 1) { | ||
| 684 | + ElNotification.error('流程图中必须有一个流程节点') | ||
| 685 | + return Promise.reject('reject') | ||
| 686 | + } | ||
| 687 | + } | ||
| 688 | + if (type === 'edge') { | ||
| 689 | + if (model.source === 'start-node') { | ||
| 690 | + ElNotification.error('不可以删除【开始】连接线') | ||
| 691 | + return Promise.reject('reject') | ||
| 692 | + } | ||
| 693 | + if (model.target === 'end-node') { | ||
| 694 | + ElNotification.error('不可以删除【结束】连接线') | ||
| 695 | + return Promise.reject('reject') | ||
| 696 | + } | ||
| 612 | } | 697 | } |
| 613 | } | 698 | } |
| 614 | 699 | ||
| ... | @@ -783,6 +868,8 @@ export default { | ... | @@ -783,6 +868,8 @@ export default { |
| 783 | handleAfterAdd, | 868 | handleAfterAdd, |
| 784 | 869 | ||
| 785 | handleActiveChange, | 870 | handleActiveChange, |
| 871 | + onAuthVisibleChange, | ||
| 872 | + onAuthEditChange, | ||
| 786 | onAuthAllChange, | 873 | onAuthAllChange, |
| 787 | onAuthAllEditChange, | 874 | onAuthAllEditChange, |
| 788 | 875 | ... | ... |
-
Please register or login to post a comment