Browse Source

选择器全选bug

master
x_ying 3 years ago
parent
commit
22ce7144e7
  1. 28
      src/views/archivesManage/archivesCheck/module/addCheck.vue
  2. 20
      src/views/system/notifyManage/index.vue

28
src/views/archivesManage/archivesCheck/module/addCheck.vue

@ -29,6 +29,7 @@
placeholder="请选择"
:collapse-tags="showTags"
@change="selectChange"
@remove-tag="removeTag"
>
<el-option
v-for="item in category"
@ -131,6 +132,7 @@ export default {
nodeKey: 'id',
defaultCheckedKeys: [],
categoryValue: [0, 1, 2, 3],
oldCategory: [0, 1, 2, 3],
category: [
{ value: 0, label: '全部' },
{ value: 1, label: '档号' },
@ -151,14 +153,32 @@ export default {
},
//
selectChange(val) {
console.log(val)
if (val[val.length - 1] === 0) {
// console.log(val)
if (val[val.length - 1] === 0) { //
this.categoryValue = [0, 1, 2, 3]
this.showTags = true
} else {
this.categoryValue = this.categoryValue.filter(item => item !== 0)
this.showTags = false
const arr1 = this.oldCategory.filter(item => item !== 0)
const arr2 = val.filter(item => item !== 0)
if (arr1.length === arr2.length) { //
this.categoryValue = []
} else if (arr1.length < arr2.length && arr2.length === this.category.length - 1) {
this.categoryValue.unshift(0) //
this.showTags = true
} else {
this.categoryValue = this.categoryValue.filter(item => item !== 0) //
this.showTags = false
}
}
this.oldCategory = this.categoryValue
},
//
removeTag(val) {
console.log(val, '-------')
if (val === 0) {
this.categoryValue = []
}
this.$forceUpdate()
}
}

20
src/views/system/notifyManage/index.vue

@ -117,7 +117,8 @@ export default {
{ value: 3, label: '王五' },
{ value: 4, label: '张三' },
{ value: 5, label: '李四' },
{ value: 6, label: '王五' }
{ value: 6, label: '王五' },
{ value: 7, label: '王五' }
],
devOptions: [
{ value: 0, label: '全部设备' },
@ -126,6 +127,7 @@ export default {
{ value: 3, label: '设备3' }
],
selectOptions: [],
oldSelect: null,
showTags: true,
rules: {
msgType: [
@ -218,14 +220,24 @@ export default {
//
defaultSelAll() {
this.selectOptions = this.sendObjOptions.map(item => { return item.value })
this.oldSelect = this.selectOptions
this.showTags = true
},
changeSelect(val) {
if (val[val.length - 1] === 0) {
if (val[val.length - 1] === 0) { //
this.defaultSelAll()
} else {
this.selectOptions = this.selectOptions.filter(item => item !== 0)
this.showTags = false
const arr1 = this.oldSelect.filter(item => item !== 0)
const arr2 = val.filter(item => item !== 0)
if (arr1.length === arr2.length) { //
this.selectOptions = []
} else if (arr1.length < arr2.length && arr2.length === this.sendObjOptions.length - 1) {
this.defaultSelAll() //
} else {
this.selectOptions = this.selectOptions.filter(item => item !== 0) //
this.showTags = false
}
this.oldSelect = this.selectOptions
}
//
// var endSelectVal = val[val.length - 1]

Loading…
Cancel
Save