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

<script>
import {getDefinedLayer, setMapSumAna} from "@/units/map/AddLayer";

export default {
  name: "SunAnalysis",
  data(){
    return{
      sunAnalysisList:[
        {
          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){
      setMapSumAna(false);
      getDefinedLayer(true);
      this.$emit('setToolDetailType','');
      for(let i=0;i<this.sunAnalysisList.length;i++){
        if(item.name ==this.sunAnalysisList[i].name) {
          this.sunAnalysisList[i].chosen = !this.sunAnalysisList[i].chosen;
          if(this.sunAnalysisList[i].chosen){
            switch (this.sunAnalysisList[i].name){
              case "全部日照":
                setMapSumAna(true)
                break;
              case "局部日照":
                this.$emit('setToolDetailType','singleSunAnalysis')
                break;
            }
          }else{
            switch (this.sunAnalysisList[i].name){
              case "全部日照":
                setMapSumAna(false)
                break;
              case "局部日照":
                this.$emit('setToolDetailType','')
                break;
            }
          }
        }
        else{
          this.sunAnalysisList[i].chosen = false
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
#sun-analysis{
  position: absolute;
  right:70px;
  top:250px;
  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>
