派生自 wuyushui/SewerAndRainNetwork

seatonwan9
2021-05-28 593f6ccd3aec8045a26b4b330f2b034df05bfd9f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<template>
    <div class="report-location-box">
        <div class="report-location">
            <el-tabs v-model="activeName">
                <el-tab-pane label="点击定位" name="first">
                    <div class="click-location">
                        <el-row>
                            <el-input type="text" v-model="clickLocation" clearable @focus="focusLocation"></el-input>
                        </el-row>
                        <el-row>
                            <el-button type="primary" @click="confirm">确认</el-button>
                        </el-row>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="管段定位" name="second">
                    <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: 10px">
                        <el-button type="primary" @click="confirm">确认</el-button>
                    </div>
                </el-tab-pane>
            </el-tabs>
        </div>
    </div>
</template>
 
<script>
// import eventBus from '../../../../eventBus'
// 管段定位组件
import ReportLocationSection from './ReportLocationSection'
 
export default {
  name: 'ReportLocation',
  components: {
    ReportLocationSection
  },
  data () {
    return {
      // active tab切换
      activeName: 'first',
      // 点击定位绑定数据
      clickLocation: '',
      // 经纬度定位
      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
      this.clickLocation = '\'' + pointX + '\'' + pointY + ''
      this.mapPointResult(e)
    },
    mapPointResult (e) {
      console.log(e)
      this.LongLatPos.longPos = e.latlng.lng
      this.LongLatPos.latPos = e.latlng.lat
    },
    // 获得焦点 进行定位
    focusLocation () {
      this.selectPipeLine()
    },
    // 经纬度定位
    mapPoints () {
      this.selectPipeLine()
    },
    // 点击确认按钮事件
    confirm () {
      // 通过子组件向父组件传递数据
      this.$emit('locationClick', this.LongLatPos)
      this.clickLocation = ''
      this.LongLatPos.longPos = ''
      this.LongLatPos.latPos = ''
    }
  }
}
</script>
 
<style lang="less" scoped>
    .place-box {
        display: flex;
        align-items: center;
        justify-content: space-around;
    }
    .click-location {
        margin: 0 auto;
        text-align: center;
 
        .el-input {
            width: 80%;
            margin: 15px auto;
        }
 
        .el-button {
            margin: 15px auto;
        }
    }
    .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>