派生自 wuyushui/SewerAndRainNetwork

chenzeping
2021-03-15 3ca24d97c52399dcbd93165bf5c01e2ee2af7823
src/components/panel/ToolBoxPanel.vue
@@ -1,126 +1,179 @@
<template>
  <div class="lefttop-toolbox-panel">
    <div class="init-choose" @click="changeSelect()">
      <img src="@/assets/images/map-pages/icon/toolbox/circle.png" alt="">
    <div>
      <div class="init-choose" @click="changeSelect()">
        <img src="@/assets/images/map-pages/icon/toolbox/circle.png" alt=""/>
      </div>
      <el-menu class="el-menu"
               mode="horizontal"
               :collapse="isCollapse"
               unique-opened
               @select="handleSelect"
               v-show='selectGroup'
      >
        <base-nav-menu-item :menuList='menuList'></base-nav-menu-item>
      </el-menu>
    </div>
    <!--    <transition name="fade">-->
    <!--      <ul v-show='selectGroup'>-->
    <!--        <li v-for="(item,i) in imgList" :key="i" @click="toggleActive(i)" :value="total"><img :src="item"/></li>-->
    <!--      </ul>-->
    <!--    </transition>-->
    <div class="el-select-dropdown" v-show='selectGroup'>
      <el-dropdown @command="handleCommand" trigger="click" v-for="(item,i) in imgLists" :key="i" :value="total">
        <transition name="fade">
          <img :src="item.title" :title="item.alt"/>
        </transition>
        <el-dropdown-menu>
          <el-dropdown-item v-for="(ite,index) in item.items" :key="index" :command='ite.headings'>
            <span>{{ ite.headings }}</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <!--文字标注弹框-->
    <!--    <TextBounced v-show="this.bouncedText" @changeBounced="gitBounced"></TextBounced>-->
  </div>
