| | |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="200" fixed="right"> |
| | | <el-table-column label="操作" width="280" fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | v-if="scope.row.isOnline" |
| | |
| | | :loading="scope.row.statusUpdating" |
| | | > |
| | | 设为在线 |
| | | </el-button> |
| | | <el-button |
| | | type="danger" |
| | | size="small" |
| | | @click="removeSingleDevice(scope.row)" |
| | | > |
| | | 移除设备 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | } |
| | | } |
| | | |
| | | // 移除单个设备 |
| | | const removeSingleDevice = async (device) => { |
| | | try { |
| | | await ElMessageBox.confirm( |
| | | `确定要从设备组中移除设备"${device.deviceName || device.deviceCode}"吗?`, |
| | | '移除设备确认', |
| | | { |
| | | confirmButtonText: '确定移除', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | } |
| | | ) |
| | | |
| | | const deviceId = device.id || device.deviceId |
| | | await deviceGroupApi.batchRemoveDevicesFromGroup({ |
| | | groupId: currentGroup.value.id || currentGroup.value.groupId, |
| | | deviceIds: [deviceId] |
| | | }) |
| | | ElMessage.success('设备移除成功') |
| | | const groupId = currentGroup.value.id || currentGroup.value.groupId |
| | | await loadGroupDevices(groupId) |
| | | await loadAvailableDevices() |
| | | emit('refresh-statistics') |
| | | } catch (error) { |
| | | if (error !== 'cancel') { |
| | | console.error('移除设备失败:', error) |
| | | ElMessage.error('移除设备失败: ' + (error.response?.data?.message || error.message)) |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 更新设备在线状态 |
| | | const updateDeviceOnlineStatus = async (device, status) => { |
| | | try { |
| | |
| | | } |
| | | |
| | | await deviceStatusApi.updateDeviceOnlineStatus({ |
| | | deviceId: deviceId, |
| | | id: deviceId, |
| | | status: status |
| | | }) |
| | | |