From 5a4d65986d3ecacf602ec33959873e4cf09fafc8 Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Mon, 14 Apr 2025 07:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/DeviceManagement.vue | 390 +++++++++++------- 1 file changed, 240 insertions(+), 150 deletions(-) diff --git a/main/manager-web/src/views/DeviceManagement.vue b/main/manager-web/src/views/DeviceManagement.vue index ade5e7d8..eb42d565 100644 --- a/main/manager-web/src/views/DeviceManagement.vue +++ b/main/manager-web/src/views/DeviceManagement.vue @@ -11,73 +11,86 @@ - -
- - - - - - - - - - - - - - - - - -
-
- - {{ isAllSelected ? '取消全选' : '全选' }} - - - 新增 - -
-
- - - - - 共{{ deviceList.length }}条记录 -
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+
+ + {{ isAllSelected ? '取消全选' : '全选' }} + + + 新增 + + 删除 +
+
+ + + + + 共{{ deviceList.length }}条记录 +
+
+
- - - +
+ + +
@@ -156,6 +169,28 @@ export default { this.$refs.deviceTable.toggleAllSelection(); }, + deleteSelected() { + if (this.selectedDevices.length === 0) { + this.$message.warning("请先选择需要删除的设备"); + return; + } + + this.$confirm(`确定要删除选中的${this.selectedDevices.length}个设备吗?`, '警告', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + const ids = this.selectedDevices.map(device => device.device_id); + Api.device.batchDeleteDevices(ids, ({ data }) => { + if (data.code === 0) { + this.$message.success(`成功删除${this.selectedDevices.length}个设备`); + this.fetchBindDevices(this.currentAgentId); + } else { + this.$message.error(data.msg || '删除失败'); + } + }); + }); + }, handleAddDevice() { this.addDeviceDialogVisible = true; @@ -214,25 +249,28 @@ export default { model: device.board, firmwareVersion: device.appVersion, macAddress: device.macAddress, - bindTime: formattedBindTime, // 使用格式化后的时间 + bindTime: formattedBindTime, lastConversation: device.lastConnectedAt, remark: device.alias, isEdit: false, otaSwitch: device.autoUpdate === 1, - // 添加原始时间用于排序 rawBindTime: new Date(device.createDate).getTime() }; }) - // 按照绑定时间降序排序 .sort((a, b) => a.rawBindTime - b.rawBindTime); } else { this.$message.error(data.msg || '获取设备列表失败'); } }); }, + headerCellClassName({ columnIndex }) { + if (columnIndex === 0) { + return "custom-selection-header"; + } + return ""; + } } }; -