@v2coding/ui 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/v2coding-ui.esm.js +1340 -282
- package/dist/v2coding-ui.min.js +1 -1
- package/dist/v2coding-ui.ssr.js +1331 -283
- package/package.json +1 -1
- package/src/components/field/field.fence.vue +856 -0
- package/src/components/field/field.lnglat.vue +236 -0
- package/src/components/table/table.vue +1 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ui-field-latlng" v-loading="loading">
|
|
3
|
+
<div class="map"></div>
|
|
4
|
+
<div class="info" v-show="!loading">
|
|
5
|
+
<div class="input-item searchbox">
|
|
6
|
+
<div class="input-item-prepend">
|
|
7
|
+
<span class="input-item-text">搜索关键字</span>
|
|
8
|
+
</div>
|
|
9
|
+
<!-- form="__ignore__" 避免 enter提交表单 -->
|
|
10
|
+
<input ref="input" type="text" form="__ignore__" placeholder="请输入...">
|
|
11
|
+
<div ref="output" class="search-result"></div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import gcoord from 'gcoord';
|
|
19
|
+
import {getAMap} from '../../config/config.amap';
|
|
20
|
+
import FieldMixin from './field.mixin';
|
|
21
|
+
|
|
22
|
+
const CoordTypes = {
|
|
23
|
+
bd09: gcoord.BD09,
|
|
24
|
+
gcj02: gcoord.GCJ02,
|
|
25
|
+
wgs84: gcoord.WGS84,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: 'ui-field-latlng',
|
|
30
|
+
mixins: [FieldMixin],
|
|
31
|
+
props: {
|
|
32
|
+
coordType: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'wgs84',
|
|
35
|
+
validator: (val) => Object.keys(CoordTypes).includes(val),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
loading: true,
|
|
41
|
+
keyword: '',
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
computed: {
|
|
45
|
+
point() {
|
|
46
|
+
if (!this.value) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (!this.isValidPoint(this.value)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const [lat, lng] = this.value.split(',');
|
|
53
|
+
return {lat: +lat, lng: +lng};
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
watch: {
|
|
57
|
+
point(p) {
|
|
58
|
+
this.onPointChange(p);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
init() {
|
|
63
|
+
getAMap(['AMap.ToolBar', 'AMap.Geolocation', 'AMap.AutoComplete']).then((AMap) => {
|
|
64
|
+
this.initMap(AMap);
|
|
65
|
+
this.loading = false;
|
|
66
|
+
this.done();
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
initMap(AMap) {
|
|
70
|
+
const map = new AMap.Map(this.$el.querySelector('.map'), {
|
|
71
|
+
zoom: 11,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
map.addControl(new AMap.ToolBar({position: 'RT'}));
|
|
75
|
+
map.addControl(new AMap.Geolocation({position: 'RB'}));
|
|
76
|
+
const auto = new AMap.AutoComplete({
|
|
77
|
+
input: this.$refs.input,
|
|
78
|
+
output: this.$refs.output,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
map.on('click', this.onMapClick);
|
|
82
|
+
auto.on('select', (event) => {
|
|
83
|
+
if (!event.poi || !event.poi.location) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
map.setZoomAndCenter(16, event.poi.location);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
this.map = map;
|
|
90
|
+
|
|
91
|
+
this.onPointChange(this.point);
|
|
92
|
+
},
|
|
93
|
+
isValidPoint(val) {
|
|
94
|
+
const [lat, lng] = val.split(',');
|
|
95
|
+
return !(isNaN(+lat) || isNaN(+lng));
|
|
96
|
+
},
|
|
97
|
+
onMapClick({lnglat}) {
|
|
98
|
+
let {lat, lng} = lnglat;
|
|
99
|
+
// 当前地图是 GCJ02 坐标系
|
|
100
|
+
if (this.coordType !== 'gcj02') {
|
|
101
|
+
[lng, lat] = gcoord.transform([lng, lat], gcoord.GCJ02, CoordTypes[this.coordType]);
|
|
102
|
+
lng = lng.toFixed(7) / 1;
|
|
103
|
+
lat = lat.toFixed(7) / 1;
|
|
104
|
+
}
|
|
105
|
+
this.onChange([lat, lng].join(','));
|
|
106
|
+
},
|
|
107
|
+
onPointChange(point) {
|
|
108
|
+
if (!this.map) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.map.clearMap();
|
|
112
|
+
if (!point) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let {lng, lat} = point;
|
|
116
|
+
// 当前地图是 GCJ02 坐标系
|
|
117
|
+
if (this.coordType !== 'gcj02') {
|
|
118
|
+
[lng, lat] = gcoord.transform([lng, lat], CoordTypes[this.coordType], gcoord.GCJ02);
|
|
119
|
+
}
|
|
120
|
+
// eslint-disable-next-line no-undef
|
|
121
|
+
const marker = new AMap.Marker({position: new AMap.LngLat(lng, lat)});
|
|
122
|
+
this.map.add(marker);
|
|
123
|
+
this.map.setCenter([lng, lat]);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<style lang="less">
|
|
130
|
+
.ui-field-latlng {
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: 280px;
|
|
133
|
+
position: relative;
|
|
134
|
+
|
|
135
|
+
.map {
|
|
136
|
+
width: 100%;
|
|
137
|
+
height: 100%;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.info {
|
|
141
|
+
position: absolute;
|
|
142
|
+
top: 0;
|
|
143
|
+
left: 0;
|
|
144
|
+
right: 0;
|
|
145
|
+
bottom: 0;
|
|
146
|
+
pointer-events: none;
|
|
147
|
+
|
|
148
|
+
.searchbox {
|
|
149
|
+
left: 12px;
|
|
150
|
+
top: 12px;
|
|
151
|
+
background-color: #fff;
|
|
152
|
+
box-shadow: 0 0 3px rgba(0, 0, 0, .5);
|
|
153
|
+
pointer-events: initial;
|
|
154
|
+
border-radius: 3px;
|
|
155
|
+
padding: 3px;
|
|
156
|
+
|
|
157
|
+
.search-result {
|
|
158
|
+
position: absolute;
|
|
159
|
+
top: calc(100% - 2px);
|
|
160
|
+
left: 0;
|
|
161
|
+
right: 0;
|
|
162
|
+
background-color: #fefefe;
|
|
163
|
+
box-shadow: 0 1px 3px #999 ;
|
|
164
|
+
visibility: hidden;
|
|
165
|
+
border-radius: 0 0 3px 3px;
|
|
166
|
+
|
|
167
|
+
.auto-item {
|
|
168
|
+
white-space: nowrap;
|
|
169
|
+
font-size: 12px;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
padding: 4px;
|
|
172
|
+
line-height: 14px;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.input-item {
|
|
179
|
+
position: relative;
|
|
180
|
+
display: inline-flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
width: 220px;
|
|
183
|
+
font-size: 12px;
|
|
184
|
+
|
|
185
|
+
.input-item-prepend {
|
|
186
|
+
margin-right: -1px;
|
|
187
|
+
|
|
188
|
+
.input-item-text {
|
|
189
|
+
padding: 0.25em 0.5em;
|
|
190
|
+
display: block;
|
|
191
|
+
text-justify: distribute-all-lines;
|
|
192
|
+
text-align-last: justify;
|
|
193
|
+
align-items: center;
|
|
194
|
+
margin-bottom: 0;
|
|
195
|
+
font-weight: 400;
|
|
196
|
+
line-height: 1.5;
|
|
197
|
+
color: #495057;
|
|
198
|
+
text-align: center;
|
|
199
|
+
white-space: nowrap;
|
|
200
|
+
background-color: #e9ecef;
|
|
201
|
+
border: 1px solid #ced4da;
|
|
202
|
+
border-radius: .25rem 0 0 .25rem;
|
|
203
|
+
box-sizing: border-box;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
input {
|
|
208
|
+
position: relative;
|
|
209
|
+
flex: 1 1 auto;
|
|
210
|
+
width: 1%;
|
|
211
|
+
margin: 0;
|
|
212
|
+
background: #fff;
|
|
213
|
+
padding: 0.25em 0.5em;
|
|
214
|
+
display: inline-block;
|
|
215
|
+
line-height: 1.5;
|
|
216
|
+
color: #495057;
|
|
217
|
+
vertical-align: middle;
|
|
218
|
+
border: 1px solid #ced4da;
|
|
219
|
+
border-radius: 0 .25rem .25rem 0;
|
|
220
|
+
appearance: none;
|
|
221
|
+
box-sizing: border-box;
|
|
222
|
+
|
|
223
|
+
&:focus {
|
|
224
|
+
border-color: #80bdff;
|
|
225
|
+
outline: 0;
|
|
226
|
+
box-shadow: 0 0 0 0.1rem rgba(128, 189, 255, .1);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.amap-logo,
|
|
232
|
+
.amap-copyright {
|
|
233
|
+
display: none !important;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
</style>
|
|
@@ -779,7 +779,7 @@
|
|
|
779
779
|
|
|
780
780
|
.ui-table-empty {
|
|
781
781
|
padding-top: 110px;
|
|
782
|
-
background: url(
|
|
782
|
+
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTg0IiBoZWlnaHQ9IjE1MiIgdmlld0JveD0iMCAwIDE4NCAxNTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDI0IDMxLjY3KSI+CiAgICAgIDxlbGxpcHNlIGZpb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