hookehuyr

新增备注

Showing 1 changed file with 149 additions and 96 deletions
...@@ -487,12 +487,41 @@ export default { ...@@ -487,12 +487,41 @@ export default {
487 } 487 }
488 }); 488 });
489 489
490 + onMounted(() => {
491 + // // 显示提示框的标志位
492 + // var showConfirmation = true;
493 + // // 监听 beforeunload 事件
494 + // window.addEventListener('beforeunload', function (event) {
495 + // if (showConfirmation) {
496 + // // 取消事件的默认行为(弹出确认对话框)
497 + // event.preventDefault();
498 + // // Chrome 和 Firefox 需要返回一个值以显示确认对话框
499 + // event.returnValue = '';
500 + // // 显示自定义的提示信息
501 + // var confirmationMessage = '确定要离开此页面吗?';
502 + // (event || window.event).returnValue = confirmationMessage; // 兼容旧版浏览器
503 + // return confirmationMessage;
504 + // }
505 + // });
506 + // // 监听 unload 事件
507 + // window.addEventListener('unload', function () {
508 + // // 设置标志位为 false,避免在刷新页面时再次显示提示框
509 + // showConfirmation = false;
510 + // });
511 + // axios.get('/srv/?a=query_form_all_field')
512 + // .then(res => {
513 + // console.warn(res.data);
514 + // });
515 + // $('.el-tabs__nav')
516 + // 根据数据获取选中的tag标签
517 + // setTagsList(state.userTabs);
518 + });
519 +
490 function handleActiveChange(name) { 520 function handleActiveChange(name) {
491 console.warn(name); 521 console.warn(name);
492 } 522 }
493 523
494 - const onAuthAllChange = val => { 524 + const onAuthAllChange = val => { // 全选可见按钮回调
495 - // 全选可见按钮回调
496 if (val) { 525 if (val) {
497 // 全部选中 526 // 全部选中
498 state.field_auths.forEach(ele => { 527 state.field_auths.forEach(ele => {
...@@ -505,14 +534,16 @@ export default { ...@@ -505,14 +534,16 @@ export default {
505 }); 534 });
506 } 535 }
507 }; 536 };
508 - const onAuthAllEditChange = val => { 537 + const onAuthAllEditChange = val => { // 全选可编辑按钮回调
509 - // 全选可编辑按钮回调
510 console.warn(val); 538 console.warn(val);
511 }; 539 };
512 540
513 - const openUserForm = () => { 541 + const openUserForm = () => { // 打开设置用户弹框
514 state.dialogUserFormVisible = true; 542 state.dialogUserFormVisible = true;
515 // TODO:查询到的用户列表数据 543 // TODO:查询到的用户列表数据
544 + state.userTags = [
545 + { id: "user-1-1", name: "用户1-1" },
546 + ]
516 state.userTabs = [ 547 state.userTabs = [
517 { 548 {
518 id: "tab-1", 549 id: "tab-1",
...@@ -531,7 +562,7 @@ export default { ...@@ -531,7 +562,7 @@ export default {
531 { 562 {
532 id: "user-1-1", 563 id: "user-1-1",
533 label: "用户1-1", 564 label: "用户1-1",
534 - checked: true, 565 + checked: false,
535 disabled: false 566 disabled: false
536 }, 567 },
537 { 568 {
...@@ -634,10 +665,13 @@ export default { ...@@ -634,10 +665,13 @@ export default {
634 ] 665 ]
635 } 666 }
636 ]; 667 ];
668 + // 对比选中的用户的 ID,选中的 ID 同步状态到 userTabs 的数据结构上
669 + state.userTags.forEach(ele => {
670 + modifyFieldValue(state.userTabs, "id", ele.id, true);
671 + });
637 }; 672 };
638 673
639 - const handleTabClick = (tab, event, idx) => { 674 + const handleTabClick = (tab, event, idx) => { // 点击Tab切换回调
640 - // 点击Tab切换回调
641 state.tabSelectData = tab.data; // tab选中数据提供给list类型使用 675 state.tabSelectData = tab.data; // tab选中数据提供给list类型使用
642 state.userList = []; // 清空用户列表 676 state.userList = []; // 清空用户列表
643 state.checkedUserList = []; // 清空选中用户列表 677 state.checkedUserList = []; // 清空选中用户列表
...@@ -669,8 +703,7 @@ export default { ...@@ -669,8 +703,7 @@ export default {
669 // } 703 // }
670 }; 704 };
671 705
672 - const handleTabContentClick = (tab, event) => { 706 + const handleTabContentClick = (tab, event) => { // 侧边栏Tab点击回调
673 - // 侧边栏Tab点击回调
674 // console.log(state.activeTabContent); 707 // console.log(state.activeTabContent);
675 // console.log(tab); 708 // console.log(tab);
676 // console.log(event); 709 // console.log(event);
...@@ -688,7 +721,7 @@ export default { ...@@ -688,7 +721,7 @@ export default {
688 }); 721 });
689 }; 722 };
690 723
691 - const handleNodeClick = data => { 724 + const handleNodeClick = data => { // 树形结构点击回调
692 // console.log(data); 725 // console.log(data);
693 if (data.list) { 726 if (data.list) {
694 state.userList = data.list; 727 state.userList = data.list;
...@@ -704,8 +737,15 @@ export default { ...@@ -704,8 +737,15 @@ export default {
704 } 737 }
705 }; 738 };
706 739
740 + /**
741 + * 递归查找匹配字段,并修改字段为新值
742 + *
743 + * @param {object} obj - 修改对象
744 + * @param {string} fieldName - 修改字段
745 + * @param {any} targetValue - 匹配值
746 + * @param {any} newValue - 修改新值
747 + */
707 function modifyFieldValue(obj, fieldName, targetValue, newValue) { 748 function modifyFieldValue(obj, fieldName, targetValue, newValue) {
708 - // 遍历相应ID修改选中值
709 // 检查当前层级的字段值是否匹配目标值 749 // 检查当前层级的字段值是否匹配目标值
710 if (obj[fieldName] === targetValue) { 750 if (obj[fieldName] === targetValue) {
711 obj["checked"] = newValue; 751 obj["checked"] = newValue;
...@@ -719,14 +759,18 @@ export default { ...@@ -719,14 +759,18 @@ export default {
719 } 759 }
720 } 760 }
721 761
722 - const handleCheckedUserListChange = (user, checked) => { 762 + const handleCheckedUserListChange = (user, checked) => { // 勾选用户回调
723 - // 勾选用户回调
724 // 修改选中值状态 763 // 修改选中值状态
725 modifyFieldValue(state.userTabs, "id", user.id, checked); 764 modifyFieldValue(state.userTabs, "id", user.id, checked);
726 }; 765 };
727 766
767 + /**
768 + * 递归获取树形结构下的所有list字段数据
769 + *
770 + * @param {Array} arr - The array to traverse.
771 + * @return {Array} - The list items found.
772 + */
728 function getAllListItems(arr) { 773 function getAllListItems(arr) {
729 - // 遍历递归获取list下面的数据
730 var result = []; 774 var result = [];
731 775
732 function recursiveGetListItems(subArr) { 776 function recursiveGetListItems(subArr) {
...@@ -745,8 +789,14 @@ export default { ...@@ -745,8 +789,14 @@ export default {
745 return result; 789 return result;
746 } 790 }
747 791
748 - const setTagsList = val => { 792 + /**
749 - let userList = []; 793 + * 根据 userTabs 的选中状态,更新 tag 选中列表显示
794 + * 获取生成 list 集合的 checked 状态,生成 tags 的勾选显示
795 + *
796 + * @param {Array} val - userTabs
797 + */
798 + const setTagsList = (val) => {
799 + let userList = []; // 存储所有的list数据
750 val.forEach(ele => { 800 val.forEach(ele => {
751 let data = getAllListItems(ele.data); 801 let data = getAllListItems(ele.data);
752 userList.push(data); 802 userList.push(data);
...@@ -771,20 +821,18 @@ export default { ...@@ -771,20 +821,18 @@ export default {
771 }); 821 });
772 }; 822 };
773 823
774 - // 监听数据结构选中值变化 824 + watch( // TAG: watch state.userTabs 监听数据结构选中值变化
775 - watch(
776 () => state.userTabs, 825 () => state.userTabs,
777 val => { 826 val => {
778 if (val) { 827 if (val) {
779 - // 设置tag选中列表 828 + // 更新 tags 选中列表显示
780 setTagsList(val); 829 setTagsList(val);
781 } 830 }
782 }, 831 },
783 { deep: true } 832 { deep: true }
784 ); 833 );
785 834
786 - const handleTagClose = tag => { 835 + const handleTagClose = (tag) => { // 移除 tags 成员标签回调
787 - // 移除成员标签回调
788 state.userTags.splice(state.userTags.indexOf(tag), 1); // 删除标签列表中的项 836 state.userTags.splice(state.userTags.indexOf(tag), 1); // 删除标签列表中的项
789 // 移除数据结构中的选中值 837 // 移除数据结构中的选中值
790 modifyFieldValue(state.userTabs, "id", tag.id, false); 838 modifyFieldValue(state.userTabs, "id", tag.id, false);
...@@ -792,55 +840,42 @@ export default { ...@@ -792,55 +840,42 @@ export default {
792 let tagsId = state.userTags.map(ele => { 840 let tagsId = state.userTags.map(ele => {
793 return ele.id; 841 return ele.id;
794 }); 842 });
795 - // console.warn(tagsId); 843 + // 处理tags列表和下面选中列表同步问题
796 - if (state.is_active_search) { // 搜索状态 844 + let checkDataList = [];
797 - // 获取tags中已删除的, 勾选列表中还勾选的值 845 + if (state.is_active_search) { // 激活搜索状态
798 - let result = state.checkedSearchUserList.filter( 846 + checkDataList = state.checkedSearchUserList;
799 - value => !tagsId.includes(value) 847 + } else { // 激活非搜索状态
800 - ); 848 + checkDataList = state.checkedUserList;
801 - // 选中列表中不存在勾选列表中项时,需要删除勾选列表中的项 849 + }
802 - if (result.length) { 850 + // 获取 tags 中已删除的, 勾选列表中还勾选的值
803 - result.forEach(ele => { 851 + let result = checkDataList.filter(
804 - state.checkedSearchUserList.splice(
805 - state.checkedSearchUserList.indexOf(ele),
806 - 1
807 - );
808 - });
809 - }
810 - } else { // 非搜索状态
811 - // 获取tags中已删除的, 勾选列表中还勾选的值
812 - let result = state.checkedUserList.filter(
813 value => !tagsId.includes(value) 852 value => !tagsId.includes(value)
814 - ); 853 + );
815 - // 选中列表中不存在勾选列表中项时,需要删除勾选列表中的项 854 + // 如果存在不同步的值,需要在列表中删除勾选列表中的项
816 - if (result.length) { 855 + if (result.length) {
817 - result.forEach(ele => { 856 + result.forEach(ele => {
818 - state.checkedUserList.splice(state.checkedUserList.indexOf(ele), 1); 857 + checkDataList.splice(
819 - }); 858 + checkDataList.indexOf(ele),
820 - } 859 + 1
860 + );
861 + });
821 } 862 }
822 - // console.log(result);
823 - // console.log(state.userTags);
824 - // console.log(state.checkedUserList);
825 }; 863 };
826 864
827 - const closeUserForm = () => { 865 + const closeUserForm = () => { // 关闭用户列表表单回调
828 - // 关闭用户列表表单回调
829 state.dialogUserFormVisible = false; 866 state.dialogUserFormVisible = false;
830 }; 867 };
831 - const confirmUserForm = () => { 868 + const confirmUserForm = () => { // 确认用户列表表单回调
832 - // 确认用户列表表单回调
833 state.dialogUserFormVisible = false; 869 state.dialogUserFormVisible = false;
834 console.log(state.userTags); 870 console.log(state.userTags);
835 }; 871 };
836 872
837 - const activeSearchBtn = () => { 873 + const activeSearchBtn = () => { // 激活搜索按钮操作
838 state.is_active_search = !state.is_active_search; 874 state.is_active_search = !state.is_active_search;
839 - state.searchUserList = []; 875 + state.searchUserList = []; // 清空搜索列表
840 }; 876 };
841 877
842 - const checkSearchStatus = () => { 878 + const checkSearchStatus = () => { // 在搜索框中同步显示tag框选中的用户
843 - // 在搜索框中同步显示tag框选中的用户
844 state.userTags.forEach(ele => { 879 state.userTags.forEach(ele => {
845 state.searchUserList.forEach(item => { 880 state.searchUserList.forEach(item => {
846 if (ele.id === item.id) { 881 if (ele.id === item.id) {
...@@ -853,8 +888,7 @@ export default { ...@@ -853,8 +888,7 @@ export default {
853 .filter(ele => ele.checked) 888 .filter(ele => ele.checked)
854 .map(ele => ele.id); 889 .map(ele => ele.id);
855 }; 890 };
856 - const checkUserStatus = () => { 891 + const checkUserStatus = () => { // 在搜索框中同步显示tag框选中的用户
857 - // 在搜索框中同步显示tag框选中的用户
858 state.userTags.forEach(ele => { 892 state.userTags.forEach(ele => {
859 state.userList.forEach(item => { 893 state.userList.forEach(item => {
860 if (ele.id === item.id) { 894 if (ele.id === item.id) {
...@@ -868,14 +902,13 @@ export default { ...@@ -868,14 +902,13 @@ export default {
868 .map(ele => ele.id); 902 .map(ele => ele.id);
869 }; 903 };
870 904
871 - const onClearSearch = () => { 905 + const onClearSearch = () => { // 清空搜索回调
872 - // 清空搜索回调
873 state.is_active_search = !state.is_active_search; 906 state.is_active_search = !state.is_active_search;
874 // 同步显示tag框选中的用户 907 // 同步显示tag框选中的用户
875 checkUserStatus(); 908 checkUserStatus();
876 }; 909 };
877 - const onSearch = () => { 910 + const onSearch = () => { // 搜索回调
878 - // TODO: 搜索回调 911 + // TODO: 获取后台数据
879 state.searchUserList = [ 912 state.searchUserList = [
880 { 913 {
881 id: "user-1-1", 914 id: "user-1-1",
...@@ -896,41 +929,11 @@ export default { ...@@ -896,41 +929,11 @@ export default {
896 disabled: true 929 disabled: true
897 } 930 }
898 ]; 931 ];
899 - // console.log(state.userTags); 932 + // 如果 tags 里存在的值,需要在搜索列表中勾选
900 checkSearchStatus(); 933 checkSearchStatus();
901 }; 934 };
902 935
903 - onMounted(() => { 936 + watch( // TAG: watch state.dialogUserFormVisible 监听弹框显示,修改tab文字宽度
904 - // // 显示提示框的标志位
905 - // var showConfirmation = true;
906 - // // 监听 beforeunload 事件
907 - // window.addEventListener('beforeunload', function (event) {
908 - // if (showConfirmation) {
909 - // // 取消事件的默认行为(弹出确认对话框)
910 - // event.preventDefault();
911 - // // Chrome 和 Firefox 需要返回一个值以显示确认对话框
912 - // event.returnValue = '';
913 - // // 显示自定义的提示信息
914 - // var confirmationMessage = '确定要离开此页面吗?';
915 - // (event || window.event).returnValue = confirmationMessage; // 兼容旧版浏览器
916 - // return confirmationMessage;
917 - // }
918 - // });
919 - // // 监听 unload 事件
920 - // window.addEventListener('unload', function () {
921 - // // 设置标志位为 false,避免在刷新页面时再次显示提示框
922 - // showConfirmation = false;
923 - // });
924 - // axios.get('/srv/?a=query_form_all_field')
925 - // .then(res => {
926 - // console.warn(res.data);
927 - // });
928 - // $('.el-tabs__nav')
929 - // 根据数据获取选中的tag标签
930 - setTagsList(state.userTabs);
931 - });
932 -
933 - watch(
934 () => state.dialogUserFormVisible, 937 () => state.dialogUserFormVisible,
935 val => { 938 val => {
936 if (val) { 939 if (val) {
...@@ -941,8 +944,16 @@ export default { ...@@ -941,8 +944,16 @@ export default {
941 } 944 }
942 ); 945 );
943 946
947 +
948 + /********** 流程图功能函数 **********/
949 +
944 let editor; 950 let editor;
945 951
952 + /**
953 + * Handle the event when a node is double-clicked.
954 + *
955 + * @param {Object} e - The event object
956 + */
946 function onDblclickNode(e) { 957 function onDblclickNode(e) {
947 const model = G6.Util.clone(e.item.get("model")); 958 const model = G6.Util.clone(e.item.get("model"));
948 model.style = model.style || {}; 959 model.style = model.style || {};
...@@ -952,6 +963,11 @@ export default { ...@@ -952,6 +963,11 @@ export default {
952 editor.openModel(); 963 editor.openModel();
953 } 964 }
954 965
966 + /**
967 + * Handles the double click event on an edge.
968 + *
969 + * @param {Event} e - The event object representing the double click event.
970 + */
955 function onDblClickEdge(e) { 971 function onDblClickEdge(e) {
956 const { source, target, style, labelCfg, label } = e.item.get("model"); 972 const { source, target, style, labelCfg, label } = e.item.get("model");
957 const model = { 973 const model = {
...@@ -970,15 +986,34 @@ export default { ...@@ -970,15 +986,34 @@ export default {
970 editor.openModel(); 986 editor.openModel();
971 } 987 }
972 988
989 + /**
990 + * Cancels the operation and closes the editor model.
991 + *
992 + * @param {}
993 + * @return {}
994 + */
973 function cancel() { 995 function cancel() {
974 editor.closeModel(); 996 editor.closeModel();
975 } 997 }
976 998
999 + /**
1000 + * Saves the changes made in the editor.
1001 + *
1002 + * @param {type} paramName - description of parameter
1003 + * @return {type} description of return value
1004 + */
977 function save() { 1005 function save() {
978 editor.updateModel(state.detailModel); 1006 editor.updateModel(state.detailModel);
979 editor.closeModel(); 1007 editor.closeModel();
980 } 1008 }
981 1009
1010 + /**
1011 + * Handles the before delete event of the model.
1012 + *
1013 + * @param {Object} model - The model object.
1014 + * @param {string} type - The type of the model.
1015 + * @return {Promise} A promise that resolves when the event is handled.
1016 + */
982 async function handleBeforeDelete(model, type) { 1017 async function handleBeforeDelete(model, type) {
983 if (type === "node") { 1018 if (type === "node") {
984 if (model.label === "开始") { 1019 if (model.label === "开始") {
...@@ -991,6 +1026,12 @@ export default { ...@@ -991,6 +1026,12 @@ export default {
991 } 1026 }
992 } 1027 }
993 1028
1029 + /**
1030 + * Handles the logic after deleting a model.
1031 + *
1032 + * @param {Object} model - The model being deleted.
1033 + * @param {string} type - The type of the model being deleted.
1034 + */
994 function handleAfterDelete(model, type) { 1035 function handleAfterDelete(model, type) {
995 if (type === "edge") { 1036 if (type === "edge") {
996 console.log("delete edge"); 1037 console.log("delete edge");
...@@ -999,6 +1040,13 @@ export default { ...@@ -999,6 +1040,13 @@ export default {
999 } 1040 }
1000 } 1041 }
1001 1042
1043 + /**
1044 + * A function to handle something before adding.
1045 + *
1046 + * @param {object} model - The model object.
1047 + * @param {string} type - The type of the model.
1048 + * @return {Promise} A promise that resolves to a result or rejects with an error.
1049 + */
1002 function handleBeforeAdd(model, type) { 1050 function handleBeforeAdd(model, type) {
1003 if (type === "edge") { 1051 if (type === "edge") {
1004 if (model.source === "end-node") { 1052 if (model.source === "end-node") {
...@@ -1028,6 +1076,11 @@ export default { ...@@ -1028,6 +1076,11 @@ export default {
1028 } 1076 }
1029 } 1077 }
1030 1078
1079 + /**
1080 + * Logs the data from the editor's graph.
1081 + *
1082 + * @return {undefined} No return value.
1083 + */
1031 function logData() { 1084 function logData() {
1032 let { nodes, edges } = editor.editorState.graph.save(); 1085 let { nodes, edges } = editor.editorState.graph.save();
1033 nodes = nodes.map( 1086 nodes = nodes.map(
......