From 15d1502699e6c7d5cc6cfc5e4abd26e51bad726e Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Mon, 24 Jul 2023 16:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/wgs84.js | 64 ++++++++ src/views/component/imports.vue | 18 ++- src/views/jsc/components/echartsMap.vue | 197 ++++++++++++++++-------- src/views/record/map.vue | 65 ++++---- src/views/record/personinfo.vue | 14 +- 5 files changed, 262 insertions(+), 96 deletions(-) create mode 100644 src/utils/wgs84.js diff --git a/src/utils/wgs84.js b/src/utils/wgs84.js new file mode 100644 index 0000000..bdee21d --- /dev/null +++ b/src/utils/wgs84.js @@ -0,0 +1,64 @@ +// 定义一些常量 +const x_PI = 3.14159265358979324 * 3000.0 / 180.0 +const PI = 3.1415926535897932384626 +const a = 6378245.0 // 卫星椭球坐标投影到平面地图坐标系的投影因子 +const ee = 0.00669342162296594323 // 椭球的偏心率 + +/** + * GCJ02(火星坐标系) 转换为 WGS84 / 即谷歌高德转WGS84 + * @param { Number } lng + * @param { Number } lat + */ +export function gcj02towgs84(lng, lat) { + if (outOfChina(lng, lat)) { + return [lng, lat] + } else { + var dlat = transformlat(lng - 105.0, lat - 35.0) + var dlng = transformlng(lng - 105.0, lat - 35.0) + var radlat = lat / 180.0 * PI + var magic = Math.sin(radlat) + magic = 1 - ee * magic * magic + var sqrtmagic = Math.sqrt(magic) + dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI) + dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI) + const mglat = lat + dlat + const mglng = lng + dlng + return [lng * 2 - mglng, lat * 2 - mglat] + } +} + +/** + * 经度转换 + * @param { Number } lng + * @param { Number } lat + */ +function transformlat(lng, lat) { + var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)) + ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0 + ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0 + ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0 + return ret +} + +/** + * 纬度转换 + * @param { Number } lng + * @param { Number } lat + */ +function transformlng(lng, lat) { + var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)) + ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0 + ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0 + ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0 + return ret +} + +/** + * 判断是否在国内,不在国内则不做偏移 + * @param {*} lng + * @param {*} lat + */ +function outOfChina(lng, lat) { + return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false) +} + diff --git a/src/views/component/imports.vue b/src/views/component/imports.vue index 00cca11..d681f00 100644 --- a/src/views/component/imports.vue +++ b/src/views/component/imports.vue @@ -62,6 +62,9 @@ export default { table: [], }; }, + created() { + console.log("path",this.$route.path) + }, methods: { getToken, show() { @@ -104,6 +107,16 @@ export default { }, imports() { + // tab:1,2 1是新增,2是台账 + let paths = this.$route.path; + let isBook = paths.split("_")[0] + console.log(isBook) + if(isBook=='/book'){ + for(var k of this.tableList){ + k.isBook = true + } + } + // return imports({ table_name: this.tableName, data: this.tableList @@ -113,9 +126,10 @@ export default { type: 'success', message: `成功导入${res.total}条` }) + this.hidden(); + this.$emit('refresh') }) - this.hidden(); - this.$emit('refresh') + } }, computed: {}, diff --git a/src/views/jsc/components/echartsMap.vue b/src/views/jsc/components/echartsMap.vue index cd4e863..f46c691 100644 --- a/src/views/jsc/components/echartsMap.vue +++ b/src/views/jsc/components/echartsMap.vue @@ -7,17 +7,17 @@ import * as echarts from 'echarts'; import jtmap from './jtmap.json'; - export default { - props:{ - mapData:{ - type:Array, - default:[] - } + export default { + props: { + mapData: { + type: Array, + default: [] + } }, data() { return { myChart: null, - hookToolTip: {}, + hookToolTip: {}, // mapData:[] } }, @@ -41,18 +41,23 @@ }, }, methods: { - showInfo(id) { - this.$router.push({path:"/record/personinfo",query:{id:id}}) + showInfo(id) { + this.$router.push({ + path: "/record/personinfo", + query: { + id: id + } + }) }, resetCharts() { this.myChart.resize() }, drawChart() { - let that = this - this.mapData.forEach((m,index)=>{ - if(!m.coord){ - m.coord = ['',''] - } + let that = this + this.mapData.forEach((m, index) => { + if (!m.coord) { + m.coord = ['', ''] + } }) // 基于准备好的dom,初始化echarts实例 this.myChart = echarts.init(document.getElementById('chart')) @@ -70,75 +75,135 @@ if (!val.data) { return } - return '

