派生自 wuyushui/SewerAndRainNetwork

yangdelong
2021-05-29 71c663091d05b11c41f78d8e75cb8b3db63b9cbc
src/components/base-page/enterprise-emergency/events-reported/ReportLocation.vue
@@ -8,139 +8,34 @@
                <ReportLocationSection></ReportLocationSection>
            </el-tab-pane>
            <el-tab-pane label="经纬度定位" name="third">
                <el-row class="place-box">
                    <div class="place-left">
                        <el-form :model="LongLatPos" label-width="90px">
                            <el-form-item label="经度:">
                                <el-input v-model="LongLatPos.longPos"></el-input>
                            </el-form-item>
                            <el-form-item label="纬度:">
                                <el-input v-model="LongLatPos.latPos"></el-input>
                            </el-form-item>
                        </el-form>
                    </div>
                    <div class="place-right">
                        <el-button type="primary" @click="mapPoints">定位</el-button>
                    </div>
                </el-row>
                <div class="place-bottom" style="text-align: center;margin: 5px">
                    <el-button type="primary" @click="confirm">确认</el-button>
                </div>
                <ReportLocationPoint></ReportLocationPoint>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>
<script>
// import eventBus from '../../../../eventBus'
// 管段定位组件
import ReportLocationSection from './ReportLocationSection'
import ReportLocationSearch from './ReportLocationSearch'
import iconUrl from '../../../../../public/assets/images/map/loc.png'
import ReportLocationPoint from './ReportLocationPoint'
export default {
  name: 'ReportLocation',
  components: {
    ReportLocationSearch,
    ReportLocationSection
    ReportLocationSection,
    ReportLocationPoint
  },
  data () {
    return {
      // active tab切换
      activeName: 'first',
      // 经纬度定位
      LongLatPos: {
        longPos: '',
        latPos: ''
      }
    }
  },
  // mounted () {
  //   // 接收规定 每次重新选择定位 都指定 选择第一个开始
  //   eventBus.$on('tab-change', (obj) => {
  //     this.activeName = obj
  //   })
  // },
  methods: {
    // 地图上点击
    selectPipeLine () {
      window.map.on('click', this.selectClick)
      // window.mapManager.clickDialogSwitch = false
    },
    // 地图上点击回调
    selectClick (e) {
      window.map.off('click', this.selectClick)
      // const point = [e.latlng.lng, e.latlng.lat]
      const pointX = e.latlng.lng
      const pointY = e.latlng.lat
      // let marker = window.L.marker(point,{
      //
      // })
      this.clickLocation = '\'' + pointX + '\'' + pointY + ''
      this.mapPointResult(e)
    },
    mapPointResult (e) {
      console.log(e)
      this.LongLatPos.longPos = e.latlng.lng
      this.LongLatPos.latPos = e.latlng.lat
      const as = [e.latlng.lat, e.latlng.lng]
      // console.log(as)
      const marker = window.L.marker(as, {
        icon: window.L.icon({
          iconUrl: iconUrl,
          iconSize: [30, 30],
          iconAnchor: [15, 15]
        })
      })
      window.map.addLayer(marker)
    },
    // 获得焦点 进行定位
    focusLocation () {
      this.selectPipeLine()
    },
    // 经纬度定位
    mapPoints () {
      this.selectPipeLine()
    },
    // 点击确认按钮事件
    confirm () {
      // 通过子组件向父组件传递数据
      this.$emit('locationClick', this.LongLatPos)
      this.clickLocation = ''
      this.LongLatPos.longPos = ''
      this.LongLatPos.latPos = ''
      activeName: 'first'
    }
  }
}
</script>
<style lang="less" scoped>
    .place-box {
        display: flex;
        align-items: center;
        justify-content: space-around;
    }
    .place {
        text-align: center;
        .place-top {
            display: flex;
            align-items: center;
            justify-content: space-around;
            .place-right {
                .el-button {
                    margin: 15px;
                }
            }
        }
        .place-bottom {
            .el-button {
                /*margin: 15px;*/
            }
        }
    }
</style>