lishifeng
2020-09-15 ce10677f47a14879424e7f562f78442cc03cfda1
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
<template>
  <div class="b-map-info-window">
    <div class="table-row">
      <div class="table-cell table-cell-right">地址:</div>
      <div class="table-cell">{{address}}</div>
    </div>
    <div class="table-row">
      <div class="table-cell table-cell-right">经度:</div>
      <div class="table-cell">{{point.lng}}</div>
    </div>
    <div class="table-row">
      <div class="table-cell table-cell-right">纬度:</div>
      <div class="table-cell">{{point.lat}}</div>
    </div>
    <div class="table-row">
      <div class="table-cell table-cell-right">站点名:</div>
      <div class="table-cell">
        <select style="border: 1px solid #ccc; width: 320px" v-model="home">
          <option v-for="(home, index) in getHomeList" :key="index" 
          :value="index">{{home.label}}</option>
        </select>
      </div>
    </div>
    <div class="table-row">
      <div class="table-cell"></div>
      <div class="table-cell table-cell-right table-cell-footer">
        <el-button type="primary" size="mini" @click="setHomeOnMap">确定</el-button>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  props: {
    text: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      address: '',
      point: {
        lng: '',   // 经度
        lat: '',   // 纬度
      },
      home: -1,
      homeList: []
    }
  },
  watch: {
    homeList(n) {
      if(this.homeList.length>0) {
        this.home = 0;
      }
    }
  },
  methods: {
    setHomeOnMap() {
      let homeInfo = this.getHomeInfo;
      if(homeInfo == -1) {
        this.$message({
          type: 'warning',
          message: '暂无可设站点'
        })
      }else {
        this.$emit('set-home-info', {
          address: this.address,
          point: this.point,
          info: homeInfo
        });
      }
    }
  },
  computed: {
    getHomeList() {
      if(this.homeList.length >0) {
        return this.homeList;
      }else {
        return [{
          value: -1,
          label: '暂无可设置站点'
        }]
      }
    },
    getHomeInfo() {
      let home = this.home;
      if(home == -1) {
        return -1;
      }else  {
        return this.homeList[home];
      }
    }
  }
};
</script>
 
<style scoped>
.b-map-info-window {
  color: #000000;
  padding: 8px;
  display: table;
}
.table-row {
  display: table-row;
}
.table-cell {
  display: table-cell;
  padding: 2px;
  white-space: nowrap;
}
.table-cell.table-cell-right {
  text-align: right;
}
.table-cell.table-cell-footer {
  padding-top: 16px;
}
</style>