<template>
  <div id="perspective-analysis">
    <ul class="screen-list">
      <li v-for="item in perspectiveList" :key="item.id" :title="item.name" @click="selectTool(item)">
        <img :src="imgSrc(item)" class="screen-img" />
      </li>
    </ul>
  </div>
</template>

<script>
import {setWatchLineAny, ViewshedArea} from "@/units/map/AddLayer";

export default {
  name: "PerspectiveAnalysis",
  data(){
    return{
      perspectiveList:[
        {
          id:'0001',
          name:'视线分析',
          chosen:false,
        },
        {
          id:'0002',
          name:'可视域',
          chosen:false,
        },
      ],
    }
  },
  methods:{
    imgSrc(item){
      if(item.chosen){
        return require('../../../../../assets/imgs/mainPage/'+item.name+'-选中.png')
      }else{
        return require('../../../../../assets/imgs/mainPage/'+item.name+'-未选中.png')
      }
    },
    selectTool(item){
      setWatchLineAny('line',false);
      ViewshedArea(false)
      for(let i=0;i<this.perspectiveList.length;i++){
        if(item.name ==this.perspectiveList[i].name) {
          this.perspectiveList[i].chosen = !this.perspectiveList[i].chosen;
          if(this.perspectiveList[i].chosen){
            switch (this.perspectiveList[i].name){
              case "视线分析":
                setWatchLineAny('line',true)
                this.$emit('setToolDetailType','')
                break;
              case "可视域":
                this.$emit('setToolDetailType','perspectiveWatchArea')
                break;
            }
          }else{
            switch (this.perspectiveList[i].name){
              case "视线分析":
                setWatchLineAny('line',false)
                break;
              case "可视域":
                this.$emit('setToolDetailType','')
                break;
            }
          }
        }
        else{
          this.perspectiveList[i].chosen = false
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
#perspective-analysis{
  position: absolute;
  right:70px;
  top:300px;
  z-index: 1;
  text-align: center;
  background: rgba(0, 31, 112, 0.6);
  border-radius: 4px;
  border: 1px solid #00a1ff;
  color: #fff;
  .screen-list{
    padding: 10px 0px 10px 0px;
    margin: 0;
  }
  .screen-list li{
    list-style: none;
    cursor: pointer;
    padding: 2px 0px 2px 0px;
  }
  .screen-img{
    width: 35px;
    height: 35px;
  }
}
</style>
