<template> <el-row class="panel-group"> <div v-for="card in dataGroup1" :key="card.index" class="card-panel-col"> <card1 :title="card.title" :context="card.context" :icon="card.icon" :color="card.color" :unit="card.unit"/> </div> <div v-for="card in dataGroup" :key="card.title" class="card-panel-col"> <div v-if="hasPerm(card.permission)"> <card :title="card.title" :context="card.context" :icon="card.icon" :unit="card.unit" :color="card.color" @click.native="goPage(card.path)"/> </div> </div> </el-row> </template> <script> import Card1 from '@/components/BigData/Card1' import Card from '@/components/BigData/Card' // 首页 import { getWatchStatistic, waterMeterCount, valveCount } from '@/api/dashboard' // 根据布防数量统计井数量 import { wellCountByBfzt } from '@/api/well' // 当前报警数 import { deviceStaticByStatus, alarmNowStatic } from '@/api/dataStatics' // 根据工单状态统计工单数量 import { jobCountByStatus } from '@/api/job' export default { components: { Card, Card1 }, data() { return { dataGroup1: [ { title: ['总用水量', '本月用水量'], context: ['--', '--'], icon: '', color: '#40c9c6', unit: '吨', index: 0 }, { title: ['今日用水量', '生产厂区用水量'], context: ['--', '--'], icon: '', color: '#36a3f7', unit: '吨', index: 1 }, { title: ['滑道实时噪声'], context: ['--'], icon: 'icon-noise', color: '#f1c353', unit: 'db', index: 2 } ], dataGroup: [ { title: '阀门数量', context: '--', icon: 'icon-valve', color: '#40c9c6', permission: '/device/list' }, { title: '水表数量', context: '--', icon: 'icon-watch', color: '#9694f7', path: '/deviceList?deviceType=13', permission: '/device/list' }, { title: '告警信息', context: '--', icon: 'icon-alarm', color: '#f4516c', path: '/alarmNow', permission: '/alarm/now' } ] } }, mounted() { this.getWater() // this.getWellCount() this.getDeviceCount() this.getAlarmCount() // this.getJobCount() }, methods: { refresh() { this.getAlarmCount() this.getJobCount() }, goPage(path) { this.$router.push(path) }, getWater() { // 用水量 getWatchStatistic().then(response => { this.dataGroup1[0].context = [response.data.total ? parseFloat(response.data.total).toFixed(2) : '--', response.data.month ? parseFloat(response.data.month).toFixed(2) : '--'] this.dataGroup1[1].context = [response.data.today ? parseFloat(response.data.today).toFixed(2) : '--', response.data.prodution ? parseFloat(response.data.prodution).toFixed(2) : '--'] this.dataGroup1[2].context = [response.data.sound ? Number(response.data.sound).toFixed(2) : '--'] }) }, // getWellCount() { // wellCountByBfzt().then(response => { // this.dataGroup[0].context = response.data.total // }) // }, getDeviceCount() { // deviceStaticByStatus().then(response => { // this.dataGroup[1].context = response.data.total // }) // 阀门数量 valveCount().then(response => { this.dataGroup[0].context = response.data }) // 水表数量 waterMeterCount().then(response => { this.dataGroup[1].context = response.data }) }, getAlarmCount() { alarmNowStatic().then(response => { this.dataGroup[2].context = response.data.total }) }, getJobCount() { jobCountByStatus().then(response => { const data = response.data const total = data.beforeGet + data.beforeConfirm + data.inHandle this.dataGroup[3].context = total }) } } } </script> <style lang="scss" scoped> .panel-group { margin-top: 5px; padding: 0px 0px; display: flex; justify-content: space-between; .card-panel-col { margin: 5px; margin-bottom: 18px; flex:1; } // .card-panel { // height: 108px; // cursor: pointer; // font-size: 10px; // position: relative; // overflow: hidden; // color: #666; // background: #fff; // box-shadow: 4px 4px 40px rgba(0, 0, 0, .05); // border-color: rgba(0, 0, 0, .05); // &:hover { // .card-panel-icon-wrapper { // color: #fff; // } // .icon-people { // background: #40c9c6; // } // .icon-message { // background: #36a3f7; // } // .icon-money { // background: #f4516c; // } // .icon-shopping { // background: #34bfa3 // } // } // // .icon-people { // // color: #40c9c6; // // } // // .icon-message { // // color: #36a3f7; // // } // // .icon-money { // // color: #f4516c; // // } // // .icon-shopping { // // color: #34bfa3 // // } // .card-panel-icon-wrapper { // float: left; // margin: 14px 0 0 14px; // padding: 16px; // transition: all 0.38s ease-out; // border-radius: 6px; // } // .card-panel-icon { // float: left; // font-size: 40px; // } // .card-panel-description { // font-weight: bold; // margin: 26px; // margin-left: 0px; // .card-panel-text { // line-height: 18px; // color: rgba(0, 0, 0, 0.45); // font-size: 14px; // margin-bottom: 12px; // } // .card-panel-num { // font-size: 18px; // } // } // } } @media (max-width:550px) { .card-panel-description { display: none; } .card-panel-icon-wrapper { float: none !important; width: 100%; height: 100%; margin: 0 !important; .svg-icon { display: block; margin: 14px auto !important; float: none !important; } } } </style>