emcp/frontend/src/views/aiQuantity/index.vue

216 lines
6.2 KiB
Vue
Raw Normal View History

2026-05-18 12:39:57 +08:00
<script setup lang="ts">
2026-05-18 18:31:31 +08:00
import { computed, onMounted, ref } from 'vue'
2026-05-18 12:39:57 +08:00
import { usePlatformStore } from '../../stores/platform'
2026-05-18 18:31:31 +08:00
import {fetchChannelConfig} from '@/api/platform'
2026-06-26 18:06:50 +08:00
import { formatAlarmEventValue, getAlarmBelongText, getEventDisplayName } from '@/utils/alarmEvent'
2026-05-18 12:39:57 +08:00
const { state, bootstrap } = usePlatformStore()
2026-05-18 18:31:31 +08:00
const channelConfig = ref<Record<number, { type: string; limit_low: number; limit_high: number; line_no: string }>>({})
2026-05-18 12:39:57 +08:00
const aiData = computed(() => {
2026-05-18 18:31:31 +08:00
const aiCollect = state.realtime?.ai_collect || {}
2026-05-18 12:39:57 +08:00
return Array.from({ length: 12 }, (_, i) => {
2026-05-18 18:31:31 +08:00
const ch = i + 1
const code = `ai${ch}`
const config = channelConfig.value[ch] || {}
2026-05-18 12:39:57 +08:00
return {
2026-05-18 18:31:31 +08:00
code,
line_no: config.line_no || '',
singal_type: '',
type: config.type || '',
limit_low: config.limit_low || 0,
limit_high: config.limit_high || 0,
rawValue: aiCollect[code] !== undefined ? aiCollect[code] : '',
ch
2026-05-18 12:39:57 +08:00
}
})
})
2026-05-18 18:31:31 +08:00
function formatTime(dateStr: string): string {
const date = new Date(dateStr)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}
2026-06-26 18:06:50 +08:00
2026-05-18 12:39:57 +08:00
const tableData = computed(() => {
2026-05-19 10:46:30 +08:00
const alarms = state.alarms || []
2026-06-29 09:34:00 +08:00
const firstThree = alarms.slice(0, 2)
2026-05-19 10:46:30 +08:00
return firstThree.map(list => {
2026-06-26 18:06:50 +08:00
return {
id: list.id || 0,
name: getAlarmBelongText(list.line_code),
typeName: getEventDisplayName(list.event_type, list.event_code),
eventCode: list.event_code,
eventValue: formatAlarmEventValue(list.event_type, list.event_value),
content: list.content,
time: list.event_time ? formatTime(list.event_time) : '',
2026-05-19 10:46:30 +08:00
}
})
2026-05-18 12:39:57 +08:00
})
2026-05-18 18:31:31 +08:00
function init(){
fetchChannelConfig().then(res => {
const list = res.ai_channel || []
list.forEach((item: any) => {
channelConfig.value[item.ch] = {
type: item.type,
limit_low: item.limit_low,
limit_high: item.limit_high,
line_no: item.line_no
}
})
})
}
2026-05-18 12:39:57 +08:00
onMounted(() => {
2026-05-18 18:31:31 +08:00
init()
2026-05-18 12:39:57 +08:00
void bootstrap()
})
</script>
<template>
<div class="ai-container">
<div class="ai-container-top">
2026-05-26 15:11:03 +08:00
<!-- <div class="top-title">AI采集信息</div> -->
2026-05-18 12:39:57 +08:00
<div class="container-top-box">
<!-- 表格表头 -->
<div class="table-header">
<div class="header-cell" style="width: 90px;max-width: 90px;min-width: 90px;">通道号</div>
<div class="header-cell">原始值</div>
<div class="header-cell">所属路线</div>
<div class="header-cell">类别</div>
<div class="header-cell">低值</div>
2026-05-18 18:31:31 +08:00
<div class="header-cell">高值</div>
2026-05-18 12:39:57 +08:00
</div>
<!-- 表格内容 -->
<div class="table-body">
<div v-for="(item, index) in aiData" :key="index" class="table-row">
2026-05-18 18:31:31 +08:00
<div class="cell" style="width: 90px;max-width: 90px;min-width: 90px;color: #787878;">{{ item.ch }}
</div>
2026-05-18 12:39:57 +08:00
<div class="cell">{{ item.rawValue }}</div>
2026-05-18 18:31:31 +08:00
<div class="cell">线路{{ item.line_no }}</div>
<div class="cell">{{ item.type }}</div>
<div class="cell">{{ item.limit_low }}</div>
<div class="cell">{{ item.limit_high }}</div>
2026-05-18 12:39:57 +08:00
</div>
</div>
</div>
</div>
2026-06-29 09:34:00 +08:00
<div class="ai-container-bottom">
2026-05-18 12:39:57 +08:00
<div class="top-title">报警信息</div>
<div class="container-bottom-box">
<div v-for="(item, index) in tableData" :key="index" class="container-bottom-box-line1">
2026-05-19 09:19:51 +08:00
<div style="width: 8%;text-align: center;">{{ index + 1 }}</div>
<div style="width: 14%;text-align: center;">{{ item.name }}</div>
<div style="width: 20%;text-align: center;">{{ item.typeName }}</div>
2026-06-26 18:06:50 +08:00
<div style="width: 8%;text-align: center;">{{ item.eventValue }}</div>
2026-05-19 09:19:51 +08:00
<div style="width: 30%;text-align: center;">{{ item.content }}</div>
<div style="width: 20%;text-align: center;">{{ item.time }}</div>
2026-05-18 12:39:57 +08:00
</div>
</div>
2026-06-29 09:34:00 +08:00
</div>
2026-05-18 12:39:57 +08:00
</div>
</template>
<style scoped lang="scss">
.ai-container {
width: 100%;
height: 100%;
2026-06-29 09:34:00 +08:00
padding: 10px;
2026-05-18 12:39:57 +08:00
.top-title {
font-weight: 700;
font-style: normal;
font-size: 16px;
color: #363636;
2026-06-29 09:34:00 +08:00
margin-bottom: 4px;
2026-05-18 12:39:57 +08:00
}
.ai-container-top {
width: 100%;
2026-06-29 09:34:00 +08:00
margin-bottom: 4px;
2026-05-18 12:39:57 +08:00
.container-top-box {
width: 100%;
2026-06-29 09:34:00 +08:00
height: 404px;
padding: 8px 10px;
2026-05-18 12:39:57 +08:00
background: #ffffff;
box-shadow: 0px 0px 10px rgba(219, 225, 236, 1);
border-radius: 4px;
display: flex;
flex-direction: column;
.table-header {
display: flex;
width: 100%;
margin-bottom: 5px;
gap: 5px;
.header-cell {
flex: 1;
2026-06-29 09:34:00 +08:00
height: 25px;
line-height: 25px;
2026-05-18 12:39:57 +08:00
background-color: #f8f9fc;
border: 1px solid #e8e8e8;
border-radius: 4px;
text-align: center;
font-size: 14px;
color: #787878;
}
}
.table-body {
display: flex;
flex-direction: column;
gap: 5px;
2026-05-18 18:31:31 +08:00
2026-05-18 12:39:57 +08:00
.table-row {
display: flex;
width: 100%;
gap: 5px;
.cell {
flex: 1;
2026-06-29 09:34:00 +08:00
height: 25px;
line-height: 25px;
2026-05-18 12:39:57 +08:00
border: 1px solid #e8e8e8;
border-radius: 4px;
text-align: center;
font-size: 14px;
color: #363636;
}
}
}
}
}
.ai-container-bottom {
width: 100%;
.container-bottom-box {
width: 100%;
2026-06-29 09:34:00 +08:00
height: 66px;
padding: 0px;
2026-05-18 12:39:57 +08:00
background: #ffffff;
box-shadow: 0px 0px 10px rgba(219, 225, 236, 1);
border-radius: 4px;
.container-bottom-box-line1 {
display: flex;
align-items: center;
color: #787878;
2026-06-29 09:34:00 +08:00
height: 33px;
2026-05-18 12:39:57 +08:00
font-size: 14px;
color: #505050;
border-bottom: 1px solid #f2f2f2;
&:last-child {
border-bottom: none;
}
}
}
}
}
2026-06-26 18:06:50 +08:00
</style>