针对多选人组件的全选问题修复

This commit is contained in:
yunkexin 2026-06-02 15:03:40 +08:00
parent 20ac5d77e9
commit 11030ffae0

View File

@ -202,13 +202,6 @@
getUserLists(json).then(res => {
if (res.IsSuccessful) {
this.selfDepartmentUsers = res.Data
}
})
}
// else {
// findAndAddUser(this.orgTree)
// }
findAndAddUser(this.orgTree)
let num = 0
for (let task of this.selfDepartmentUsers) {
const itemJson = this.defaultChecked.filter(i => !i.IS_DELETED).find((item) => {
@ -226,6 +219,14 @@
USER_ID: 'all',
})
}
}
})
}
// else {
// findAndAddUser(this.orgTree)
// }
findAndAddUser(this.orgTree)
},
@ -385,16 +386,6 @@
})
}
}
// arrayC.forEach(item => {
// this.checkedByAll.push({
// NAME: item.NAME,
// IS_DELETED: item.IS_DELETED,
// USER_ID: item.USER_ID,
// })
// })
// TODO:
} else {
if (e.type === 'dep') {
this.handleExpandOrg({
@ -430,6 +421,7 @@
// NAME: e.name
// }
})
this.checkAndUpdateAllSelectStatus()
}
}
} else {
@ -471,10 +463,47 @@
item.IS_DELETED = true
}
})
this.checkAndUpdateAllSelectStatus()
}
}
}
},
//
checkAndUpdateAllSelectStatus() {
//
if (!this.selfDepartmentUsers || this.selfDepartmentUsers.length === 0) return
// ID
const allUserIds = this.selfDepartmentUsers.map(user => user.ID)
// ID
//
const selectedUserIds = this.checkedByAll
.filter(item => !item.IS_DELETED && item.USER_ID && item.USER_ID !== 'all')
.map(item => item.USER_ID)
//
const isAllSelected = allUserIds.length > 0 &&
allUserIds.every(id => selectedUserIds.includes(id))
//
const allItem = this.checkedByAll.find(item => item.USER_ID === 'all')
const hasAllItem = allItem && !allItem.IS_DELETED
if (isAllSelected && !hasAllItem) {
//
this.checkedByAll.push({
NAME: '全选',
IS_DELETED: false,
USER_ID: 'all',
})
} else if (!isAllSelected && hasAllItem) {
//
if (allItem) {
allItem.IS_DELETED = true
}
}
},
removeChecked(value) {
this.checkedByAll.forEach(item => {
if (item.USER_ID === value.USER_ID) {