[update] 选择用户增加全选所有复选框

This commit is contained in:
lideqin
2024-02-21 15:26:48 +08:00
parent 003d0cb0d1
commit 42776e1d2c
4 changed files with 191 additions and 4 deletions
@@ -1,13 +1,18 @@
<template>
<j-modal
:title="$t('userSelect.selectUser')"
:maskClosable="false"
:width="1200"
:closable="true"
centered
@ok="handleOk"
@cancel="handleCancel"
switchFullscreen
:visible="visible">
<template v-slot:title>
<!-- 全选所有 -->
<a-checkbox v-if="type === 'checkbox'" v-model="isCheckedAll" class="modal-title-check" @change="checkedAllChange"/>
<span>{{ $t('userSelect.selectUser') }}</span>
</template>
<div class="modal-top-wrapper">
<div class="modal-left-wrapper">
<a-spin :spinning="treeLoading">
@@ -144,6 +149,19 @@ export default {
this.getUserListByIds(val)
}
}
},
dataSourceRight: {
immediate: true,
deep: true,
handler (val) {
console.log(val.length, this.ipagination.total)
if (val.length !== 0 && val.length === this.ipagination.total) {
// 说明都选中了
this.isCheckedAll = true
} else {
this.isCheckedAll = false
}
}
}
},
data () {
@@ -202,6 +220,7 @@ export default {
loadingLeft: false,
dataSourceRight: [],
workingGroupTreeList: [], // 内部工作组下拉框数据
isCheckedAll: false, // 是否选中所有
url: {
userList: '/act/user/workGroupPage',
userListByIds: '/sys/user/queryByIds'
@@ -265,6 +284,27 @@ export default {
return item
})
},
// 全选所有
checkedAllChange (e) {
console.log(e.target.checked)
if (e.target.checked) {
this.loadingLeft = true
const params = {}
params.pageNo = 1
params.pageSize = this.ipagination.total + 10
getAction(this.url.userList, params).then(res => {
if (res.success) {
this.dataSourceRight = res.result.records || []
this.selectedRowKeys = (res.result.records || []).map(item => item.userId)
}
}).finally(() => {
this.loadingLeft = false
})
} else {
this.dataSourceRight = []
this.selectedRowKeys = []
}
},
searchReset () {
this.queryParam = {}
this.loadData()
@@ -390,6 +430,9 @@ export default {
<style scoped lang="less">
@import '~@assets/less/common.less';
.modal-title-check {
margin-right: 10px;
}
.modal-top-wrapper {
display: flex;
height: 480px;
@@ -430,6 +473,8 @@ export default {
.name-content {
display: flex;
flex-wrap: wrap;
max-height: 200px;
overflow-y: auto;
.name-div {
width: auto;
padding: 5px 16px;