派生自 wuyushui/SewerAndRainNetwork

chenzeping
2021-03-16 b9c5104fa16e67ef2761fc9f6ff5083573e958dc
src/components/panel/ToolBoxPanel.vue
@@ -1,11 +1,15 @@
<template>
  <div class="left-top-toolbox-panel">
    <div class="specific-tools">
      <el-button @click="changeSelect">
      <el-button @click="changeSelect" v-show="selectGroup">
        <img src="@assets/images/map-pages/icon/toolbox/tool.png" alt="">
        <span>工具</span>
      </el-button>
      <transition name="isD">
      <el-button @click="changeSelect" v-show="!selectGroup">
        <img src="@assets/images/map-pages/icon/toolbox/Selecd/tool.png" alt="">
        <a>工具</a>
      </el-button>
      <transition name="animationChange">
        <el-row v-show="selectGroup" class="specific-tools-group">
          <el-popover
              placement="bottom"
@@ -15,16 +19,18 @@
              v-for="(item,index) in menuList" :key="index"
          >
            <el-button slot="reference" class="el-button" :class="active === index ? 'tools-panel-choose':''"
                      @click="changeChoose(index)">
              <img :src="item.icon" alt=""/>
                       @click="changeChoose(index)">
              <img :src="item.iconSelecd" alt="" v-if="active === index"/>
              <img :src="item.icon" alt="" v-else/>
              <span>{{ item.label }}</span>
            </el-button>
            <el-button v-for="(itemT,indexT) in item.items" :key="indexT" @click="choiceItem(itemT)">
              <img :src="itemT.icon" :title="itemT.title"/>
            <el-button v-for="(itemT,indexT) in item.items" :key="indexT" @click="choiceItem(itemT,indexT)">
              <img :src="itemT.iconChoose" :title="itemT.title" v-if="Selecd === indexT"/>
              <img :src="itemT.icon" :title="itemT.title" v-else/>
            </el-button>
          </el-popover>
          <el-button @click="changeSelect" class="special-button">
            <i :class="selectGroup === false ? 'el-icon-d-arrow-right':'el-icon-d-arrow-left'"></i>
            <i :class="selectGroup === false ? 'el-icon-d-arrow-left':'el-icon-d-arrow-left'"></i>
          </el-button>
        </el-row>
      </transition>