' + val.data.name + '

查看详情

' + return '

' + val.data.name + + '

查看详情

' } }, - series: [{ - map: 'china', - type: 'map', - map: 'GX', - // aspectScale: 0.9, - roam: false, - + geo: { + map: "GX", + roam: false, //不开启缩放和平移 + zoom: 1.23, //视角缩放比例 label: { - show: true, - textStyle: { - color: '#fff', - fontSize: 12, - } + normal: { + show: false, + fontSize: "0", + color: "rgba(0,0,0,0.7)", + }, }, - itemStyle: { normal: { - borderColor: '#0AAEB0', // 图形的描边颜色 #0AAEB0 - borderWidth: 1, // 描边线宽。 - borderType: 'solid', // 柱条的描边类型。 - areaColor: '#2378f7', // 图形的颜色 #233F53 - shadowBlur: 5, // 图形阴影的模糊大小。 - shadowColor: '#2378f7', // 阴影色 #233F53 - shadowOffsetX: 5, // X轴阴影 - shadowOffsetY: 5, // Y轴阴影 - - label: { - show: false, // 显示区域名称 - textStyle: { - color: '#fff', - fontSize: 12, - }, - } + borderColor: "rgba(0, 0, 0, 0.2)", }, - // 鼠标移入时 emphasis: { - borderColor: '#fff', // 图形的描边颜色 #2378f7 - borderWidth: '1', - areaColor: '#2378f7', // 阴影色 #233F53 - label: { - show: false, - textStyle: { - color: '#fff', - fontSize: 14, - } - } + // areaColor: "#F3B329", //鼠标选择区域颜色 + shadowOffsetX: 0, + shadowOffsetY: 0, + shadowBlur: 20, + borderWidth: 0, + shadowColor: "rgba(0, 0, 0, 0.5)", }, - regions: [{ + }, + // data:this.dataList + + regions: [ + //对不同的区块进行着色 + { + name: "开发区", + itemStyle: { + normal: { + areaColor: "#75bedc", + }, + emphasis: { + areaColor: "#75bedc", + }, + }, + }, + { name: "指前镇", itemStyle: { normal: { - areaColor: "red", + areaColor: "#d7335a", }, emphasis: { - areaColor: "red", + areaColor: "#d7335a", }, }, - }], + }, + { + name: "朱林镇", + itemStyle: { + normal: { + areaColor: "#fc8251", + }, + emphasis: { + areaColor: "#fc8251", + }, + }, + }, + { + name: "直溪镇", + itemStyle: { + normal: { + areaColor:'#91cd77', + }, + emphasis: { + areaColor:'#91cd77', + }, + }, + }, + { + name: "薛埠镇", + itemStyle: { + normal: { + areaColor:'#ef6567', + }, + emphasis: { + areaColor:'#ef6567', + }, + }, + }, + { + name: "金城镇", + itemStyle: { + normal: { + areaColor:'#f9c956', + }, + emphasis: { + areaColor:'#f9c956', + }, + }, + }, + { + name: "儒林镇", + itemStyle: { + normal: { + areaColor:'#c968e1', + }, + emphasis: { + areaColor:'#c968e1', + }, + }, + }, + { + name: "尧塘镇", + itemStyle: { + normal: { + areaColor:'#00ffff', + }, + emphasis: { + areaColor:'#00ffff', + }, + }, + }, - effect: { - show: true, - shadowBlur: 10, - loop: true, - } - }, + ] + }, + series: [{ + name: "一户一档", + type: "map", + mapType: "china", + geoIndex: 0, markPoint: { symbol: 'image://' + require('@/assets/logo-mini.png'), // 自定义图片路径 symbolSize: [50, 40], // 图片大小 @@ -159,7 +224,7 @@ // coord数组存放地址坐标 data: this.mapData } - }] + }], }) } diff --git a/src/views/record/map.vue b/src/views/record/map.vue index 8ce650c..f0c20d8 100644 --- a/src/views/record/map.vue +++ b/src/views/record/map.vue @@ -47,11 +47,13 @@ getparameter } from "@/api/system/dictionary"; import { - index + index, + save } from "@/api/system/baseForm.js" import { Message - } from 'element-ui' + } from 'element-ui' + export default { data() { return { @@ -193,7 +195,8 @@ // 增加点位 setMapMarker() { var that = this - + // console.log("123",m.longitude, m.latitude) + // console.log('456',gcj02towgs84(m.longitude, m.latitude)) that.map.remove(that.makerList) that.makerList = [] // this.map.clearMap(); @@ -354,30 +357,40 @@ // return this.mapList = _data var geocoder = null - let that = this - AMap.plugin("AMap.Geocoder", function() { - geocoder = new AMap.Geocoder({ - city: '常州' // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode - }) - _nolng.map((k, index) => { - geocoder.getLocation(k.reside, function(status, result) { - if (status === 'complete' && result.info === 'OK') { - // result中对应详细地理坐标信息 - k.longitude = result.geocodes[0].location.lng - k.latitude = result.geocodes[0].location.lat - } - if (index == _nolng.length - 1) { - that.mapList.push(..._nolng) - that.setMapMarker() - that.fullscreenLoading = false; - } - }) - - }) - // for (let k of _nolng) { + let that = this + if(_nolng.length>0){ + AMap.plugin("AMap.Geocoder", function() { + geocoder = new AMap.Geocoder({ + city: '常州' // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode + }) + _nolng.map((k, index) => { + geocoder.getLocation(k.reside, function(status, result) { + if (status === 'complete' && result.info === 'OK') { + // result中对应详细地理坐标信息 + k.longitude = result.geocodes[0].location.lng + k.latitude = result.geocodes[0].location.lat + save({ + table_name: that.select.table_name, + ...k + }) + } + if (index == _nolng.length - 1) { + that.mapList.push(..._nolng) + that.setMapMarker() + that.fullscreenLoading = false; + } + }) + + }) + // for (let k of _nolng) { + + // } + }) + }else{ + that.setMapMarker() + that.fullscreenLoading = false; + } - // } - }) // setTimeout(function() { // that.mapList.push(..._nolng) // that.setMapMarker() diff --git a/src/views/record/personinfo.vue b/src/views/record/personinfo.vue index 1200a2c..7b8c0b3 100644 --- a/src/views/record/personinfo.vue +++ b/src/views/record/personinfo.vue @@ -132,8 +132,18 @@ for(var k of res.idcard_workflows_idcard_relation){ if(k.work_status=='通过'){ - console.log(k) - workflows+=`

${k.created_at?.substring(0,10)}/${k.guanlianbiaoming}

` + // 辅具适配 + if(k.guanlianbiao=='assists'){ + workflows+=`

${k.created_at?.substring(0,10)}/${k.guanlianbiaoming}

` + workflows+=`

管理年限:${k.detail.guanlinianxian}

` + workflows+=`

辅具类别:${k.detail.sub_type}

` + workflows+=`

可申请补贴金额:${k.detail.apply_money}

` + workflows+=`

已申请补贴金额:${k.detail.get_money}

` + workflows+=`

结余金额:${k.detail.surplus_money}

` + }else{ + workflows+=`

${k.created_at?.substring(0,10)}/${k.guanlianbiaoming}

` + } + } } }