hookehuyr

fix 代码整理

1 <!-- 1 <!--
2 * @Date: 2022-08-29 14:31:20 2 * @Date: 2022-08-29 14:31:20
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-08-06 16:03:02 4 + * @LastEditTime: 2024-08-06 16:18:24
5 * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue 5 * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue
6 * @Description: 树形组件 6 * @Description: 树形组件
7 --> 7 -->
...@@ -554,30 +554,6 @@ const checkedGroup = ref({ ...@@ -554,30 +554,6 @@ const checkedGroup = ref({
554 }); 554 });
555 555
556 /** 556 /**
557 - * 重置角色Tab列表的disable状态
558 - */
559 -// const resetRoleDisable = () => {
560 -// // 如果角色没有选中,解除禁用
561 -// if (!role_checked.value.length) {
562 -// roleList.value.forEach(item => {
563 -// item.disabled = false;
564 -// });
565 -// }
566 -// }
567 -
568 -/**
569 -* 重置成员Tab列表的disable状态
570 -*/
571 -// const resetUserDisable = () => {
572 -// // 如果成员没有选中,解除禁用
573 -// if (!user_checked.value.length) {
574 -// userList.value.forEach(item => {
575 -// item.disabled = false;
576 -// });
577 -// }
578 -// }
579 -
580 -/**
581 * 重置搜索结果列表的disable状态 557 * 重置搜索结果列表的disable状态
582 */ 558 */
583 const resetSearchDisable = () => { 559 const resetSearchDisable = () => {
...@@ -589,15 +565,6 @@ const resetSearchDisable = () => { ...@@ -589,15 +565,6 @@ const resetSearchDisable = () => {
589 } 565 }
590 } 566 }
591 567
592 -/**
593 - * 重置所有列表的disable状态
594 - */
595 -// const resetAllDisable = () => {
596 -// resetRoleDisable(); // 重置角色禁用状态
597 -// resetUserDisable(); // 重置成员禁用状态
598 -// resetSearchDisable(); // 重置搜索结果禁用状态
599 -// }
600 -
601 const onRemoveDeptTag = (dept) => { // 移除部门标签 568 const onRemoveDeptTag = (dept) => { // 移除部门标签
602 // 移除选中框显示 569 // 移除选中框显示
603 const index = checkedGroup.value.dept.findIndex(item => JSON.stringify(item) === JSON.stringify(dept)); 570 const index = checkedGroup.value.dept.findIndex(item => JSON.stringify(item) === JSON.stringify(dept));
...@@ -673,48 +640,11 @@ const deptListReset = () => { // 组织重置列表 ...@@ -673,48 +640,11 @@ const deptListReset = () => { // 组织重置列表
673 640
674 const roleListReset = () => { // 角色重置列表 641 const roleListReset = () => { // 角色重置列表
675 roleList.value = dept_list; 642 roleList.value = dept_list;
676 - // // 单选模式下,勾选项目操作一个时,角色选项不可勾选
677 - // if (check_type.value === 'single') {
678 - // if (treeCheckedCount.value) {
679 - // roleList.value.forEach(item => {
680 - // item.disabled = true;
681 - // checkedGroup.value.role.forEach(role => {
682 - // if (role.id === item.id) {
683 - // item.disabled = false;
684 - // }
685 - // })
686 - // });
687 - // } else {
688 - // roleList.value.forEach(item => {
689 - // item.disabled = false;
690 - // })
691 - // }
692 - // }
693 } 643 }
694 644
695 const userListReset = () => { // 成员重置列表 645 const userListReset = () => { // 成员重置列表
696 userTreeRef.value.setData(role_list); 646 userTreeRef.value.setData(role_list);
697 userTreeRef.value.setExpand(35697, true); 647 userTreeRef.value.setExpand(35697, true);
698 - // // 单选模式
699 - // if (check_type.value === 'single') {
700 - // if (treeCheckedCount.value) { // 已勾选值一个
701 - // if (checkedGroup.value.user.length) {
702 - // checkedGroup.value.user.forEach(user => {
703 - // userList.value.forEach(item => {
704 - // if (user.id === item.id) {
705 - // item.disabled = false;
706 - // } else {
707 - // item.disabled = true;
708 - // }
709 - // });
710 - // })
711 - // } else {
712 - // userList.value.forEach(item => {
713 - // item.disabled = true;
714 - // })
715 - // }
716 - // }
717 - // }
718 } 648 }
719 /**************** END *****************/ 649 /**************** END *****************/
720 650
...@@ -722,12 +652,6 @@ const userListReset = () => { // 成员重置列表 ...@@ -722,12 +652,6 @@ const userListReset = () => { // 成员重置列表
722 const select_dept_value = ref(); // 组织结构树形选中值 652 const select_dept_value = ref(); // 组织结构树形选中值
723 const deptTreeDisableAll = ref(false); // 组织结构树形禁用 653 const deptTreeDisableAll = ref(false); // 组织结构树形禁用
724 654
725 -// const getDeptTreeData = () => { // 获取组织结构数据
726 -// deptTreeRef.value.setData(role_list);
727 -// // 默认展开第一个
728 -// deptTreeRef.value.setExpand(35697, true);
729 -// }
730 -
731 /** 655 /**
732 * 组织结构单选勾中 656 * 组织结构单选勾中
733 * @param {*} node 657 * @param {*} node
...@@ -814,40 +738,18 @@ const roleChangeMethod = (val) => { ...@@ -814,40 +738,18 @@ const roleChangeMethod = (val) => {
814 * @param {*} evt 738 * @param {*} evt
815 */ 739 */
816 const onRoleClick = (role, evt, index) => { 740 const onRoleClick = (role, evt, index) => {
817 - // if (role.disabled) { // 节点禁用时不能操作 741 + // 单选模式
818 - // showToast('单选模式下,只能勾选一个')
819 - // return;
820 - // }
821 - // // 单选模式
822 - // if (check_type.value === 'single') {
823 - // // 移除选中框显示
824 - // const index = checkedGroup.value['role'].findIndex(item => item === role.id);
825 - // checkedGroup.value['role'].splice(index, 1);
826 - // // 超出选中1个,禁用其他选中
827 - // if (!treeCheckedCount.value) {
828 - // roleList.value.forEach(item => {
829 - // if (item.id === role.id) {
830 - // item.disabled = false;
831 - // } else {
832 - // item.disabled = true;
833 - // }
834 - // });
835 - // }
836 - // // 如果没有选中,解除禁用
837 - // resetRoleDisable();
838 - // }
839 -
840 if (check_type.value === 'single') { 742 if (check_type.value === 'single') {
841 - const idx = checkedGroup.value['role'].findIndex(item => item.id === role.id); 743 + const current_idx = checkedGroup.value['role'].findIndex(item => item.id === role.id);
842 if (treeCheckedCount.value) { 744 if (treeCheckedCount.value) {
843 - if (idx === -1) { 745 + if (current_idx === -1) {
844 showToast('单选模式下,只能勾选一个') 746 showToast('单选模式下,只能勾选一个')
845 setTimeout(() => { 747 setTimeout(() => {
846 roleCheckboxRefs.value[index].toggle(); 748 roleCheckboxRefs.value[index].toggle();
847 }, 10); 749 }, 10);
848 return; 750 return;
849 } else { 751 } else {
850 - checkedGroup.value['role'].splice(idx, 1); 752 + checkedGroup.value['role'].splice(current_idx, 1);
851 } 753 }
852 } 754 }
853 } 755 }
...@@ -870,46 +772,25 @@ const userList = ref([]); ...@@ -870,46 +772,25 @@ const userList = ref([]);
870 const onUserTreeClick = (node) => { // 点击成员树形回调 772 const onUserTreeClick = (node) => { // 点击成员树形回调
871 userList.value = node.user; 773 userList.value = node.user;
872 user_checked.value = checkedGroup.value.user.map(item => item.id); 774 user_checked.value = checkedGroup.value.user.map(item => item.id);
873 - // // 单选模式
874 - // if (check_type.value === 'single') {
875 - // if (treeCheckedCount.value) { // 已勾选值一个
876 - // if (checkedGroup.value.user.length) { // 成员列表有勾选值
877 - // checkedGroup.value.user.forEach(user => {
878 - // node.user.forEach(item => {
879 - // if (user.id === item.id) {
880 - // item.disabled = false;
881 - // } else {
882 - // item.disabled = true;
883 - // }
884 - // });
885 - // })
886 - // } else { // 成员列表没有勾选值
887 - // showToast('单选模式下,只能勾选一个')
888 - // userList.value = []
889 - // }
890 - // } else {
891 - // resetUserDisable();
892 - // }
893 - // }
894 } 775 }
895 776
896 const onUserChange = (val) => { // 成员多选组点击回调 777 const onUserChange = (val) => { // 成员多选组点击回调
897 } 778 }
898 779
899 -const onCheckUserChange = (val, evt, index) => { 780 +const onCheckUserChange = (val, evt, index) => { // 成员列表点击右侧选项回调
900 nextTick(() => { 781 nextTick(() => {
901 - 782 + // 单选模式
902 if (check_type.value === 'single') { 783 if (check_type.value === 'single') {
903 - const idx = checkedGroup.value['user'].findIndex(item => item.id === val.id); 784 + const current_idx = checkedGroup.value['user'].findIndex(item => item.id === val.id);
904 if (treeCheckedCount.value) { 785 if (treeCheckedCount.value) {
905 - if (idx === -1) { 786 + if (current_idx === -1) {
906 showToast('单选模式下,只能勾选一个') 787 showToast('单选模式下,只能勾选一个')
907 setTimeout(() => { 788 setTimeout(() => {
908 userCheckboxRefs.value[index].toggle(); 789 userCheckboxRefs.value[index].toggle();
909 }, 10); 790 }, 10);
910 return; 791 return;
911 } else { 792 } else {
912 - checkedGroup.value['user'].splice(idx, 1); 793 + checkedGroup.value['user'].splice(current_idx, 1);
913 } 794 }
914 } 795 }
915 } 796 }
...@@ -945,30 +826,6 @@ const onCheckUserChange = (val, evt, index) => { ...@@ -945,30 +826,6 @@ const onCheckUserChange = (val, evt, index) => {
945 } 826 }
946 } 827 }
947 }); 828 });
948 - // // 节点禁用时不能操作
949 - // if (val.disabled) {
950 - // showToast('单选模式下,只能勾选一个')
951 - // return;
952 - // }
953 - // // 单选模式
954 - // if (check_type.value === 'single') {
955 - // // 移除选中框显示
956 - // const index = checkedGroup.value['user'].findIndex(item => item === val.id);
957 - // checkedGroup.value['user'].splice(index, 1);
958 - // // 超出选中1个,禁用其他选中
959 - // if (!treeCheckedCount.value) {
960 - // userList.value.forEach(item => {
961 - // if (item.id === val.id) {
962 - // item.disabled = false;
963 - // } else {
964 - // item.disabled = true;
965 - // }
966 - // });
967 - // }
968 - // // 如果没有选中,解除禁用
969 - // resetUserDisable();
970 - // }
971 -
972 } 829 }
973 /**************** END *****************/ 830 /**************** END *****************/
974 831
...@@ -984,7 +841,9 @@ const user_dept_role = ref({ ...@@ -984,7 +841,9 @@ const user_dept_role = ref({
984 841
985 const onSearchResultChange = (val) => { // 监听搜索结果集点击回调,结果集为选中项 842 const onSearchResultChange = (val) => { // 监听搜索结果集点击回调,结果集为选中项
986 } 843 }
844 +
987 const deptCheckboxRef = ref(null); 845 const deptCheckboxRef = ref(null);
846 +
988 const onSearchResultClick = (val, evt) => { // 搜索结果集项点击回调 847 const onSearchResultClick = (val, evt) => { // 搜索结果集项点击回调
989 nextTick(() => { 848 nextTick(() => {
990 let checked = false; 849 let checked = false;
......