From f42d1541fa52be0a8f3e494ad87bf6b7b7b3aaa1 Mon Sep 17 00:00:00 2001 From: kerwincui <164770707@qq.com> Date: Sat, 9 Jul 2022 19:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=A8=E9=80=89=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/views/iot/group/device-list.vue | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/vue/src/views/iot/group/device-list.vue b/vue/src/views/iot/group/device-list.vue index 51ef6424..fc02ca62 100644 --- a/vue/src/views/iot/group/device-list.vue +++ b/vue/src/views/iot/group/device-list.vue @@ -9,7 +9,7 @@ - + @@ -146,9 +146,6 @@ export default { }, // 多选框选中数据 handleSelectionChange(selection, row) { - this.single = selection.length !== 1 - this.multiple = !selection.length; - // 设备ID是否存在于原始设备ID数组中 let index = this.ids.indexOf(row.deviceId); // 是否选中 @@ -161,13 +158,29 @@ export default { this.ids.splice(index, 1); } }, + // 全选事件处理 + handleSelectionAll(selection) { + for (let i = 0; i < this.deviceList.length; i++) { + // 设备ID是否存在于原始设备ID数组中 + let index = this.ids.indexOf(this.deviceList[i].deviceId); + // 是否选中 + let value = selection.indexOf(this.deviceList[i]); + if (index == -1 && value != -1) { + // 不存在且选中 + this.ids.push(this.deviceList[i].deviceId); + } else if (index != -1 && value == -1) { + // 存在且取消选中 + this.ids.splice(index, 1); + } + } + }, // 关闭选择设备列表 closeSelectDeviceList() { this.openDeviceList = false; }, // 更新分组下的设备 handleDeviceSelected() { - this.group.deviceIds=this.ids; + this.group.deviceIds = this.ids; updateDeviceGroups(this.group).then(response => { this.$modal.msgSuccess("更新分组下的设备成功"); this.openDeviceList = false;