diff --git a/config/index.js b/config/index.js index 8386f4ae..a73616ff 100644 --- a/config/index.js +++ b/config/index.js @@ -12,7 +12,7 @@ module.exports = { proxyTable: { "/api": { // 请求的目标主机 - // target: 'http://218.59.175.44:8082/nsgk_test/', // 公网测试环境 + //target: 'http://218.59.175.44:8082/nsgk_test/', // 公网测试环境 // target: `http://192.168.0.116:8091/nsgk_api/`, // 内网测试环境 target: 'http://localhost:8080/', //target: 'http://192.168.0.106:8080/', diff --git a/src/components/Map/MapGisLine.vue b/src/components/Map/MapGisLine.vue index 36339b17..a07b9dd0 100644 --- a/src/components/Map/MapGisLine.vue +++ b/src/components/Map/MapGisLine.vue @@ -7,6 +7,7 @@ +       @@ -31,6 +32,7 @@ export default { uuidMap: this.guidProduct(), drawingPolygonMap: this.guidProduct(), drawingResetMap: this.guidProduct(), + locationMap: this.guidProduct(), mapGeoServerUrl: "", // geoserver地址 villageBorderLayerName: "", // 乡镇边界图层名称 }; @@ -72,6 +74,56 @@ export default { return v.toString(16); }); }, + getCurrentLocation(callback) { + // 1. 首先尝试Android宿主端 + if(window._Native_object) // Android层注入全局对象 + { + console.log('使用Native获取定位'); + let coord = window._Native_object.GetLocation(null); + console.log('Native坐标: ' + coord); + if(coord) + { + let arr = coord.split(','); + let res = { + code: 200, + data: { + lng: arr[0], + lat: arr[1], + }, + }; + callback(res); + return; + } + } + + // 2. 再尝试浏览器 + if (navigator.geolocation) { + console.log('使用浏览器获取定位'); + navigator.geolocation.getCurrentPosition( + (position) => { + const { latitude, longitude } = position.coords; + let res = { + code: 200, + data: { + lng: longitude, + lat: latitude, + }, + }; + callback(res); + }, + (error) => { + console.log('定位失败: ' + error.message); + getQueryLand().then(callback); + }, + { enableHighAccuracy: true, timeout: 10000 } + ); + return; + } + + // 最后使用地区坐标 + console.log('使用地区坐标定位'); + getQueryLand().then(callback); + }, //地图查看 drawingPaceCountryLine() { //加载地图编辑 @@ -297,6 +349,26 @@ export default { that.formSubmit(); } }); + $("#" + this.locationMap).click(function () { + that.getCurrentLocation(res => { + if (res.code == 200) { + let lat = res.data.lat; + let lng = res.data.lng; + if(lat && lng){ + Zb = [lng,lat]; + }else { + Zb =[115.452752, 31.789033]; + } + map.getView().animate({ + // 只设置需要的属性即可 + center: ol.proj.fromLonLat(Zb), // 中心点 + zoom: 18, // 缩放级别 + rotation: undefined, // 缩放完成view视图旋转弧度 + duration: 1000, // 缩放持续时间,默认不需要设置 + }); + } + }); + }); } else{ //this.closeMoule = null; document.getElementById(that.uuidMap).innerHTML = ''; @@ -326,7 +398,7 @@ export default { }); //获取坐标是否存在 var Zb; - getQueryLand().then((response) => { + this.getCurrentLocation((response) => { if (response.code == 200) { let InsertCode = response.data; if (InsertCode != null) { @@ -442,6 +514,26 @@ export default { //that.closeMoule = null; that.formSubmit(); }); + $("#" + this.locationMap).click(function () { + that.getCurrentLocation(res => { + if (res.code == 200) { + let lat = res.data.lat; + let lng = res.data.lng; + if(lat && lng){ + Zb = [lng,lat]; + }else { + Zb =[115.452752, 31.789033]; + } + map.getView().animate({ + // 只设置需要的属性即可 + center: ol.proj.fromLonLat(Zb), // 中心点 + zoom: 18, // 缩放级别 + rotation: undefined, // 缩放完成view视图旋转弧度 + duration: 1000, // 缩放持续时间,默认不需要设置 + }); + } + }); + }); } }, }, diff --git a/src/components/Map/MapGisTagDTGCopy.vue b/src/components/Map/MapGisTagDTGCopy.vue index adad61ae..6f2e7bf0 100644 --- a/src/components/Map/MapGisTagDTGCopy.vue +++ b/src/components/Map/MapGisTagDTGCopy.vue @@ -3,6 +3,7 @@
+       @@ -27,6 +28,7 @@ uuidMap: this.guidProduct(), drawPolygonMap: this.guidProduct(), drawResetMap: this.guidProduct(), + locationMap: this.guidProduct(), mapGeoServerUrl: "", // geoserver地址 villageBorderLayerName: "", // 乡镇边界图层名称 }; @@ -68,6 +70,56 @@ return v.toString(16); }); }, + getCurrentLocation(callback) { + // 1. 首先尝试Android宿主端 + if(window._Native_object) // Android层注入全局对象 + { + console.log('使用Native获取定位'); + let coord = window._Native_object.GetLocation(null); + console.log('Native坐标: ' + coord); + if(coord) + { + let arr = coord.split(','); + let res = { + code: 200, + data: { + lng: arr[0], + lat: arr[1], + }, + }; + callback(res); + return; + } + } + + // 2. 再尝试浏览器 + if (navigator.geolocation) { + console.log('使用浏览器获取定位'); + navigator.geolocation.getCurrentPosition( + (position) => { + const { latitude, longitude } = position.coords; + let res = { + code: 200, + data: { + lng: longitude, + lat: latitude, + }, + }; + callback(res); + }, + (error) => { + console.log('定位失败: ' + error.message); + getQueryLand().then(callback); + }, + { enableHighAccuracy: true, timeout: 10000 } + ); + return; + } + + // 最后使用地区坐标 + console.log('使用地区坐标定位'); + getQueryLand().then(callback); + }, //地图查看 pointPaceCountryDarw() { //加载地图编辑 @@ -337,6 +389,26 @@ that.formSubmit(); } }); + $("#" + this.locationMap).click(function () { + that.getCurrentLocation(res => { + if (res.code == 200) { + let lat = res.data.lat; + let lng = res.data.lng; + if(lat && lng){ + Zb = [lng,lat]; + }else { + Zb =[115.452752, 31.789033]; + } + map.getView().animate({ + // 只设置需要的属性即可 + center: ol.proj.fromLonLat(Zb), // 中心点 + zoom: 18, // 缩放级别 + rotation: undefined, // 缩放完成view视图旋转弧度 + duration: 1000, // 缩放持续时间,默认不需要设置 + }); + } + }); + }); } else{ this.closeMoule = null; @@ -368,7 +440,7 @@ //获取坐标是否存在 var Zb; //开始定位当前位置 - getQueryLand().then(res => { + this.getCurrentLocation(res => { if (res.code == 200) { let lat = res.data.lat; let lng = res.data.lng; @@ -519,6 +591,26 @@ that.closeMoule = null; that.formSubmit(); }); + $("#" + this.locationMap).click(function () { + that.getCurrentLocation(res => { + if (res.code == 200) { + let lat = res.data.lat; + let lng = res.data.lng; + if(lat && lng){ + Zb = [lng,lat]; + }else { + Zb =[115.452752, 31.789033]; + } + map.getView().animate({ + // 只设置需要的属性即可 + center: ol.proj.fromLonLat(Zb), // 中心点 + zoom: 18, // 缩放级别 + rotation: undefined, // 缩放完成view视图旋转弧度 + duration: 1000, // 缩放持续时间,默认不需要设置 + }); + } + }); + }); } }, }, diff --git a/src/components/common/Selector.vue b/src/components/common/Selector.vue new file mode 100644 index 00000000..5bd960ef --- /dev/null +++ b/src/components/common/Selector.vue @@ -0,0 +1,219 @@ + + + + + + diff --git a/src/views/sunVillage_info/fixedAssets.vue b/src/views/sunVillage_info/fixedAssets.vue index bcfd602c..ee13bfd5 100644 --- a/src/views/sunVillage_info/fixedAssets.vue +++ b/src/views/sunVillage_info/fixedAssets.vue @@ -8,8 +8,12 @@
- - + + + +
共{{listLength}}个资产
@@ -85,9 +89,11 @@ } from "@/api/sunVillage_info/fixedAssets"; import request from '@/utils/request' import MapGisTag from "@/components/Map/MapGisTagDTGCopy"; + import Selector from "@/components/common/Selector.vue"; export default { name: "certificateList", components: { + Selector, MapGisTag }, data() { @@ -107,6 +113,7 @@ orderByColumn:'createTime', isAsc:'desc', name:'', + operationType: null, }, uploadFiles1:[], projectId:'', @@ -117,6 +124,8 @@ listMap:0, permanentId: null, // 固定资产ID permanents: [], // 固定资产列表,存储本账套下所有的固定资产信息 + typeVisible: false, + operation_type: [], }; }, created() { @@ -129,6 +138,9 @@ this.houseGetDicts("use_type").then((response) => { this.useTypeOptions = response.data; }); + this.houseGetDicts("operation_type").then((response) => { + this.operation_type = response.data; + }); }, methods: { openMap(id, theGeom,index){ @@ -288,7 +300,23 @@ goAdd(){ this.$router.push('/sunVillage_info/fixedAssetsAdd') }, + openAssetType() { + this.typeVisible = true; + }, + refresh() { + this.queryParams.pageNum = 1; + this.listLength = 0; + this.applicationList = []; + this.finished = false; + this.getList(); + }, }, + computed: { + searchPlaceholder() { + let typeName = this.operation_type.find((x) => x.dictValue == this.queryParams.operationType); + return '搜索' + (typeName ? `${typeName.dictLabel}资产` : ''); + }, + } }