<template> <!-- 历史告警 --> <div class="syntherticData app-container"> <!-- 头部 --> <div class="synHead"> <div :class="['part', checkedKey == item.key ? 'changed' : '']" v-for="item in headArr" :key="item.key" @click="changeHeadData(item.key)" > <img :src="getImgMonitorIcon(item.imgUrl)" :alt="item.name" /> <p>{{ item.name }}</p> <p class="value">{{ dataAarray[item.key] ? dataAarray[item.key] : dataAarray[item.keys] ? dataAarray[item.keys] : 0 }}</p> </div> </div> <div class="content"> <div class="synRight"> <reportService :checkedKey="checkedKey"></reportService> </div> </div> </div> </template> <script setup name="syntherticData"> import bus from '@/bus'; import { rtuWarnRecordHistory } from '@/api/dataAnalysis/repairdata'; import { getImgMonitorIcon } from '@/utils/validate'; import reportService from './reportService.vue'; const { proxy } = getCurrentInstance(); // 变量声明 const headArr = [ { name: '全部', value: '(合计97处)', imgUrl: 'all_icon.png', key: '', keys: 'all' }, { name: '水位告警', value: '(4)', imgUrl: 'river_icon.png', key: 'water_level' }, { name: '降雨告警', value: '(4)', imgUrl: 'lake_icon.png', key: 'rain' }, { name: '流量告警', value: '(97处)', imgUrl: 'gqjc_icon.png', key: 'flow' }, { name: '水质告警', value: '(合计7处)', imgUrl: 'line_icon.png', key: 'quality' }, { name: '其他告警', value: '(合计197处)', imgUrl: 'land_icon.png', key: 'other' }, ]; const checkedKey = ref('1'); // 方法 function changeHeadData(warnType) { checkedKey.value = warnType; } const dataAarray = ref({}); const rtuWarnType = async () => { let { data } = await rtuWarnRecordHistory(); var contall = 0; data.forEach(i => { dataAarray.value[i.warnType] = i.count; contall += i.count; }); dataAarray.value.all = contall; }; // 初始化 onMounted(() => { rtuWarnType(); changeHeadData(''); //默认显示全部 }); </script> <style lang="scss" scoped> .syntherticData { width: 100%; height: calc(100vh - 84px); background: #f5f7fe; position: relative; .synHead { width: 100%; height: 70px; background: #fff; display: flex; align-items: center; justify-content: space-around; .part { line-height: 25px; display: flex; align-items: center; cursor: pointer; height: 40px; padding: 5px 8px; img { margin-right: 6px; } .value { color: #3782ff; margin-left: 5px; } &:hover { background: #e4eeff; } } .changed { background: #e4eeff; border: 1px solid #3782ff; border-radius: 2px; animation-duration: 1s; } } .content { display: flex; height: 93%; background: #ffffff; box-shadow: 0px 2px 6px 0px rgba(28, 52, 92, 0.1); border-radius: 6px; margin-top: 10px; .synRight { width: 100%; } } } </style>