| | |
| | | CollectorOnlineStatus, |
| | | CollectorStatus, |
| | | CollectorTestStatus, |
| | | CollectorPayload, |
| | | DeviceCollectorRecord, |
| | | } from '@/stores/deviceCollectors' |
| | | import { request, type ApiResponse } from './request' |
| | |
| | | data: CollectorDto |
| | | } |
| | | |
| | | interface DiscoveredCollectorDto { |
| | | deviceCode: string |
| | | ip: string |
| | | mac: string |
| | | name: string |
| | | manufacturer: string |
| | | model: string |
| | | channelCount: number |
| | | onlineStatus: CollectorOnlineStatus |
| | | testStatus: CollectorTestStatus |
| | | currentTest: string |
| | | } |
| | | |
| | | interface DiscoveredCollectorListResponse extends ApiResponse { |
| | | total: number |
| | | rows: DiscoveredCollectorDto[] |
| | | } |
| | | |
| | | export interface DeviceCollectorInput { |
| | | deviceCode: string |
| | | ip: string |
| | |
| | | export interface DeviceCollectorListResult { |
| | | total: number |
| | | rows: DeviceCollectorRecord[] |
| | | } |
| | | |
| | | export interface DiscoveredCollectorListResult { |
| | | total: number |
| | | rows: CollectorPayload[] |
| | | } |
| | | |
| | | const onlineStatusMap: Record<string, CollectorOnlineStatus> = { '0': '离线', '1': '在线' } |
| | |
| | | return mapCollector(result.data) |
| | | } |
| | | |
| | | export async function getDiscoveredCollectorList(pageNum: number, pageSize: number): Promise<DiscoveredCollectorListResult> { |
| | | const result = await request<DiscoveredCollectorListResponse>( |
| | | `/system/collector/discovered/list?pageNum=${pageNum}&pageSize=${pageSize}`, |
| | | ) |
| | | return { |
| | | total: Number(result.total) || 0, |
| | | rows: (result.rows || []).map(item => ({ |
| | | deviceCode: item.deviceCode, |
| | | ip: item.ip, |
| | | mac: item.mac, |
| | | name: item.name || '', |
| | | manufacturer: item.manufacturer || '', |
| | | model: item.model || '', |
| | | channelCount: item.channelCount || 1, |
| | | onlineStatus: item.onlineStatus || '离线', |
| | | testStatus: item.testStatus || '空闲', |
| | | currentTest: item.currentTest || '-', |
| | | status: '启用', |
| | | remark: '', |
| | | })), |
| | | } |
| | | } |
| | | |
| | | export function createDeviceCollector(input: DeviceCollectorInput): Promise<ApiResponse> { |
| | | return request<ApiResponse>('/system/collector', { |
| | | method: 'POST', |