</template>
<script>
import circle from '@/assets/images/map-pages/icon/toolbox/circle.png'
import fullscreen from '@/assets/images/map-pages/icon/toolbox/fullscreen.png'
import legend from '@/assets/images/map-pages/icon/toolbox/legend.png'
import location from '@/assets/images/map-pages/icon/toolbox/location.png'
import polygon from '@/assets/images/map-pages/icon/toolbox/polygon.png'
import square from '@/assets/images/map-pages/icon/toolbox/square.png'
// import legend from '@/assets/images/map-pages/icon/toolbox/legend.png'
// import square from '@/assets/images/map-pages/icon/toolbox/square.png'
import circle from '@assets/images/map-pages/icon/toolbox/circle.png'
import location from '@assets/images/map-pages/icon/toolbox/location.png'
import polygon from '@assets/images/map-pages/icon/toolbox/polygon.png'
import fullscreen from '@assets/images/map-pages/icon/toolbox/fullscreen.png'
// 测量的方法
import '@/components/plugin/leaflet-measure-path/leaflet-measure-path.css'
import Measure from '@/components/plugin/MeaSure'
// 标注的方法
import MakeTation from '@components/plugin/MakeTation'
// 封装的选择弹框
import BaseNavMenuItem from '@components/panel/BaseNavMenuItem'
export default {
  name: 'ToolBoxPanel',
  components: {},
  components: { BaseNavMenuItem },
  data () {
    return {
      isPanelVisible: false,
      total: 0,
      activeTools: {},
      imgLists: [
      menuList: [
        {
          title: circle,
          alt: '标绘',
          icon: circle,
          label: '标绘',
          index: '1',
          items: [
            { headings: '线标绘' },
            { headings: '面标绘' },
            { headings: '箭头标绘' }
            {
              index: '1-1',
              label: '点标绘'
            },
            {
              index: '1-2',
              label: '线标绘'
            },
            {
              index: '1-3',
              label: '面标绘',
              items: [
                {
                  index: '1-3-1',
                  label: '圆形'
                },
                {
                  index: '1-3-2',
                  label: '多边形'
                },
                {
                  index: '1-3-3',
                  label: '矩形'
                }
              ]
            }
          ]
        },
        {
          title: square,
          alt: '标注',
          icon: location,
          label: '切换底图',
          index: '2',
          items: [
            { headings: '点标注' },
            { headings: '线标注' },
            { headings: '面标注' },
            { headings: '文字标注' },
            { headings: '图标标注' }
            {
              label: '影像图',
              index: '2-1',
              items: [
                {
                  index: '2-1-1',
                  label: '影像標注'
                }
              ]
            },
            {
              label: '矢量图',
              index: '2-2',
              items: [
                {
                  index: '2-2-1',
                  label: '矢量標注'
                }
              ]
            },
            {
              label: '地形图',
              index: '2-3',
              items: [
                {
                  index: '2-3-1',
                  label: '地形標注'
                }
              ]
            }
          ]
        },
        {
          title: legend,
          alt: '测量',
          icon: polygon,
          label: '管网',
          index: '3',
          items: [
            { headings: '距离测量' },
            { headings: '面积测量' }
            {
              index: '3-1',
              label: '连通性分析'
            },
            {
              index: '3-2',
              label: '爆管分析'
            },
            {
              index: '3-3',
              label: '流向分析'
            },
            {
              index: '3-4',
              label: '横断面分析'
            }
          ]
        },
        {
          title: location,
          alt: '切换底图',
          icon: fullscreen,
          label: '下载',
          index: '4',
          items: [
            { headings: '影像图' },
            { headings: '矢量图' },
            { headings: '地形图' }
          ]
        },
        {
          title: polygon,
          alt: '管网',
          items: [
            { headings: '连通性分析' },
            { headings: '爆管分析' },
            { headings: '流向分析' },
            { headings: '横断面分析' }
          ]
        },
        {
          title: fullscreen,
          alt: '下载',
          items: [
            { headings: '全屏' },
            { headings: 'A4横向' },
            { headings: 'A4纵向' }
            {
              index: '4-1',
              label: '全屏'
            },
            {
              index: '4-2',
              label: 'A4横向'
            },
            {
              index: '4-3',
              label: 'A4纵向'
            }
          ]
        }
      ],
      form: {
        regionType: '',
        enterprise: ''
      },
      isCollapse: false,
      selectGroup: false,
      drawLayer: null,
      map: null,
      L: window.L,
      map: null
      // 控制工具栏 文字标注 的弹框是否显示
      bouncedText: false
    }
  },
  methods: {
    changeSelect () {
      this.selectGroup = !this.selectGroup
    handleOpen () {
    },
    handleClose (done) {
      console.log(done)
    handleClose () {
    },
    handleClick (tab, event) {
      console.log(tab, event)
    },
    handleCommand (command) {
      console.log(command)
      switch (command) {
        case '全屏':
    handleSelect (index) {
      console.log(index)
      switch (index) {
        case '4-1':
          // this.map.toggleFullscreen()
          var printer = this.L.easyPrint({
            sizeModes: ['Current', 'A4Landscape', 'A4Portrait'],
@@ -151,38 +204,40 @@
        case '线标绘':
          this.drawLayer = this.map.editTools.startPolyline()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          Measure.startMeasureLen(this.map, this.L)
          break
        case '面标绘':
          this.drawLayer = this.map.editTools.startPolygon()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          break
        case '箭头标绘':
          this.drawLayer = this.map.editTools.startPolyline()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
        case '多边形':
          alert('多边形')
          break
        case '点标注':
          this.drawLayer = this.map.editTools.startMarker()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
        case '点标绘':
          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.drawLayer = this.map.editTools.startText()
          this.drawLayer.on('dblclick').on('dblclick', this.drawLayer.toggleEdit)
          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
      }
    },
    loadData () {
    gitBounced (params) {
      this.bouncedText = params
    },
    changeSelect () {
      this.selectGroup = !this.selectGroup
    }
  },
  mounted () {
    this.loadData()
  },
  created () {
  }
}
</script>
@@ -190,76 +245,81 @@
<style lang="less">
.lefttop-toolbox-panel {
  position: absolute;
  left: 5px;
  top: 5px;
  left: 15px;
  top: 15px;
  z-index: 999;
  display: flex;
  .init-choose {
    //margin: 15px 5px;
    background: #305B62;
    //margin-top: 15px;
    width: 35px;
    height: 38px;
    border-radius: 50%;
    border: 2px skyblue solid;
  div {
    width: 100%;
    height: 55px;
    line-height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
  }
  .el-select-dropdown {
    position: absolute;
    z-index: 1;
    width: 250px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    background: #305B62;
    border-radius: 15px;
    padding-inline: 10px;
    padding-inline-start: 30px;
    .el-dropdow {
      width: 20%;
    .init-choose {
      background: #305B62;
      width: 35px;
      height: 35px;
      border-radius: 50%;
      border: 2px skyblue solid;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 999;
    }
    @keyframes bounce-in {
      0% {
        transform: scale(0);
        opacity: 0.3;
    .el-menu {
      width: 100%;
      background: none;
      z-index: 1;
      border: none;
      background: #305B62;
      border-radius: 50px;
      //margin-left: -30px;
      .el-icon-arrow-down:before {
        content: " ";
      }
      100% {
        transform: scale(1);
        opacity: 1;
      .el-submenu__title:focus, .el-submenu__title:hover {
        background: none;
      }
    }
  }
    .fade-enter-active {
      transform-origin: left center;
      animation: bounce-in .2s;
    }
  //.transition {
  //  @keyframes bounce-in {
  //    0% {
  //      transform: scale(0);
  //      opacity: 0.3;
  //    }
  //    100% {
  //      transform: scale(1);
  //      opacity: 1;
  //    }
  //  }
  //
  //  .fade-enter-active {
  //    transform-origin: left center;
  //    animation: bounce-in .2s;
  //  }
  //
  //  .fade-leave-active {
  //    transform-origin: left;
  //    animation: bounce-in .2s reverse;
  //  }
  //}
    .fade-leave-active {
      transform-origin: left;
      animation: bounce-in .2s reverse;
}
.el-menu--horizontal {
  .el-menu--popup {
    min-width: 100px;
    .el-menu-item {
      min-width: 50px;
    }
  }
  .el-select-dropdown:last-child {
    margin-left: 10px;
  }
  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
}
ul {
  padding-inline-start: 0;
}
</style>