<template>
  <div id="mapDeviceMenu">
    <div class="device" v-if="item.value>0" v-for="(item,index) in smartDeviceData" @click="handleClick(item,index)">
      <div :class="isActive==index?'itemActive item':'itemDefault item'" >
      </div>
      {{item.name}}
    </div>
  </div>
</template>

<script>
  export default {
    data(){
      return{
        isActive:0
      }
    },
    props:['smartDeviceData'],
    methods:{
      handleClick(item,index){
        this.isActive = index;
        this.$emit("reqDeviceCount",item.deviceType)
      }
    }
  }
</script>

<style lang="less" scoped="scoped">
  #mapDeviceMenu{
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    overflow-y: scroll;
    .device{
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    .item{
      width: .8rem;
      height: .8rem;
      margin: 5px;
      line-height: .8rem;
      text-align: center;
      cursor: pointer;
      transition: all .3s linear;
      font-size: .15rem;
    }
    .item:hover{
      .itemActive
    }
    .itemDefault{
      background: url(../assets/menuIcon.png) no-repeat;
      background-size: cover;
    }
    .itemActive{
      background: url(../assets/menuIconActive.png) no-repeat;
      background-size: cover;
    }
  }
</style>
