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 ""; + } } }; -