<template>
  <Card title="设备监控">
    <div class="devices">
      <div class="">
        <div class="flex  between devList">
          <div v-for="(item, index) in devList" :key="index" @click="selectDev(item.val,index)"  class="devItem">
            <span :class="selectDevVal==item.val?'that_class':''" >
              {{ item.tit }}
            </span>
          </div>

        </div>
      </div>

      <vue-scroll style="height:calc(100% - 52px)">
         <!-- 摄像 -->
         <videoItemList :list="viewlist" v-if="(devindex==0)"></videoItemList>
        <!-- ai设备 -->
        <aiDev v-if="devindex==2" :list="viewlist"></aiDev>
        <!-- 电箱 -->
        <electrical :list="viewlist" v-if="(devindex==3)"></electrical>
        <!-- 绿色设备 -->
        <environmentDevList :list="viewlist" v-if="(devindex==4)"></environmentDevList>
        <!-- 升降机 -->
        <lifterList :list="viewlist" v-if="(devindex==5)"></lifterList>
        <!-- 塔吊 -->
        <towerList :list="viewlist" v-if="(devindex==6)"></towerList>
       
        <!-- <div class="device" v-for="i in 5" :key="i">
          <div class="device-name">空压机{{ i }}</div>
          <div class="info">
            <img class="image" src="../assets/images/common/bg_kyj.png" />
            <div class="detail">
              <div class="detail-item green">状态：进行中</div>
              <div class="detail-item grey">电压：10000V</div>
              <div class="detail-item orange">电流：100A</div>
              <div class="detail-item">线缆温度：120℃</div>
              <div class="detail-item">环境温度：53℃</div>
              <div class="detail-item">漏电流：99A</div>
            </div>
          </div>
        </div> -->
      </vue-scroll>
    </div>
  </Card>
</template>

<script>
import { getAllDevApi } from '@/assets/js/api/zhongjianFourth';
import { mapState } from 'vuex';
import aiDev from './rightTopComponents/aiDevList.vue'
import electrical from './rightTopComponents/electrical.vue'
import environmentDevList from './rightTopComponents/environmentDevList.vue'
import lifterList from './rightTopComponents/lifterList.vue'
import towerList from './rightTopComponents/towerList.vue'
import videoItemList from './rightTopComponents/videoItemList.vue'
import Card from '../components/Card.vue';
export default {
  components: { Card,aiDev,electrical,environmentDevList,lifterList,towerList,videoItemList},
  data() {
    return {
      viewlist:[],
      devList: [
        {
          tit: '摄像头',
          val: 1,
          key:'videoItemList'
        },
        {
          tit: 'AI设备',
          val: 2,
          key:'aiList'
        },
        {
          tit: '车辆',
          val: 3,
          key:'carList'
        },
        {
          tit: '电箱',
          val: 4,
          key:'electricalDevList',
        },
        {
          tit: '绿色设备',
          val: 5,
          key:'environmentDevList',
        },
        {
          tit: '升降机',
          val: 6,
          key:'lifterList'
        },
        {
          tit: '塔吊',
          val: 7,
          key:'towerList'
        },
       
      ],
      selectDevVal:1,
      devindex:0,
      allDevlist:[]
    }
  },

  computed: {
    ...mapState(['projectSn']),
  },
  created() {
  this.getAllDev();
  },
  methods: {
    selectDev(v,i) {
      this.selectDevVal = v;
      this.devindex=i;
      let key=this.devList[i].key;
      this.viewlist=this.allDevlist[key]

    },
    getAllDev() {
      getAllDevApi({ projectSn: this.projectSn }).then(res => {
        console.log(res, 'getAllDevApi===========')
        this.allDevlist=res.result
      
        let key=this.devList[0].key;
      this.viewlist=this.allDevlist[key];
     

      })
    }
  },
}
</script>

<style lang="less" scoped>
.that_class{
  color: #6EE5F0!important;
}
.devList {

  width: 100%;
  font-size: 14px;
  height: 40px;

  .devItem {
    cursor: pointer;
  }
}

.flex {
  display: flex;
  align-items: center;
}

.between {
  justify-content: space-between;
}

.start {
  justify-content: flex-start;
}

.wrap {
  flex-wrap: wrap;
}

.devices {
  padding-left: 20px;
  height: 100%;
  color: #fff;

  .device {
    width: 100%;
    height: 176px;

    .device-name {
      // margin-top: 20px;
      height: 40px;
      line-height: 40px;
      font-size: 12px;
    }

    .info {
      height: 22px;
      line-height: 22px;
      font-size: 12px;
      color: #68d8e4;
      display: flex;

      .image {
        margin-right: 20px;
        width: 170px;
        height: 140px;
      }
    }
  }

  .green {
    color: #46d7b6;
  }

  .grey {
    color: #9da1aa;
  }

  .orange {
    color: #e7622a;
  }
}
</style>
