diff --git a/src/api/iot/ota/task/record/index.ts b/src/api/iot/ota/task/record/index.ts index 220bda9b..4ae38373 100644 --- a/src/api/iot/ota/task/record/index.ts +++ b/src/api/iot/ota/task/record/index.ts @@ -16,12 +16,11 @@ export interface OtaTaskRecord { // IoT OTA 任务记录 API export const IoTOtaTaskRecordApi = { - // 获取 OTA 升级记录状态统计 - getOtaTaskRecordStatusCount: async (firmwareId?: number, taskId?: number) => { + getOtaTaskRecordStatusStatistics: async (firmwareId?: number, taskId?: number) => { const params: any = {} if (firmwareId) params.firmwareId = firmwareId if (taskId) params.taskId = taskId - return await request.get({ url: `/iot/ota/task/record/get-status-count`, params }) + return await request.get({ url: `/iot/ota/task/record/get-status-statistics`, params }) }, // 查询 OTA 任务记录分页 diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 9c1246af..794778ca 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -735,7 +735,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ component: () => import('@/views/iot/device/device/detail/index.vue') }, { - path: 'ota/firmware/detail/:id', + path: 'ota/operation/firmware/detail/:id', name: 'IoTOtaFirmwareDetail', meta: { title: '固件详情', diff --git a/src/views/iot/ota/firmware/detail/index.vue b/src/views/iot/ota/firmware/detail/index.vue index 0c0cc9d3..23c613b2 100644 --- a/src/views/iot/ota/firmware/detail/index.vue +++ b/src/views/iot/ota/firmware/detail/index.vue @@ -23,31 +23,37 @@ - + - {{ statistics.total || 0 }} + + {{ + Object.values(firmwareStatistics).reduce((sum, count) => sum + (count || 0), 0) || 0 + }} + 升级设备总数 - {{ statistics.pending || 0 }} + {{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.PENDING.value] || 0 }} 待推送 - {{ statistics.pushed || 0 }} + {{ + firmwareStatistics[IoTOtaTaskRecordStatusEnum.PUSHED.value] || 0 + }} 已推送 - {{ statistics.inProgress || 0 }} + {{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.UPGRADING.value] || 0 }} 正在升级 @@ -55,21 +61,23 @@ - {{ statistics.success || 0 }} + {{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.SUCCESS.value] || 0 }} 升级成功 - {{ statistics.failed || 0 }} + {{ + firmwareStatistics[IoTOtaTaskRecordStatusEnum.FAILURE.value] || 0 + }} 升级失败 - {{ statistics.cancelled || 0 }} + {{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.CANCELED.value] || 0 }} 升级取消 @@ -78,7 +86,7 @@ - + @@ -100,19 +108,8 @@ const firmwareLoading = ref(false) const firmware = ref({} as IoTOtaFirmware) // 统计信息 -const statisticsLoading = ref(false) -const statistics = ref({ - total: 0, - pending: 0, - pushed: 0, - inProgress: 0, - success: 0, - failed: 0, - cancelled: 0 -}) - -// 任务列表组件引用 -const otaTaskListRef = ref() +const firmwareStatisticsLoading = ref(false) +const firmwareStatistics = ref>({}) /** 获取固件信息 */ const getFirmwareInfo = async () => { @@ -126,28 +123,13 @@ const getFirmwareInfo = async () => { /** 获取升级统计 */ const getStatistics = async () => { - statisticsLoading.value = true + firmwareStatisticsLoading.value = true try { - const data = await IoTOtaTaskRecordApi.getOtaTaskRecordStatusCount(firmwareId.value) - statistics.value = { - pending: data[IoTOtaTaskRecordStatusEnum.PENDING.value] || 0, - pushed: data[IoTOtaTaskRecordStatusEnum.PUSHED.value] || 0, - inProgress: data[IoTOtaTaskRecordStatusEnum.IN_PROGRESS.value] || 0, - success: data[IoTOtaTaskRecordStatusEnum.SUCCESS.value] || 0, - failed: data[IoTOtaTaskRecordStatusEnum.FAILED.value] || 0, - cancelled: data[IoTOtaTaskRecordStatusEnum.CANCELLED.value] || 0, - total: 0 - } - // 计算总数 - statistics.value.total = - statistics.value.pending + - statistics.value.pushed + - statistics.value.inProgress + - statistics.value.success + - statistics.value.failed + - statistics.value.cancelled + firmwareStatistics.value = await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics( + firmwareId.value + ) } finally { - statisticsLoading.value = false + firmwareStatisticsLoading.value = false } } diff --git a/src/views/iot/ota/task/OtaTaskList.vue b/src/views/iot/ota/task/OtaTaskList.vue index cdc1ad7c..448e3eb9 100644 --- a/src/views/iot/ota/task/OtaTaskList.vue +++ b/src/views/iot/ota/task/OtaTaskList.vue @@ -1,5 +1,5 @@ - +