From 22ce7144e71707c399f9320973df65074aa0560e Mon Sep 17 00:00:00 2001 From: x_ying <2438792676@qq.com> Date: Thu, 4 Aug 2022 08:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E5=85=A8=E9=80=89bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../archivesCheck/module/addCheck.vue | 28 ++++++++++++++++--- src/views/system/notifyManage/index.vue | 20 ++++++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/views/archivesManage/archivesCheck/module/addCheck.vue b/src/views/archivesManage/archivesCheck/module/addCheck.vue index 7ac3acd..7652ee1 100644 --- a/src/views/archivesManage/archivesCheck/module/addCheck.vue +++ b/src/views/archivesManage/archivesCheck/module/addCheck.vue @@ -29,6 +29,7 @@ placeholder="请选择" :collapse-tags="showTags" @change="selectChange" + @remove-tag="removeTag" > 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() } } diff --git a/src/views/system/notifyManage/index.vue b/src/views/system/notifyManage/index.vue index 52af82d..e4ed47b 100644 --- a/src/views/system/notifyManage/index.vue +++ b/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]