feat:【IoT 物联网】初始化 IoT 固件详情页 60%
This commit is contained in:
@ -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 任务记录分页
|
||||
|
||||
@ -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: '固件详情',
|
||||
|
||||
@ -23,31 +23,37 @@
|
||||
|
||||
<!-- 固件升级设备统计 -->
|
||||
<ContentWrap title="固件升级设备统计" class="mb-20px">
|
||||
<el-row :gutter="20" class="py-20px" v-loading="statisticsLoading">
|
||||
<el-row :gutter="20" class="py-20px" v-loading="firmwareStatisticsLoading">
|
||||
<el-col :span="6">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-blue-500">{{ statistics.total || 0 }}</div>
|
||||
<div class="text-32px font-bold mb-8px text-blue-500">
|
||||
{{
|
||||
Object.values(firmwareStatistics).reduce((sum, count) => sum + (count || 0), 0) || 0
|
||||
}}
|
||||
</div>
|
||||
<div class="text-14px text-gray-600">升级设备总数</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-gray-400">
|
||||
{{ statistics.pending || 0 }}
|
||||
{{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.PENDING.value] || 0 }}
|
||||
</div>
|
||||
<div class="text-14px text-gray-600">待推送</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-blue-400">{{ statistics.pushed || 0 }}</div>
|
||||
<div class="text-32px font-bold mb-8px text-blue-400">{{
|
||||
firmwareStatistics[IoTOtaTaskRecordStatusEnum.PUSHED.value] || 0
|
||||
}}</div>
|
||||
<div class="text-14px text-gray-600">已推送</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-yellow-500">
|
||||
{{ statistics.inProgress || 0 }}
|
||||
{{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.UPGRADING.value] || 0 }}
|
||||
</div>
|
||||
<div class="text-14px text-gray-600">正在升级</div>
|
||||
</div>
|
||||
@ -55,21 +61,23 @@
|
||||
<el-col :span="3">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-green-500">
|
||||
{{ statistics.success || 0 }}
|
||||
{{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.SUCCESS.value] || 0 }}
|
||||
</div>
|
||||
<div class="text-14px text-gray-600">升级成功</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-red-500">{{ statistics.failed || 0 }}</div>
|
||||
<div class="text-32px font-bold mb-8px text-red-500">{{
|
||||
firmwareStatistics[IoTOtaTaskRecordStatusEnum.FAILURE.value] || 0
|
||||
}}</div>
|
||||
<div class="text-14px text-gray-600">升级失败</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<div class="text-center p-20px border border-solid border-gray-200 rounded bg-gray-50">
|
||||
<div class="text-32px font-bold mb-8px text-gray-400">
|
||||
{{ statistics.cancelled || 0 }}
|
||||
{{ firmwareStatistics[IoTOtaTaskRecordStatusEnum.CANCELED.value] || 0 }}
|
||||
</div>
|
||||
<div class="text-14px text-gray-600">升级取消</div>
|
||||
</div>
|
||||
@ -78,7 +86,7 @@
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 任务管理 -->
|
||||
<OtaTaskList ref="otaTaskListRef" :firmware-id="firmwareId" />
|
||||
<OtaTaskList :firmware-id="firmwareId" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -100,19 +108,8 @@ const firmwareLoading = ref(false)
|
||||
const firmware = ref<IoTOtaFirmware>({} 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<Record<string, number>>({})
|
||||
|
||||
/** 获取固件信息 */
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<ContentWrap title="任务管理" class="mb-20px">
|
||||
<ContentWrap title="固件任务管理" class="mb-20px">
|
||||
<!-- 搜索栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
@ -59,7 +59,7 @@
|
||||
<el-table-column label="操作" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.status === IoTOtaTaskStatusEnum.PENDING.value"
|
||||
v-if="scope.row.status === IoTOtaTaskStatusEnum.IN_PROGRESS.value"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleCancelTask(scope.row.id)"
|
||||
|
||||
@ -162,25 +162,17 @@ export const IoTOtaTaskDeviceScopeEnum = {
|
||||
|
||||
// IoT OTA 任务状态枚举
|
||||
export const IoTOtaTaskStatusEnum = {
|
||||
PENDING: {
|
||||
label: '待执行',
|
||||
value: 1
|
||||
},
|
||||
IN_PROGRESS: {
|
||||
label: '执行中',
|
||||
value: 2
|
||||
label: '进行中',
|
||||
value: 10
|
||||
},
|
||||
COMPLETED: {
|
||||
label: '已完成',
|
||||
value: 3
|
||||
value: 20
|
||||
},
|
||||
CANCELLED: {
|
||||
CANCELED: {
|
||||
label: '已取消',
|
||||
value: 4
|
||||
},
|
||||
FAILED: {
|
||||
label: '执行失败',
|
||||
value: 5
|
||||
value: 30
|
||||
}
|
||||
} as const
|
||||
|
||||
@ -188,26 +180,26 @@ export const IoTOtaTaskStatusEnum = {
|
||||
export const IoTOtaTaskRecordStatusEnum = {
|
||||
PENDING: {
|
||||
label: '待推送',
|
||||
value: 1
|
||||
value: 0
|
||||
},
|
||||
PUSHED: {
|
||||
label: '已推送',
|
||||
value: 2
|
||||
value: 10
|
||||
},
|
||||
IN_PROGRESS: {
|
||||
label: '正在升级',
|
||||
value: 3
|
||||
UPGRADING: {
|
||||
label: '升级中',
|
||||
value: 20
|
||||
},
|
||||
SUCCESS: {
|
||||
label: '升级成功',
|
||||
value: 4
|
||||
value: 30
|
||||
},
|
||||
FAILED: {
|
||||
FAILURE: {
|
||||
label: '升级失败',
|
||||
value: 5
|
||||
value: 40
|
||||
},
|
||||
CANCELLED: {
|
||||
CANCELED: {
|
||||
label: '升级取消',
|
||||
value: 6
|
||||
value: 50
|
||||
}
|
||||
} as const
|
||||
|
||||
Reference in New Issue
Block a user