@@ -33,17 +39,35 @@
</template>
<script>
// 功能导航
import plot from '@assets/images/map-pages/icon/toolbox/biaohui.png'
import polygon from '@assets/images/map-pages/icon/toolbox/celiang1.png'
import location from '@assets/images/map-pages/icon/toolbox/ditu.png'
import fullscreen from '@assets/images/map-pages/icon/toolbox/xiazai.png'
// 导航选中的状态
import plotChooose from '@assets/images/map-pages/icon/toolbox/Selecd/biaohui.png'
import polygonChooose from '@assets/images/map-pages/icon/toolbox/Selecd/celiang1.png'
import locationChooose from '@assets/images/map-pages/icon/toolbox/Selecd/ditu.png'
import dowloadChooose from '@assets/images/map-pages/icon/toolbox/Selecd/xiazai.png'
// 标绘的可选择数据
import iconRefinery from '@assets/images/map-pages/local.png'
import marker from '@assets/images/map-pages/icon/toolbox/map.png'
import line from '@assets/images/map-pages/icon/toolbox/line.png'
import polygonJ from '@assets/images/map-pages/icon/toolbox/polygon.png'
import polygonS from '@assets/images/map-pages/icon/toolbox/ju.png'
import polygonY from '@assets/images/map-pages/icon/toolbox/circle.png'
import del from '@assets/images/map-pages/icon/toolbox/del.png'
// 标绘选中的内容图片
import markerChoose from '@assets/images/map-pages/icon/toolbox/biaohuimark/dingweimark.png'
import lineChoose from '@assets/images/map-pages/icon/toolbox/biaohuimark/linemark.png'
import polygonJChoose from '@assets/images/map-pages/icon/toolbox/biaohuimark/liubianxing2mark.png'
import polygonSChoose from '@assets/images/map-pages/icon/toolbox/biaohuimark/rectmark.png'
import polygonYChoose from '@assets/images/map-pages/icon/toolbox/biaohuimark/circlemark.png'
import delChoose from '@assets/images/map-pages/icon/toolbox/biaohuimark/shanchu.png'
// 测量
import distance from '@assets/images/map-pages/icon/toolbox/juli.png'
@@ -54,12 +78,18 @@
export default {
  name: 'ToolBoxPanel',
  // components: { BaseNavMenuItem },
  data () {
    return {
      selectGroup: false,
      active: -1,
      Selecd: -1,
      drawLayer: null,
      map: null,
      L: window.L,
      menuList: [
        {
          icon: plot,
          iconSelecd: plotChooose,
          label: '标绘',
          index: '1',
          items: [
@@ -67,36 +97,49 @@
              index: '1-1',
              label: '点标绘',
              icon: marker,
              title: '点标绘'
              title: '点标绘',
              iconChoose: markerChoose
            },
            {
              index: '1-2',
              label: '线标绘',
              icon: line,
              title: '线标绘'
              title: '线标绘',
              iconChoose: lineChoose
            },
            {
              index: '1-4',
              label: '多边形',
              icon: polygonJ,
              title: '多边形'
              title: '多边形',
              iconChoose: polygonJChoose
            },
            {
              index: '1-5',
              label: '矩形',
              icon: polygonS,
              title: '矩形'
              title: '矩形',
              iconChoose: polygonSChoose
            },
            {
              index: '1-3',
              label: '圆形',
              icon: polygonY,
              title: '圆形'
              title: '圆形',
              iconChoose: polygonYChoose
            },
            {
              index: '1-4',
              label: '删除',
              icon: del,
              title: '删除标绘',
              iconChoose: delChoose
            }
          ]
        },
        {
          icon: polygon,
          iconSelecd: polygonChooose,
          label: '测量',
          index: '3',
          items: [
@@ -111,11 +154,18 @@
              label: '面积',
              icon: mm,
              title: '面积测量'
            },
            {
              index: '3-3',
              label: '删除',
              icon: '',
              title: '删除'
            }
          ]
        },
        {
          icon: location,
          iconSelecd: locationChooose,
          label: '地图',
          index: '2',
          items: [
@@ -153,6 +203,7 @@
        },
        {
          icon: fullscreen,
          iconSelecd: dowloadChooose,
          label: '下载',
          index: '4',
          items: [
@@ -176,42 +227,40 @@
            }
          ]
        }
      ],
      selectGroup: false,
      drawLayer: null,
      map: null,
      L: window.L,
      active: 0,
      isShow: true
      ]
    }
  },
  methods: {
    changeChoose (index) {
      this.active = index
    },
    choiceItem (itemT) {
      console.log(itemT.label)
    changeSelect () {
      this.selectGroup = !this.selectGroup
    },
    choiceItem (itemT, indexT) {
      this.Selecd = indexT
      switch (itemT.label) {
        case '点标绘':
          // MakeTation.StartPointAnnotation(this.map, this.L)
          var myIcon = this.L.icon({
            iconUrl: iconRefinery,
            iconSize: [26, 32],
            iconAnchor: [13, 16],
            popupAnchor: [26, -32]
          })
          this.drawLayer = this.map.editTools.startMarker()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          this.drawLayer.setIcon(myIcon)
          break
        case '线标绘':
          this.drawLayer = this.map.editTools.startPolyline()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          break
        case '多边形':
          this.drawLayer = this.map.editTools.startPolygon()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          break
        case '矩形':
          this.drawLayer = this.map.editTools.startRectangle()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          break
        case '圆形':
          this.drawLayer = this.map.editTools.startCircle()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          break
        case '距离':
          Measure.startMeasureLen(this.map, this.L)
@@ -247,83 +296,32 @@
          }).addTo(this.map)
          printerY.printMap('A4Portrait page', 'MyManualPrint')
          break
        case '删除':
          this.map.removeLayer(this.drawLayer)
          break
      }
    },
    // handleSelect (index) {
    //   console.log(index)
    //   switch (index) {
    //     case '4-1':
    //       // this.map.toggleFullscreen()
    //       var printer = this.L.easyPrint({
    //         sizeModes: ['Current', 'A4Landscape', 'A4Portrait'],
    //         filename: 'map_image',
    //         exportOnly: true,
    //         hideControlContainer: true
    //       }).addTo(this.map)
    //       printer.printMap('CurrentSize', 'MyManualPrint')
    //       break
    //     case '4-2':
    //       var printerX = this.L.easyPrint({
    //         sizeModes: ['Current', 'A4Landscape', 'A4Portrait'],
    //         filename: 'map_image',
    //         exportOnly: true,
    //         hideControlContainer: true
    //       }).addTo(this.map)
    //       printerX.printMap('A4Landscape page', 'MyManualPrint')
    //       break
    //     case '4-3':
    //       var printerY = this.L.easyPrint({
    //         sizeModes: ['Current', 'A4Landscape', 'A4Portrait'],
    //         filename: 'map_image',
    //         exportOnly: true,
    //         hideControlContainer: true
    //       }).addTo(this.map)
    //       printerY.printMap('A4Portrait page', 'MyManualPrint')
    //       break
    //     case '1-2':
    //       this.drawLayer = this.map.editTools.startPolyline()
    //       this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
    //       Measure.startMeasureLen(this.map, this.L)
    //       break
    //     case '1-3-1':
    //       // alert('圆形')
    //       this.drawLayer = this.map.editTools.circleMarker()
    //       this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
    //       break
    //     case '1-3-2':
    //       this.drawLayer = this.map.editTools.startPolygon()
    //       this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
    //       break
    //     case '1-1':
    //       MakeTation.StartPointAnnotation(this.map, this.L)
    //       break
    //     case '图标标注':
    //       this.drawLayer = this.map.editTools.startIcon()
    //       this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
    //       break
    //     case '文字标注':
    //       this.bouncedText = true
    //       MakeTation.startMakeText(this.map, this.L)
    //       break
    //     case '距离测量':
    //       Measure.startMeasureLen(this.map, this.L)
    //       break
    //     case '面积测量':
    //       Measure.startMeasureArea(this.map, this.L)
    //       break
    //   }
    // },
    // 文字标注控制
    // 左上功能控制
    changeSelect () {
      this.selectGroup = !this.selectGroup
      this.isShow = !this.isShow
      this.drawLayer.on('dblclick', this.L.DomEvent.stop).on('dblclick', this.drawLayer.toggleEdit)
      this.drawLayer.setStyle({
        color: 'red',
        fillColor: '#ffffff',
        fillOpacity: 0.1,
        fill: true
      })
    }
  }
}
</script>
<style lang="less" scoped>
.animationChange-enter-active, .animationChange-leave-active {
  transition: all 0.5s;
}
.animationChange-enter, .animationChange-leave-to {
  opacity: 0;
  transform: translateX(-100px);
}
.left-top-toolbox-panel {
  position: absolute;
  left: 0;
@@ -332,6 +330,7 @@
  .specific-tools {
    display: flex;
    .el-button {
      z-index: 999;
      padding: 0;
@@ -348,13 +347,16 @@
      span {
        display: block;
        font-size: 0.012rem;
        color: @color-tool;
      }
      a {
        display: block;
        color: @color-shadow;
      }
    }
    .specific-tools-group {
      z-index: 1;
      .tools-panel-choose {
        border: none;
        box-shadow: 0 0 0.03rem @color-shadow;
@@ -376,12 +378,5 @@
      color: @color-over;
    }
  }
}
.isD-enter-active, .isD-leave-active{
  transition: all 0.5s;
}
.isD-enter, .isD-leave-to{
  opacity: 0;
  transform: translateX(-100px);
}
</style>