hookehuyr

fix 代码整理

<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-08-06 16:03:02
* @LastEditTime: 2024-08-06 16:18:24
* @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue
* @Description: 树形组件
-->
......@@ -554,30 +554,6 @@ const checkedGroup = ref({
});
/**
* 重置角色Tab列表的disable状态
*/
// const resetRoleDisable = () => {
// // 如果角色没有选中,解除禁用
// if (!role_checked.value.length) {
// roleList.value.forEach(item => {
// item.disabled = false;
// });
// }
// }
/**
* 重置成员Tab列表的disable状态
*/
// const resetUserDisable = () => {
// // 如果成员没有选中,解除禁用
// if (!user_checked.value.length) {
// userList.value.forEach(item => {
// item.disabled = false;
// });
// }
// }
/**
* 重置搜索结果列表的disable状态
*/
const resetSearchDisable = () => {
......@@ -589,15 +565,6 @@ const resetSearchDisable = () => {
}
}
/**
* 重置所有列表的disable状态
*/
// const resetAllDisable = () => {
// resetRoleDisable(); // 重置角色禁用状态
// resetUserDisable(); // 重置成员禁用状态
// resetSearchDisable(); // 重置搜索结果禁用状态
// }
const onRemoveDeptTag = (dept) => { // 移除部门标签
// 移除选中框显示
const index = checkedGroup.value.dept.findIndex(item => JSON.stringify(item) === JSON.stringify(dept));
......@@ -673,48 +640,11 @@ const deptListReset = () => { // 组织重置列表
const roleListReset = () => { // 角色重置列表
roleList.value = dept_list;
// // 单选模式下,勾选项目操作一个时,角色选项不可勾选
// if (check_type.value === 'single') {
// if (treeCheckedCount.value) {
// roleList.value.forEach(item => {
// item.disabled = true;
// checkedGroup.value.role.forEach(role => {
// if (role.id === item.id) {
// item.disabled = false;
// }
// })
// });
// } else {
// roleList.value.forEach(item => {
// item.disabled = false;
// })
// }
// }
}
const userListReset = () => { // 成员重置列表
userTreeRef.value.setData(role_list);
userTreeRef.value.setExpand(35697, true);
// // 单选模式
// if (check_type.value === 'single') {
// if (treeCheckedCount.value) { // 已勾选值一个
// if (checkedGroup.value.user.length) {
// checkedGroup.value.user.forEach(user => {
// userList.value.forEach(item => {
// if (user.id === item.id) {
// item.disabled = false;
// } else {
// item.disabled = true;
// }
// });
// })
// } else {
// userList.value.forEach(item => {
// item.disabled = true;
// })
// }
// }
// }
}
/**************** END *****************/
......@@ -722,12 +652,6 @@ const userListReset = () => { // 成员重置列表
const select_dept_value = ref(); // 组织结构树形选中值
const deptTreeDisableAll = ref(false); // 组织结构树形禁用
// const getDeptTreeData = () => { // 获取组织结构数据
// deptTreeRef.value.setData(role_list);
// // 默认展开第一个
// deptTreeRef.value.setExpand(35697, true);
// }
/**
* 组织结构单选勾中
* @param {*} node
......@@ -814,40 +738,18 @@ const roleChangeMethod = (val) => {
* @param {*} evt
*/
const onRoleClick = (role, evt, index) => {
// if (role.disabled) { // 节点禁用时不能操作
// showToast('单选模式下,只能勾选一个')
// return;
// }
// // 单选模式
// if (check_type.value === 'single') {
// // 移除选中框显示
// const index = checkedGroup.value['role'].findIndex(item => item === role.id);
// checkedGroup.value['role'].splice(index, 1);
// // 超出选中1个,禁用其他选中
// if (!treeCheckedCount.value) {
// roleList.value.forEach(item => {
// if (item.id === role.id) {
// item.disabled = false;
// } else {
// item.disabled = true;
// }
// });
// }
// // 如果没有选中,解除禁用
// resetRoleDisable();
// }
// 单选模式
if (check_type.value === 'single') {
const idx = checkedGroup.value['role'].findIndex(item => item.id === role.id);
const current_idx = checkedGroup.value['role'].findIndex(item => item.id === role.id);
if (treeCheckedCount.value) {
if (idx === -1) {
if (current_idx === -1) {
showToast('单选模式下,只能勾选一个')
setTimeout(() => {
roleCheckboxRefs.value[index].toggle();
}, 10);
return;
} else {
checkedGroup.value['role'].splice(idx, 1);
checkedGroup.value['role'].splice(current_idx, 1);
}
}
}
......@@ -870,46 +772,25 @@ const userList = ref([]);
const onUserTreeClick = (node) => { // 点击成员树形回调
userList.value = node.user;
user_checked.value = checkedGroup.value.user.map(item => item.id);
// // 单选模式
// if (check_type.value === 'single') {
// if (treeCheckedCount.value) { // 已勾选值一个
// if (checkedGroup.value.user.length) { // 成员列表有勾选值
// checkedGroup.value.user.forEach(user => {
// node.user.forEach(item => {
// if (user.id === item.id) {
// item.disabled = false;
// } else {
// item.disabled = true;
// }
// });
// })
// } else { // 成员列表没有勾选值
// showToast('单选模式下,只能勾选一个')
// userList.value = []
// }
// } else {
// resetUserDisable();
// }
// }
}
const onUserChange = (val) => { // 成员多选组点击回调
}
const onCheckUserChange = (val, evt, index) => {
const onCheckUserChange = (val, evt, index) => { // 成员列表点击右侧选项回调
nextTick(() => {
// 单选模式
if (check_type.value === 'single') {
const idx = checkedGroup.value['user'].findIndex(item => item.id === val.id);
const current_idx = checkedGroup.value['user'].findIndex(item => item.id === val.id);
if (treeCheckedCount.value) {
if (idx === -1) {
if (current_idx === -1) {
showToast('单选模式下,只能勾选一个')
setTimeout(() => {
userCheckboxRefs.value[index].toggle();
}, 10);
return;
} else {
checkedGroup.value['user'].splice(idx, 1);
checkedGroup.value['user'].splice(current_idx, 1);
}
}
}
......@@ -945,30 +826,6 @@ const onCheckUserChange = (val, evt, index) => {
}
}
});
// // 节点禁用时不能操作
// if (val.disabled) {
// showToast('单选模式下,只能勾选一个')
// return;
// }
// // 单选模式
// if (check_type.value === 'single') {
// // 移除选中框显示
// const index = checkedGroup.value['user'].findIndex(item => item === val.id);
// checkedGroup.value['user'].splice(index, 1);
// // 超出选中1个,禁用其他选中
// if (!treeCheckedCount.value) {
// userList.value.forEach(item => {
// if (item.id === val.id) {
// item.disabled = false;
// } else {
// item.disabled = true;
// }
// });
// }
// // 如果没有选中,解除禁用
// resetUserDisable();
// }
}
/**************** END *****************/
......@@ -984,7 +841,9 @@ const user_dept_role = ref({
const onSearchResultChange = (val) => { // 监听搜索结果集点击回调,结果集为选中项
}
const deptCheckboxRef = ref(null);
const onSearchResultClick = (val, evt) => { // 搜索结果集项点击回调
nextTick(() => {
let checked = false;
......