Newer
Older
qd_cnooc_front / src / views / gasDashboard / components / PanelGroup.vue
Stephanie on 6 Dec 2022 3 KB fix<views>: 修改单位
<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 { gasStatistic, deviceCount, alarmNowStatic } from '@/api/gasOverview'
import { gasStatistic2 } from '../../../api/gasOverview'
export default {
  components: {
    Card,
    Card1
  },
  data() {
    return {
      dataGroup1: [
        {
          title: ['CO₂总用气量', 'CO₂本月用气量', 'CO₂今日用气量'],
          context: ['--', '--', '--'],
          icon: '',
          color: '#40c9c6',
          unit: 'm³',
          index: 0
        },
        {
          title: ['O₂总用气量', 'O₂本月用气量', 'O₂今日用气量'],
          context: ['--', '--', '--'],
          icon: '',
          color: '#36a3f7',
          unit: 'm³',
          index: 1
        },
        {
          title: ['燃气总用气量', '燃气本月用气量', '燃气今日用气量'],
          context: ['--', '--', '--'],
          icon: '',
          color: '#36a3f7',
          unit: 'm³',
          index: 2
        },
        {
          title: ['滑道实时噪声'],
          context: ['--'],
          icon: 'icon-noise',
          color: '#f1c353',
          unit: 'db',
          index: 3
        }
      ],
      dataGroup: [
        {
          title: '告警信息',
          context: '--',
          icon: 'icon-alarm',
          color: '#f4516c',
          path: '/alarmNow',
          permission: '/alarm/now'
        }
      ]
    }
  },
  mounted() {
    this.getWater()
    // this.getWellCount()
    // this.getDeviceCount()
    this.getAlarmCount()
  },
  methods: {
    goPage(path) {
      this.$router.push(path)
    },
    getWater() {
      // 用气量
      gasStatistic().then(response => {
        this.dataGroup1[3].context = [response.data.sound ? Number(response.data.sound).toFixed(2) : '--']
      })
      gasStatistic2('15').then(response => {
        this.dataGroup1[0].context = [response.data.total.toFixed(2), response.data.month.toFixed(2), response.data.day === '' ? '--' : response.data.day.toFixed(2)]
      })
      gasStatistic2('16').then(response => {
        this.dataGroup1[1].context = [response.data.total.toFixed(2), response.data.month.toFixed(2), response.data.day === '' ? '--' : response.data.day.toFixed(2)]
      })
      gasStatistic2('17').then(response => {
        this.dataGroup1[2].context = [response.data.total.toFixed(2), response.data.month.toFixed(2), response.data.day === '' ? '--' : response.data.day.toFixed(2)]
      })
    },
    getAlarmCount() {
      alarmNowStatic().then(response => {
        this.dataGroup[0].context = response.data.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;
}
@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>