Commit 735600e93bb7a9c8bae20c9f6116a4de2f2a6c26
Merge branch 'fix/device-location' into 'main_dev'
fix: 修改设备编辑点击地图时回显问题 See merge request yunteng/thingskit-front!1022
Showing
1 changed file
with
17 additions
and
4 deletions
... | ... | @@ -116,6 +116,7 @@ |
116 | 116 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; |
117 | 117 | import { buildUUID } from '/@/utils/uuid'; |
118 | 118 | import { useMessage } from '/@/hooks/web/useMessage'; |
119 | + import { computed } from 'vue'; | |
119 | 120 | |
120 | 121 | export default defineComponent({ |
121 | 122 | components: { |
... | ... | @@ -142,6 +143,10 @@ |
142 | 143 | const orgData: any = reactive({ |
143 | 144 | treeData: [], |
144 | 145 | }); |
146 | + const isUpdate1 = computed(() => { | |
147 | + const { isUpdate } = props; | |
148 | + return isUpdate; | |
149 | + }); | |
145 | 150 | const getOrganizationListFunc = async () => { |
146 | 151 | const data = await getOrganizationList(); |
147 | 152 | copyTransFun(data as any as any[]); |
... | ... | @@ -235,11 +240,19 @@ |
235 | 240 | }; |
236 | 241 | |
237 | 242 | // 地图的弹框 |
238 | - const spinning = ref<boolean>(true); | |
243 | + const spinning = ref<boolean>(false); | |
239 | 244 | const visible = ref(false); |
240 | 245 | const selectPosition = async () => { |
241 | 246 | visible.value = true; |
242 | - if (!positionState.longitude) { | |
247 | + if ( | |
248 | + !unref(isUpdate1) && | |
249 | + unref(devicePositionState).longitude && | |
250 | + unref(devicePositionState).latitude | |
251 | + ) { | |
252 | + positionState.longitude = unref(devicePositionState).longitude; | |
253 | + positionState.latitude = unref(devicePositionState).latitude; | |
254 | + } | |
255 | + if (!positionState.longitude || !positionState.latitude) { | |
243 | 256 | let getLocalCity = new BMap.LocalCity(); |
244 | 257 | let getLocation = new BMap.Geolocation(); |
245 | 258 | const userAgent = navigator.userAgent; |
... | ... | @@ -259,7 +272,6 @@ |
259 | 272 | }); |
260 | 273 | } else { |
261 | 274 | await getLocation.getCurrentPosition(function (res) { |
262 | - console.log(res, res); | |
263 | 275 | positionState.longitude = res?.longitude || '104.05326410962411'; |
264 | 276 | positionState.latitude = res?.latitude || '30.54855093076791'; |
265 | 277 | var pt = new BMap.Point(positionState.longitude, positionState.latitude); |
... | ... | @@ -268,12 +280,13 @@ |
268 | 280 | }); |
269 | 281 | } |
270 | 282 | } catch (err) { |
271 | - console.log(err, 'err'); | |
272 | 283 | createMessage.error('获取定位失败'); |
273 | 284 | } |
274 | 285 | initMap(positionState.longitude, positionState.latitude); |
275 | 286 | } else { |
276 | 287 | initMap(positionState.longitude, positionState.latitude); |
288 | + var pt = new BMap.Point(positionState.longitude, positionState.latitude); | |
289 | + getAddrByPoint(pt); | |
277 | 290 | } |
278 | 291 | }; |
279 | 292 | ... | ... |