Commit 93dafc11a7f7074c2bee13f2566552de3822cb1b

Authored by loveumiko
1 parent 73f83cde

fix: 修改设备编辑点击地图时回显问题

@@ -116,6 +116,7 @@ @@ -116,6 +116,7 @@
116 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; 116 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
117 import { buildUUID } from '/@/utils/uuid'; 117 import { buildUUID } from '/@/utils/uuid';
118 import { useMessage } from '/@/hooks/web/useMessage'; 118 import { useMessage } from '/@/hooks/web/useMessage';
  119 + import { computed } from 'vue';
119 120
120 export default defineComponent({ 121 export default defineComponent({
121 components: { 122 components: {
@@ -142,6 +143,10 @@ @@ -142,6 +143,10 @@
142 const orgData: any = reactive({ 143 const orgData: any = reactive({
143 treeData: [], 144 treeData: [],
144 }); 145 });
  146 + const isUpdate1 = computed(() => {
  147 + const { isUpdate } = props;
  148 + return isUpdate;
  149 + });
145 const getOrganizationListFunc = async () => { 150 const getOrganizationListFunc = async () => {
146 const data = await getOrganizationList(); 151 const data = await getOrganizationList();
147 copyTransFun(data as any as any[]); 152 copyTransFun(data as any as any[]);
@@ -235,11 +240,19 @@ @@ -235,11 +240,19 @@
235 }; 240 };
236 241
237 // 地图的弹框 242 // 地图的弹框
238 - const spinning = ref<boolean>(true); 243 + const spinning = ref<boolean>(false);
239 const visible = ref(false); 244 const visible = ref(false);
240 const selectPosition = async () => { 245 const selectPosition = async () => {
241 visible.value = true; 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 let getLocalCity = new BMap.LocalCity(); 256 let getLocalCity = new BMap.LocalCity();
244 let getLocation = new BMap.Geolocation(); 257 let getLocation = new BMap.Geolocation();
245 const userAgent = navigator.userAgent; 258 const userAgent = navigator.userAgent;
@@ -259,7 +272,6 @@ @@ -259,7 +272,6 @@
259 }); 272 });
260 } else { 273 } else {
261 await getLocation.getCurrentPosition(function (res) { 274 await getLocation.getCurrentPosition(function (res) {
262 - console.log(res, res);  
263 positionState.longitude = res?.longitude || '104.05326410962411'; 275 positionState.longitude = res?.longitude || '104.05326410962411';
264 positionState.latitude = res?.latitude || '30.54855093076791'; 276 positionState.latitude = res?.latitude || '30.54855093076791';
265 var pt = new BMap.Point(positionState.longitude, positionState.latitude); 277 var pt = new BMap.Point(positionState.longitude, positionState.latitude);
@@ -268,12 +280,13 @@ @@ -268,12 +280,13 @@
268 }); 280 });
269 } 281 }
270 } catch (err) { 282 } catch (err) {
271 - console.log(err, 'err');  
272 createMessage.error('获取定位失败'); 283 createMessage.error('获取定位失败');
273 } 284 }
274 initMap(positionState.longitude, positionState.latitude); 285 initMap(positionState.longitude, positionState.latitude);
275 } else { 286 } else {
276 initMap(positionState.longitude, positionState.latitude); 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