Newer
Older
CloudBrainNew / src / views / cityConstruction / components / iot / components / deviceOnline.vue
<!--
 * @Description: 设备在线情况
 * @Author: 王晓颖
 * @Date: 2020-12-01 09:58:49
 -->
<template>
  <single-layout title="设备运行情况">
    <div class="device-online-container" v-if="isShow">
      <div class="block" v-for="(value,index) in data" :key="index">
        <AnnularComp :value="value"/>
      </div>
    </div>
  </single-layout>
</template>

<script>
import {fetchDeviceState} from '@/api/cityManage'
import AnnularComp from '../../../../../components/annularProgress/annularComp.vue'
import SingleLayout from '@/components/layout/singleLayout'
import mockData from '../../../../../../static/plan.json'
export default {
  name: 'deviceOnline',
  components: {SingleLayout, AnnularComp},
  data () {
    return {
      isShow: false,
      data: [
        {
          'name': '井盖状态监测仪',
          'total': 0,
          'online': 0,
          'color': ['#39edfb', '#19ddff']
        },
        {
          'name': '液位监测仪',
          'total': 0,
          'online': 0,
          'color': ['#fc5e5f', '#f90006']
        },
        {
          'name': '燃气智能终端',
          'total': 0,
          'online': 0,
          'color': ['#39edfb', '#19ddff']
        },
        {
          'name': '有害气体监测仪',
          'total': 0,
          'online': 0,
          'color': ['#39edfb', '#19ddff']
        },
        {
          'name': '噪声记录仪',
          'total': 0,
          'online': 0,
          'color': ['#fc5e5f', '#f90006']
        },
        {
          'name': '摄像头',
          'total': 0,
          'online': 0,
          'color': ['#39edfb', '#19ddff']
        },
        {
          'name': '路灯控制器',
          'total': 0,
          'online': 0,
          'color': ['#39edfb', '#19ddff']
        }
      ]
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    getData () {
      this.data = mockData.ioT.equipmentOperationStatus
      // fetchDeviceState().then(response => {
      //   if (response.code === 200) {
      //     this.data = []
      //     var data = response.data
      //     var item
      //     for (let i = 0; i < 8; i++) {
      //       if (i % 2 === 0) {
      //         item = {
      //           name: data[i].type,
      //           total: Number(data[i].value),
      //           online: Number(data[i].online),
      //           color: ['#fc5e5f', '#f90006']
      //         }
      //       } else if (i % 2 === 1) {
      //         item = {
      //           name: data[i].type,
      //           total: Number(data[i].value),
      //           online: Number(data[i].online),
      //           color: ['#39edfb', '#19ddff']
      //         }
      //       }
      //       this.data.push(item)
      //     }
      this.isShow = true
      //   }
      // })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .device-online-container{
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    overflow: hidden;
    .block{
      width: 25%;
      height: 45%;
    }
  }
</style>