|
|
|
|
@ -965,12 +965,11 @@ const queryFormRef = ref() // 搜索的表单
|
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
|
|
|
|
|
|
type DeviceOperatingStatusKey = 'running' | 'standby' | 'fault' | 'alarm' | 'offline'
|
|
|
|
|
type DeviceStatisticKey = 'total' | DeviceOperatingStatusKey
|
|
|
|
|
type DeviceStatisticKey = 'total' | 'running' | 'standby' | 'alarm' | 'offline'
|
|
|
|
|
const deviceStatistics = reactive<Record<DeviceStatisticKey, number>>({
|
|
|
|
|
total: 0,
|
|
|
|
|
running: 0,
|
|
|
|
|
standby: 0,
|
|
|
|
|
fault: 0,
|
|
|
|
|
alarm: 0,
|
|
|
|
|
offline: 0
|
|
|
|
|
})
|
|
|
|
|
@ -978,8 +977,7 @@ const deviceStatisticsItems = computed(() => [
|
|
|
|
|
{ key: 'total', label: '总数', value: deviceStatistics.total },
|
|
|
|
|
{ key: 'running', label: '运行数', value: deviceStatistics.running },
|
|
|
|
|
{ key: 'standby', label: '待机数', value: deviceStatistics.standby },
|
|
|
|
|
{ key: 'fault', label: '报警数', value: deviceStatistics.fault },
|
|
|
|
|
/*{ key: 'alarm', label: '报警数', value: deviceStatistics.alarm },*/
|
|
|
|
|
{ key: 'alarm', label: '报警数', value: deviceStatistics.alarm },
|
|
|
|
|
{ key: 'offline', label: '离线数', value: deviceStatistics.offline }
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
@ -1008,35 +1006,24 @@ const operatingStatusTypeMap: Record<DeviceOperatingStatusKey, 'success' | 'info
|
|
|
|
|
offline: 'info'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const setDeviceStatistics = (rows: DeviceVO[] = []) => {
|
|
|
|
|
const nextStats: Record<DeviceStatisticKey, number> = {
|
|
|
|
|
total: rows.length,
|
|
|
|
|
running: 0,
|
|
|
|
|
standby: 0,
|
|
|
|
|
fault: 0,
|
|
|
|
|
alarm: 0,
|
|
|
|
|
offline: 0
|
|
|
|
|
}
|
|
|
|
|
rows.forEach((row) => {
|
|
|
|
|
const key = normalizeDeviceOperatingStatus(row.operatingStatus)
|
|
|
|
|
nextStats[key] += 1
|
|
|
|
|
})
|
|
|
|
|
Object.assign(deviceStatistics, nextStats)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getDeviceStatistics = async (totalCount = total.value) => {
|
|
|
|
|
const { pageNo, pageSize, ...params } = queryParams
|
|
|
|
|
const statisticsPageSize = Math.max(Number(totalCount) || 0, Number(pageSize) || 10, 1)
|
|
|
|
|
const getDeviceStatistics = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const data = await DeviceApi.getDevicePage({
|
|
|
|
|
...params,
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: statisticsPageSize
|
|
|
|
|
const data = await DeviceApi.getDeviceStatusStatistics()
|
|
|
|
|
Object.assign(deviceStatistics, {
|
|
|
|
|
total: Number(data?.totalCount ?? 0),
|
|
|
|
|
running: Number(data?.runningCount ?? 0),
|
|
|
|
|
standby: Number(data?.standbyCount ?? 0),
|
|
|
|
|
alarm: Number(data?.alarmCount ?? 0),
|
|
|
|
|
offline: Number(data?.offlineCount ?? 0)
|
|
|
|
|
})
|
|
|
|
|
const rows = Array.isArray(data) ? data : Array.isArray((data as any)?.list) ? (data as any).list : []
|
|
|
|
|
setDeviceStatistics(rows)
|
|
|
|
|
} catch {
|
|
|
|
|
setDeviceStatistics(list.value)
|
|
|
|
|
Object.assign(deviceStatistics, {
|
|
|
|
|
total: 0,
|
|
|
|
|
running: 0,
|
|
|
|
|
standby: 0,
|
|
|
|
|
alarm: 0,
|
|
|
|
|
offline: 0
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1096,7 +1083,7 @@ const getList = async (showLoading = true) => {
|
|
|
|
|
const data = await DeviceApi.getDevicePage(queryParams)
|
|
|
|
|
list.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
await getDeviceStatistics(data.total)
|
|
|
|
|
await getDeviceStatistics()
|
|
|
|
|
} finally {
|
|
|
|
|
if (showLoading) {
|
|
|
|
|
loading.value = false
|
|
|
|
|
@ -1114,7 +1101,7 @@ const getListOne = async (showLoading = true) => {
|
|
|
|
|
const data = await DeviceApi.getDevicePage(queryParams)
|
|
|
|
|
list.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
await getDeviceStatistics(data.total)
|
|
|
|
|
await getDeviceStatistics()
|
|
|
|
|
} finally {
|
|
|
|
|
if (showLoading) {
|
|
|
|
|
loading.value = false
|
|
|
|
|
|