bug
This commit is contained in:
@@ -83,7 +83,7 @@
|
||||
<el-scrollbar class="AiWechatSelecter-list">
|
||||
<div class="user-wrapper">
|
||||
<el-checkbox-group v-model="userIds" @change="onCheckboxChange">
|
||||
<el-checkbox v-for="item in list" :label="item.id" :key="item.id" @change="e => onboxChange(item.id, e)">{{ item.name }}</el-checkbox>
|
||||
<el-checkbox v-for="item in list" :label="item[props.id]" :key="item[props.id]" @change="e => onboxChange(item[props.id], e)">{{ item.name }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
<AiEmpty v-if="!list.length"></AiEmpty>
|
||||
@@ -235,7 +235,9 @@
|
||||
return {
|
||||
...item,
|
||||
id: item[this.props.id],
|
||||
name: item[this.props.label]
|
||||
name: item[this.props.label],
|
||||
[this.props.id]: item[this.props.id],
|
||||
[this.props.label]: item[this.props.label]
|
||||
}
|
||||
})))
|
||||
|
||||
@@ -254,7 +256,9 @@
|
||||
return {
|
||||
...item,
|
||||
id: item[this.props.id],
|
||||
name: item[this.props.label]
|
||||
name: item[this.props.label],
|
||||
[this.props.id]: item[this.props.id],
|
||||
[this.props.label]: item[this.props.label]
|
||||
}
|
||||
})))
|
||||
this.userIds = this.chooseUser.map(v => v[this.props.id])
|
||||
@@ -278,14 +282,18 @@
|
||||
return {
|
||||
...item,
|
||||
id: item[this.props.id],
|
||||
name: item[this.props.label]
|
||||
name: item[this.props.label],
|
||||
[this.props.id]: item[this.props.id],
|
||||
[this.props.label]: item[this.props.label]
|
||||
}
|
||||
})))
|
||||
this.chooseUser = JSON.parse(JSON.stringify(this.value.map(item => {
|
||||
return {
|
||||
...item,
|
||||
id: item[this.props.id],
|
||||
name: item[this.props.label]
|
||||
name: item[this.props.label],
|
||||
[this.props.id]: item[this.props.id],
|
||||
[this.props.label]: item[this.props.label]
|
||||
}
|
||||
})))
|
||||
|
||||
@@ -307,18 +315,18 @@
|
||||
]
|
||||
} else {
|
||||
this.list.forEach(v => {
|
||||
if (!this.chooseUser.map(e => e.id).includes(v.id)) {
|
||||
if (!this.chooseUser.map(e => e[this.props.id]).includes(v[this.props.id])) {
|
||||
this.chooseUser.push(v)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.chooseUser = this.chooseUser.filter(v => {
|
||||
return !this.list.map(v => v.id).includes(v.id)
|
||||
return !this.list.map(v => v[this.props.id]).includes(v[this.props.id])
|
||||
})
|
||||
}
|
||||
|
||||
this.userIds = this.chooseUser.map(v => v.id)
|
||||
this.userIds = this.chooseUser.map(v => v[this.props.id])
|
||||
},
|
||||
|
||||
showSelecter () {
|
||||
@@ -328,7 +336,7 @@
|
||||
},
|
||||
|
||||
onTreeChange (e) {
|
||||
this.search.departmentId = e.id || ''
|
||||
this.search.departmentId = e[this.props.id] || ''
|
||||
this.search.current = 1
|
||||
|
||||
this.$nextTick(() => {
|
||||
@@ -346,7 +354,7 @@
|
||||
|
||||
onboxChange (id, v) {
|
||||
if (!this.isMultiple) {
|
||||
const checked = this.list.filter(v => v.id === id)
|
||||
const checked = this.list.filter(v => v[this.props.id] === id)
|
||||
if (v) {
|
||||
const v = checked[checked.length - 1]
|
||||
this.chooseUser = [v]
|
||||
@@ -354,7 +362,7 @@
|
||||
}
|
||||
|
||||
if (!v) {
|
||||
if (this.chooseUser.findIndex(v => v.id === id) > -1) {
|
||||
if (this.chooseUser.findIndex(v => v[this.props.id] === id) > -1) {
|
||||
this.chooseUser = []
|
||||
}
|
||||
}
|
||||
@@ -363,21 +371,21 @@
|
||||
|
||||
onCheckboxChange (ids) {
|
||||
this.$nextTick(() => {
|
||||
const checked = this.list.filter(v => ids.includes(v.id))
|
||||
const unChecked = this.list.filter(v => !ids.includes(v.id))
|
||||
const checked = this.list.filter(v => ids.includes(v[this.props.id]))
|
||||
const unChecked = this.list.filter(v => !ids.includes(v[this.props.id]))
|
||||
if (!this.isMultiple) {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
this.chooseUser.forEach((v, index) => {
|
||||
if (unChecked.findIndex(e => e.id === v.id) > -1) {
|
||||
if (unChecked.findIndex(e => e[this.props.id] === v[this.props.id]) > -1) {
|
||||
this.chooseUser.splice(index, 1)
|
||||
}
|
||||
})
|
||||
|
||||
checked.forEach(v => {
|
||||
if (this.chooseUser.findIndex(e => e.id === v.id) < 0) {
|
||||
if (this.chooseUser.findIndex(e => e[this.props.id] === v[this.props.id]) < 0) {
|
||||
this.chooseUser.push(v)
|
||||
}
|
||||
})
|
||||
@@ -505,16 +513,12 @@
|
||||
|
||||
this.$emit('change', JSON.parse(JSON.stringify(this.chooseUser.map(item => {
|
||||
return {
|
||||
...item,
|
||||
[this.props.id]: item.id,
|
||||
[this.props.label]: item.name
|
||||
...item
|
||||
}
|
||||
}))))
|
||||
this.showUserList = JSON.parse(JSON.stringify(this.chooseUser.map(item => {
|
||||
return {
|
||||
...item,
|
||||
[this.props.id]: item.id,
|
||||
[this.props.label]: item.name
|
||||
...item
|
||||
}
|
||||
})))
|
||||
this.isShow = false
|
||||
|
||||
Reference in New Issue
Block a user