<!-- Description: 事件大屏 - 数据展示- 累计报警统计 Author: 李亚光 Date: 2024-09-18 --> <script lang="ts" setup name="FullScreenAccumulatedAlarmStatistics"> import layout from './layout.vue' import { alarmTotalStatistics } from '@/api/home/dashboard/fullScreen' import useUserStore from '@/store/modules/user' const userStore = useUserStore() // 宽高 const height = ref((window.innerHeight - 100 - 50) / 3 + 20) const width = ref((window.innerWidth - (window.innerWidth * 0.6) - 30) / 2) window.addEventListener('resize', () => { height.value = (window.innerHeight - 100 - 50 + 20) / 3 width.value = (window.innerWidth - (window.innerWidth * 0.6) - 30) / 2 }) onBeforeUnmount(() => { window.addEventListener('resize', () => { }) }) const listQuery = ref({ timeType: '2', }) const selectTimeType = (type: string) => { listQuery.value.timeType = type } const data = ref<any[]>([]) const xAxisData = ref<any[]>([]) const loading = ref(false) const fetchData = () => { loading.value = true alarmTotalStatistics(listQuery.value).then(res => { // console.log(res.data, '累计报警统计') data.value = [] xAxisData.value = [] if (!userStore.roleTips.join().includes('admin')) { res.data.forEach((element: any) => { xAxisData.value.push(element.dept) data.value.push(element.alarmTotal) }); } else { // console.log(res.data, '累计报警统计') const deptList = [ '高压管网', '第一分公司', '第二分公司', '第三分公司', '第四分公司', '第五分公司', '怀柔有限公司', '密云有限公司', '平谷有限公司', '延庆有限公司', '昌平有限公司', '房山有限公司', ] // 过滤 const needShow = res.data.filter((item: any) => deptList.filter(citem => item.dept.includes(citem)).length) // 排序 const arr = [] as any[] deptList.forEach((item: string) => { const data = needShow.filter((citem: any) => citem.dept.includes(item)) if (data.length) { arr.push(data[0]) } }) // console.log(arr, '结果') arr.forEach((element: any) => { xAxisData.value.push(element.dept) data.value.push(element.alarmTotal) }); } loading.value = false }) } watch(() => listQuery.value.timeType, (newVal) => { if (newVal) { fetchData() } }) onMounted(() => { fetchData() }) </script> <template> <layout class="layout" :height="height" :width="width" title="累计报警统计" subtitle="Accumulated Alarm Statistics"> <template #content> <div class="container" v-loading="loading"> <!-- 筛选条件 --> <div class="search"> <el-button :class="listQuery.timeType === '2' ? 'active' : ''" round size="small" style="margin: 0 5px;" @click="selectTimeType('2')"> 近7日 </el-button> <el-button :class="listQuery.timeType === '3' ? 'active' : ''" round size="small" style="margin: 0 5px;" @click="selectTimeType('3')"> 本月 </el-button> <el-button :class="listQuery.timeType === '4' ? 'active' : ''" round size="small" style="margin: 0 5px;" @click="selectTimeType('4')"> 本年 </el-button> </div> <bar-chart3-d :x-axis-data="xAxisData" :data="data" :style="{ width: '100%', height: `${height - 30}px` }" /> </div> </template> </layout> </template> <style lang="scss" scoped> ::v-deep(.el-loading-mask) { background-color: rgba($color: #0b0b0f, $alpha: 95%); } ::v-deep(.el-button) { background-color: rgba($color: #103f60, $alpha: 80%); border-color: #856b6b; color: #fff; } .container { position: relative; .search { position: absolute; top: 5px; left: 10px; z-index: 10; } } // .layout { // ::v-deep(.title) { // padding-left: 8px !important; // color: #fff; // font-weight: 700; // // padding-left: 20px; // box-sizing: border-box; // } // // overflow: hidden; // } .active { color: #1c3444; border-color: #777f8d; outline: none; font-weight: 700; background-color: rgba($color: #758292, $alpha: 100%); } </style>