diff --git a/src/views/wellManage/addWell.vue b/src/views/wellManage/addWell.vue index b538147..113ee2b 100644 --- a/src/views/wellManage/addWell.vue +++ b/src/views/wellManage/addWell.vue @@ -156,6 +156,7 @@ import { getWellType, addWell } from '@/api/well/well' import { Uploadimg } from '@/api/common' import DeptSelect from '@/components/DeptSelect' +import AMapLoader from '@amap/amap-jsapi-loader' export default { name: 'AddWell', @@ -274,11 +275,38 @@ firstDept() { // 获取权属单位 return this.wellForm.deptid }, + lonLat() { + return this.wellForm.coordinateX + ',' + this.wellForm.coordinateY + }, qu() { // 获取区 return this.wellForm.qu } }, watch: { + lonLat(val) { + var _this = this + window._AMapSecurityConfig = { + securityJsCode: this.$store.getters.amapSecurityCode + } + AMapLoader.load({ + key: this.$store.getters.amapKey // 秘钥,从store中取 + }).then((AMap) => { + AMap.plugin('AMap.Geocoder', function() { + var geocoder = new AMap.Geocoder({ + city: '' + }) + var lnglat = val.split(',') + geocoder.getAddress(lnglat, function(status, result) { + if (status === 'complete' && result.info === 'OK') { + _this.wellForm.position = result.regeocode.formattedAddress + // result为对应的地理位置详细信息 + } else { + _this.wellForm.position = '' + } + }) + }) + }) + }, firstDept(val) { // 监控权属单位变化 if (val !== '') { this.wellForm.qu = ''