9de73279e06bd17852a8da091aa23509b7f80d93.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="map3D" id="map3D">
  3. </div>
  4. </template>
  5. <script>
  6. import echarts from "echarts";
  7. import '@util/echarts-gl.min.js';
  8. import axios from 'axios' //引入axios
  9. import {formatDate} from "@util/gw_date.js"
  10. import { hostUrl } from "@util/global_variable.js";
  11. import {
  12. getPblmProAll,
  13. getUserById
  14. } from "../../api/homeMainView.js";
  15. export default {
  16. components: {
  17. },
  18. props: [],
  19. data() {
  20. //这里存放数据
  21. return {
  22. chart1:null,
  23. currentOrgNm:"",
  24. currentRlcode:"",
  25. currentOrgId:"",
  26. //地图数据
  27. chartMapData:{
  28. mapPercent:[],
  29. geoCoordMap:{},
  30. geoCoordMapList:[],
  31. }
  32. }
  33. },
  34. //监听属性 类似于data概念
  35. computed: {
  36. formatDateTime() {
  37. return formatDate
  38. },
  39. hostUrl(){
  40. return hostUrl
  41. },
  42. organNm() {
  43. return this.currentOrgNm;
  44. },
  45. organCode() {
  46. return this.currentRlcode;
  47. }
  48. },
  49. //监控data中的数据变化
  50. watch: {
  51. },
  52. //生命周期 - 创建完成(可以访问当前this实例)
  53. created() {
  54. },
  55. //生命周期 - 挂载完成(可以访问DOM元素)
  56. mounted() {
  57. var _self = this;
  58. this.getPerson();
  59. this.$nextTick(function () {
  60. var _self = this;
  61. window.onresize = function() {
  62. _self.resizeCharts();
  63. }
  64. });
  65. },
  66. //方法集合
  67. methods: {
  68. GetQueryString(name) {
  69. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  70. var r = window.location.search.substr(1).match(reg);
  71. if (r != null) return unescape(r[2]); return null;
  72. },
  73. getPerson(){
  74. var _self = this;
  75. var persId = this.GetQueryString("userid");
  76. getUserById(persId).then((res) => {
  77. if(res.data){
  78. _self.currentOrgId = res.data.defaultOrg.orgId;
  79. _self.currentRlcode = res.data.defaultOrg.rlcode;
  80. _self.currentOrgNm = res.data.defaultOrg.orgNm;
  81. this.initData();
  82. }
  83. });
  84. },
  85. resizeCharts(){
  86. this.chart1.resize();
  87. },
  88. toVal(val){
  89. if(val!=null && val!=""){
  90. return val.toFixed(2)
  91. }
  92. return 0;
  93. },
  94. initData(){
  95. var _self = this;
  96. _self.chartMapData.mapPercent = [];
  97. _self.chartMapData.geoCoordMap = [];
  98. _self.chartMapData.geoCoordMapList = [];
  99. getPblmProAll({timeType:"5",objType:"",orgId:this.currentOrgId}).then((res) => {
  100. if(res.data!=null && res.data.length>0){
  101. for(var i = 0;i<res.data.length;i++){
  102. if(res.data[i].adName!="合计"){
  103. _self.chartMapData.geoCoordMap[res.data[i].adName] = [res.data[i].lgtd,res.data[i].lttd];
  104. _self.chartMapData.geoCoordMapList.push({
  105. name:res.data[i].adName,
  106. value:res.data[i].pblmSize
  107. });
  108. }
  109. }
  110. }
  111. _self.initChart1();
  112. });
  113. },
  114. initAddVcdFeatures(){
  115. let geoJsonName = this.organCode.substr(0, 6) + ".json";
  116. return axios.get('/src/assets/addvGeoData/' + geoJsonName);
  117. },
  118. async initChart1() {
  119. var _self = this;
  120. var convertData = function () {
  121. var res = [];
  122. for (var i = 0; i < _self.chartMapData.geoCoordMapList.length; i++) {
  123. var geoCoord = _self.chartMapData.geoCoordMap[_self.chartMapData.geoCoordMapList[i].name];
  124. if (geoCoord) {
  125. res.push({
  126. name: _self.chartMapData.geoCoordMapList[i].name,
  127. value: geoCoord.concat(_self.chartMapData.geoCoordMapList[i].value)
  128. });
  129. }
  130. }
  131. return res;
  132. };
  133. this.chart1 = echarts.init(document.getElementById('map3D'));
  134. var jsonAddvcd = await this.initAddVcdFeatures();
  135. echarts.registerMap(this.organNm, jsonAddvcd.data);
  136. let option = {
  137. title:{
  138. text:(this.currentOrgId=='041'?'全国各省':this.currentOrgNm)+(this.organCode.substr(0, 2)=="66"?'各师问题数量分布':'各市问题数量分布'),
  139. left:'center',
  140. padding: 20,
  141. textStyle:{
  142. color:'rgb(62,215,213)',
  143. }
  144. },
  145. tooltip: {
  146. trigger: 'axis',
  147. },
  148. geo3D: {
  149. map: this.organNm,
  150. show: true,
  151. zlevel: 15,
  152. boxWidth:80,
  153. boxHeight:30,
  154. label: {
  155. show:true,
  156. formatter:function(params){
  157. var content='',
  158. content=params.name;
  159. return content;
  160. },
  161. distance:0,
  162. textStyle:{
  163. color:'#ffffff',
  164. fontWeight : 'bold',
  165. fontSize :17,
  166. backgroundColor: 'rgba(255,255,255,0)'
  167. },
  168. },
  169. viewControl: { // 用于鼠标的旋转,缩放等视角控制。
  170. distance: 100, // [ default: 100 ] 默认视角距离主体的距离,对于 grid3D 和 geo3D 等其它组件来说是距离中心原点的距离,对于 globe 来说是距离地球表面的距离。在 projection 为'perspective'的时候有效。
  171. minDistance: 40, // [ default: 40 ] 视角通过鼠标控制能拉近到主体的最小距离。在 projection 为'perspective'的时候有效。
  172. maxDistance: 400, // [ default: 400 ] 视角通过鼠标控制能拉远到主体的最大距离。在 projection 为'perspective'的时候有效。
  173. alpha: 40, // 视角绕 x 轴,即上下旋转的角度。配合 beta 可以控制视角的方向。[ default: 40 ]
  174. beta: 15, // 视角绕 y 轴,即左右旋转的角度。[ default: 0 ]
  175. minAlpha: -360, // 上下旋转的最小 alpha 值。即视角能旋转到达最上面的角度。[ default: 5 ]
  176. maxAlpha: 360, // 上下旋转的最大 alpha 值。即视角能旋转到达最下面的角度。[ default: 90 ]
  177. minBeta: -360, // 左右旋转的最小 beta 值。即视角能旋转到达最左的角度。[ default: -80 ]
  178. maxBeta: 360, // 左右旋转的最大 beta 值。即视角能旋转到达最右的角度。[ default: 80 ]
  179. center: [0,0,0], // 视角中心点,旋转也会围绕这个中心点旋转,默认为[0,0,0]。
  180. animation: true, // 是否开启动画。[ default: true ]
  181. animationDurationUpdate: 1000, // 过渡动画的时长。[ default: 1000 ]
  182. animationEasingUpdate: 'cubicInOut' // 过渡动画的缓动效果。[ default: cubicInOut ]
  183. },
  184. light: {
  185. main: {
  186. shadow: true,
  187. shadowQuality: 'ultra',
  188. },
  189. },
  190. //地面的背景颜色
  191. groundPlane: {
  192. show: true,
  193. color:'transparent'
  194. },
  195. //特效设置
  196. postEffect: {
  197. enable:false
  198. },
  199. itemStyle: {
  200. areaColor: '#1b4474',
  201. color:'#1b4474',
  202. borderColor: 'rgb(62,215,213)',
  203. borderWidth: 1
  204. },
  205. //鼠标 hover 高亮时图形和标签的样式
  206. emphasis:{
  207. label:{
  208. show:true,
  209. distance:10
  210. },
  211. itemStyle: {
  212. color:'#15244a',
  213. }
  214. }
  215. },
  216. series: [
  217. {
  218. type: 'bar3D',
  219. coordinateSystem: 'geo3D',
  220. zlevel: 1,
  221. barSize: 0.5,
  222. shading: 'lambert',
  223. itemStyle: {
  224. color: '#c2f151'
  225. },
  226. label: {
  227. show: true,
  228. position: 'top',
  229. textStyle: {
  230. color: '#c2f151',
  231. backgroundColor: 'transparent'
  232. },
  233. formatter: function(params) {
  234. return params.value[2]
  235. }
  236. },
  237. data:convertData()
  238. }
  239. ]
  240. };
  241. this.chart1.clear()
  242. this.chart1.setOption(option);
  243. }
  244. },
  245. beforeCreate() {
  246. }, //生命周期 - 创建之前
  247. beforeMount() {
  248. }, //生命周期 - 挂载之前
  249. beforeUpdate() {
  250. }, //生命周期 - 更新之前
  251. updated() {
  252. }, //生命周期 - 更新之后
  253. beforeDestroy() {
  254. }, //生命周期 - 销毁之前
  255. destroyed() {
  256. }, //生命周期 - 销毁完成
  257. activated() {
  258. } //如果页面有keep-alive缓存功能,这个函数会触发
  259. };
  260. </script>
  261. <style>
  262. .map3D{
  263. width: 100%;
  264. height:100%;
  265. background: url("../../assets/bjdc.png") no-repeat;
  266. background-size: 100% 100%;
  267. }
  268. </style>