派生自 wuyushui/SewerAndRainNetwork

zhangshuaibao
2021-04-15 d0391dba3708d3f32bcd94e1881d1b598a0d9ef0
src/components/panel/LegendPanel.vue
@@ -1,13 +1,13 @@
<template>
  <div class="legend-panel">
    <transition name="fade">
      <div :class="'legend-content map-background'" v-show="legendControl">
      <div :class="'legend-content map-background'" v-show="isShow">
        <div class="legend-content-box" v-for="(item,index) in serviceLayers" :key="index">
          <p><span>{{ item.name }}</span></p>
          <div class="map-under-line"></div>
          <ul>
            <li v-for="(ite,inde) in item.layers" :key="inde">
              <img :src='ite.legendImage' alt=''>
            <li v-for="(ite,idx) in item.layers" :key="idx">
              <img :src="ite.legendImage===undefined?'../.././assets/images/map-pages/setting.png':ite.legendImage" alt=''>
              <span>{{ ite.name }}</span>
            </li>
          </ul>
@@ -15,7 +15,7 @@
      </div>
    </transition>
    <el-tooltip :popper-class="'map-tooltip'" effect="dark" content="图例" placement="left">
      <div :class="this.legendControl?'legend-btn map-btn-active':'legend-btn map-btn-unactive'"
      <div :class="this.isShow?'legend-btn map-btn-active':'legend-btn map-btn-unactive'"
           @click="legendChange()">
        <i class="el-icon-more-outline"></i>
      </div>
@@ -23,23 +23,42 @@
  </div>
</template>
<script>
import { LayerWasteWater } from '../../conf/layers/LayerWasteWater'
import { LayerWasteGas } from '../../conf/layers/LayerWasteGas'
import { LayerWasteSolid } from '../../conf/layers/LayerWasteSolid'
import { LayerAirQuality } from '../../conf/layers/LayerAirQuality'
import { LayerEnvRisk } from '../../conf/layers/LayerEnvRisk'
import { LayerSoilGroundWater } from '../../conf/layers/LayerSoilGroundWater'
import { LayerPipeLines } from '../../conf/layers/LayerPipeLines'
import { LayerPk } from '../../conf/layers/LayerPk'
import { LayerArea } from '../../conf/layers/LayerArea'
import bus from '@/eventBus'
export default {
  name: 'LegendPanel',
  data () {
    return {
      // 控制图例 内容的 显示/隐藏
      legendControl: false
      isShow: false,
      serviceLayers: [LayerSoilGroundWater, LayerEnvRisk, LayerAirQuality, LayerWasteSolid, LayerWasteGas, LayerWasteWater, LayerArea, LayerPk, LayerPipeLines]
    }
  },
  computed: {
    serviceLayers () {
      return this.$store.state.map.serviceLayers.LayerSewersLine
    }
  mounted () {
    const that = this
    bus.$on('changeState', function (state) {
      if (state.num !== 4 && state.type) {
        that.isShow = false
      }
    })
  },
  methods: {
    // 图标 控制内容的展示与隐藏
    legendChange () {
      this.legendControl = !this.legendControl
      this.isShow = !this.isShow
      const state = {
        type: this.isShow,
        num: 4
      }
      bus.$emit('changeState', state)
    }
  }
}