xm-audit-worldmap.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div :class="$style.mapBox">
  3. <div
  4. id="map"
  5. style="position: relative; width: 100%; height: 1200px; padding: 0; margin: 0; cursor: default; border-width: 0;"
  6. >
  7. </div>
  8. <div id="map1">
  9. <span
  10. ref="clickSpan"
  11. style="position: absolute; top: 105px; right: 80px;font-size:14px;font-weight:bold;color:#00C;text-decoration: underline; cursor: pointer;"
  12. >查看审计覆盖情况</span
  13. >
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import * as echarts from 'echarts'
  19. import 'echarts/lib/chart/map'
  20. import 'echarts/map/js/world.js'
  21. import geoCoordMap from './world.json'
  22. import MapService from './map-service.js'
  23. import world from 'echarts/map/json/world.json'
  24. import components from './_import-components/xm-audit-worldmap-import'
  25. function fngetcolor(content) {
  26. let color = 'green' // 审计已有1年的单位
  27. if (content === '1年及以上未审计') {
  28. color = 'red'
  29. } else if (content === '当年已审计') {
  30. color = 'green'
  31. }
  32. // else if (content === '2年审计') {
  33. // color = 'blue' // 审计已有2年的单位
  34. // } else if (content === '3年审计') {
  35. // color = '#EEEE00' // 审计已有2年的单位
  36. // } else if (content === '4年审计') {
  37. // color = '#FFA500' // 审计已有4年的单位
  38. // }
  39. return color
  40. }
  41. window.fngetcolor = fngetcolor
  42. var bl = 1
  43. export default {
  44. name: 'XmAuditWorldmap2',
  45. metaInfo: {
  46. title: '审计世界地图',
  47. },
  48. data() {
  49. return {
  50. sfbl: 1,
  51. dataList: [],
  52. // showgj: [
  53. // { name: '北京', value: [116.46, 39.92] }, // 以北京为例,设置初始化坐标
  54. // ],
  55. showgj: [
  56. '俄罗斯',
  57. '加拿大',
  58. '中国',
  59. '美国',
  60. '巴西',
  61. '澳大利亚',
  62. '印度',
  63. '阿根廷',
  64. '哈萨克斯坦',
  65. '阿尔及利亚刚果民主共和国',
  66. '沙特',
  67. '墨西哥',
  68. '印尼',
  69. '苏丹',
  70. '利比亚',
  71. '伊朗',
  72. '蒙古',
  73. '南非',
  74. '埃塞俄比亚',
  75. '埃及',
  76. '坦桑尼亚',
  77. '尼日利亚',
  78. '委内瑞拉',
  79. '巴基斯坦',
  80. '土耳其',
  81. '智利',
  82. '缅甸',
  83. '阿富汗',
  84. '法国',
  85. '南苏丹',
  86. '乌克兰',
  87. '泰国',
  88. '西班牙',
  89. '斯里兰卡',
  90. '印度尼西亚',
  91. '科特迪瓦',
  92. '纳米比亚',
  93. '日本',
  94. '德国',
  95. '几内亚',
  96. ],
  97. }
  98. },
  99. mounted() {
  100. // 初始化地图
  101. this.getList()
  102. this.$refs.clickSpan.addEventListener('click', this.handleClick)
  103. },
  104. methods: {
  105. handleClick() {
  106. // 处理点击 查看审计覆盖情况
  107. const now = new Date()
  108. const year = now.getFullYear()
  109. const param = {}
  110. param.type = 'gw'
  111. param.name = '境外'
  112. window.open(
  113. '#/xm-audit-mapcoverage-list?params=' +
  114. encodeURIComponent(JSON.stringify(param)) +
  115. '&year=' +
  116. year
  117. )
  118. },
  119. getList() {
  120. MapService.getWorldData().then((res) => {
  121. this.dataList = res.data
  122. this.initEchart()
  123. })
  124. },
  125. convertData(data, type) {
  126. // debugger
  127. var res = []
  128. for (var i = 0; i < data.length; i++) {
  129. // var geoCoord = geoCoordMap.mapregion[data[i].name]
  130. var geoCoord = ''
  131. var name = ''
  132. if (data[i].name) {
  133. var list = geoCoordMap.mapregion
  134. for (const key in list) {
  135. if (data[i].name.indexOf(key) !== -1) {
  136. name = key
  137. geoCoord = geoCoordMap.mapregion[key]
  138. break
  139. }
  140. }
  141. }
  142. if (geoCoord) {
  143. if (type === data[i].type) {
  144. res.push({
  145. name: data[i].name,
  146. value: geoCoord.concat(data[i].value),
  147. type: geoCoord.concat(data[i].type),
  148. })
  149. }
  150. }
  151. }
  152. return res
  153. },
  154. initEchart() {
  155. const dataList = this.dataList
  156. const gj = this.showgj
  157. const _this = this
  158. var myChart = echarts.init(document.getElementById('map'))
  159. echarts.registerMap('world', world)
  160. var option = {
  161. legend: {
  162. show: true,
  163. right: 20,
  164. top: 20,
  165. orient: 'vertical',
  166. },
  167. tooltip: {
  168. axisPointer: {
  169. type: 'shadow',
  170. },
  171. enterable: true,
  172. // alwaysShowContent: true, // 永远显示
  173. confine: false,
  174. position: 'right',
  175. backgroundColor: '#fff', // 提示浮窗背景颜色
  176. borderColor: 'rgba(0, 0, 0, 0.16);',
  177. borderWidth: 1,
  178. extraCssText: 'width:350px',
  179. // 数据格式化
  180. formatter: function(params, callback) {
  181. console.log(params)
  182. var result = ''
  183. //
  184. result += `<div><div style="width:15px;" id='pic' class="chinamappictp"></div><div><span style="color:#000;font-size:20px;font-weight:bold;margin:0 2px;margin-bottom:10px;">${params.data.name}</span><span style="float:right;color:#000;font-size:20px;margin-right:2px;margin-left:10px;">${params.value[2].year}</span></div>`
  185. for (var i = 0; i < params.value[2].datas.length; i++) {
  186. let title = params.value[2].datas[i].name
  187. if (title.length > 10) {
  188. title = title.substring(0, 25) + '...'
  189. }
  190. result += `<div style="margin: 0 2px;" class="mapdivchina"><span style="color:gray" title="${params.value[2].datas[i].name}">${title}</span>`
  191. const color = fngetcolor(params.value[2].datas[i].level)
  192. result += `<span style="float:right;color:${color};margin-right:2px;margin-left:10px;">${params.value[2].datas[i].level}`
  193. if (params.value[2].datas[i].dataList) {
  194. result += ` <i class="qrm-arrow-right" onclick="fnshowdiv('${params.value[2].datas[
  195. i
  196. ].name +
  197. '_' +
  198. i.toString()}')" ></i>`
  199. }
  200. result += `</span>`
  201. if (params.value[2].datas[i].dataList) {
  202. result += `<div id="mapdiv_${params.value[2].datas[i].name +
  203. '_' +
  204. i.toString()}" class="mapdivchinazitem" > `
  205. for (var j = 0; j < params.value[2].datas[i].dataList.length; j++) {
  206. const item = params.value[2].datas[i].dataList[j]
  207. let ztitle = item.name
  208. if (ztitle.length > 10) {
  209. ztitle = ztitle.substring(0, 10) + '...'
  210. }
  211. result += `<div style="margin: 0 2px;"><span style="color:gray" title="${item.name}">${ztitle}</span>`
  212. const itemcolor = fngetcolor(item.level)
  213. result += `<span style="float:right;color:${color};margin-right:2px;margin-left:10px;">${item.level}`
  214. result += `</span></div>`
  215. }
  216. result += ` </div>`
  217. }
  218. result += `</div>`
  219. }
  220. result += `</div> `
  221. return result
  222. },
  223. },
  224. nameMap: geoCoordMap.nameMap,
  225. geo: {
  226. map: 'world',
  227. roam: true,
  228. zoom: 2,
  229. label: {
  230. normal: {
  231. show: true, // 是否显示对应地名
  232. textStyle: {
  233. color: '#1a1112',
  234. },
  235. formatter: function(params) {
  236. if (gj.find((i) => i === params.name)) {
  237. return params.name
  238. } else {
  239. return ''
  240. }
  241. },
  242. },
  243. emphasis: {
  244. // 对应的鼠标悬浮效果
  245. show: false,
  246. textStyle: {
  247. color: '#1a1112',
  248. },
  249. },
  250. },
  251. itemStyle: {
  252. normal: {
  253. areaColor: '#f7f7f7',
  254. borderColor: '#f01010',
  255. },
  256. emphasis: {
  257. borderWidth: 1,
  258. areaColor: '#f7f7f7',
  259. borderColor: '#f01010',
  260. },
  261. },
  262. center: [101.681865, 3.136134], // 设置地图中心点的坐标
  263. },
  264. backgroundColor: '#b3cefd',
  265. series: [
  266. {
  267. // name: '1年未审计单位',
  268. name: '当年已审计单位',
  269. type: 'effectScatter',
  270. coordinateSystem: 'geo',
  271. data: this.convertData(dataList, 4),
  272. symbolSize: function(val) {
  273. return 8
  274. },
  275. encode: {
  276. value: 2,
  277. },
  278. showEffectOn: 'render',
  279. rippleEffect: {
  280. brushType: 'stroke',
  281. },
  282. hoverAnimation: true,
  283. label: {
  284. formatter: '{b}',
  285. position: 'right',
  286. show: false,
  287. },
  288. itemStyle: {
  289. color: 'green',
  290. shadowBlur: 20,
  291. },
  292. tooltip: {
  293. // 提示框样式
  294. backgroundColor: '#fff', // 提示浮窗背景颜色
  295. borderColor: 'rgba(0, 0, 0, 0.16);',
  296. borderWidth: 1,
  297. extraCssText: 'width:500px;box-shadow: 0 0 5px #008aff;',
  298. },
  299. },
  300. {
  301. // name: '审计未覆盖单位',
  302. name: '1年及以上未审计单位',
  303. type: 'scatter',
  304. coordinateSystem: 'geo',
  305. symbol: 'circle',
  306. symbolSize: 12,
  307. tooltip: {
  308. // 提示框样式
  309. backgroundColor: '#fff', // 提示浮窗背景颜色
  310. borderColor: 'rgba(0, 0, 0, 0.16);',
  311. borderWidth: 1,
  312. extraCssText: 'width:500px;box-shadow: 0 0 5px #008aff;',
  313. },
  314. itemStyle: {
  315. color: 'red',
  316. },
  317. data: this.convertData(dataList, 2),
  318. },
  319. // {
  320. // name: '2年未审计单位',
  321. // type: 'effectScatter',
  322. // coordinateSystem: 'geo',
  323. // data: this.convertData(dataList, 2),
  324. // symbolSize: function(val) {
  325. // return 8
  326. // },
  327. // encode: {
  328. // value: 2,
  329. // },
  330. // showEffectOn: 'render',
  331. // rippleEffect: {
  332. // brushType: 'stroke',
  333. // },
  334. // hoverAnimation: true,
  335. // label: {
  336. // formatter: '{b}',
  337. // position: 'right',
  338. // show: false,
  339. // },
  340. // itemStyle: {
  341. // color: 'blue',
  342. // shadowBlur: 20,
  343. // },
  344. // tooltip: {
  345. // // 提示框样式
  346. // backgroundColor: '#fff', // 提示浮窗背景颜色
  347. // borderColor: 'rgba(0, 0, 0, 0.16);',
  348. // borderWidth: 1,
  349. // extraCssText: 'width:300px;box-shadow: 0 0 5px #008aff;',
  350. // },
  351. // },
  352. ],
  353. }
  354. myChart.setOption(option)
  355. const chart = echarts.init(document.getElementById('map'))
  356. chart.on('georoam', function(params) {
  357. var option = chart.getOption() // 获得option对象
  358. if (params.zoom) {
  359. bl = bl * params.zoom
  360. if (bl > 3) {
  361. option.geo[0].label.formatter = function(params) {
  362. return params.name
  363. }
  364. chart.setOption(option) // 设置option
  365. } else {
  366. option.geo[0].label.formatter = function(params) {
  367. if (gj.find((i) => i === params.name)) {
  368. return params.name
  369. } else {
  370. return ''
  371. }
  372. }
  373. chart.setOption(option) // 设置option
  374. }
  375. }
  376. })
  377. },
  378. // sortChnage() {
  379. // this.getList('sort')
  380. // },
  381. },
  382. }
  383. </script>
  384. <style module lang="scss">
  385. @use '@/common/design' as *;
  386. .mapBox {
  387. height: 100%;
  388. // position: relative;
  389. margin-top: 20px;
  390. background: #b3cefd;
  391. }
  392. .mapTableBox {
  393. position: absolute;
  394. right: 10px;
  395. bottom: 10px;
  396. width: 420px;
  397. padding: 10px;
  398. border: 1px solid #02f6f9;
  399. border-radius: 5px;
  400. box-shadow: 0 0 10px 5px #02f6f9;
  401. }
  402. .sort {
  403. float: right;
  404. margin-bottom: 10px;
  405. }
  406. .mapTableBox thead {
  407. color: #fff !important;
  408. }
  409. .mapTableBox .el-table {
  410. color: #fff !important;
  411. background-color: transparent !important;
  412. }
  413. .mapTableBox .el-table__header-wrapper th {
  414. background-color: rgba(2, 77, 186, 1) !important;
  415. }
  416. .mapTableBox tbody tr {
  417. background-color: #091e64 !important;
  418. }
  419. .mapTableBox .el-table__row--striped td {
  420. background-color: rgba(2, 77, 186, 1) !important;
  421. }
  422. .mapTableBox .el-table th.is-leaf,
  423. .mapTableBox .el-table td {
  424. border: none !important;
  425. }
  426. .mapTableBox .el-table::before {
  427. display: none !important;
  428. }
  429. .mapTableBox .el-table--enable-row-hover .el-table__body tr:hover > td {
  430. background-color: #091e64;
  431. }
  432. .mapTableBox .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  433. background-color: rgba(2, 77, 186, 1) !important;
  434. border-color: rgba(2, 77, 186, 1) !important;
  435. box-shadow: -1px 0 0 0 rgba(2, 77, 186, 1) !important;
  436. box-shadow: -1px 0 0 0 rgba(2, 77, 186, 1) !important;
  437. }
  438. :global .worldmappictp {
  439. top: 0;
  440. float: left;
  441. width: 20px !important;
  442. height: 20px !important;
  443. background-color: initial !important;
  444. background-image: url('./dtb.png');
  445. background-repeat: no-repeat;
  446. background-position-x: center;
  447. background-position-y: center;
  448. background-size: 100%;
  449. border: none !important;
  450. }
  451. :global .qrm-arrow-right {
  452. // position: absolute;
  453. // top: 14px;
  454. // right: 7px;
  455. display: inline-block;
  456. width: 8px;
  457. height: 10px;
  458. background: url('./right.png') no-repeat;
  459. background-color: initial !important;
  460. background-position-x: center;
  461. background-position-y: center;
  462. background-size: 100%;
  463. }
  464. :global .mapdivchina span {
  465. height: 30px;
  466. font-size: 18px;
  467. line-height: 30px;
  468. }
  469. :global .mapdivchinazitem span {
  470. height: 30px;
  471. font-size: 18px;
  472. line-height: 30px;
  473. }
  474. :global .mapdivchinazitem {
  475. position: absolute;
  476. left: 500px;
  477. display: none;
  478. width: 300px;
  479. background-color: #fff;
  480. border: 1px solid rgba(0, 0, 0, 0.16);
  481. box-shadow: rgb(0, 138, 255) 0 0 5px;
  482. }
  483. :global .mapdivchina:hover {
  484. .mapdivchinazitem {
  485. display: inline;
  486. }
  487. }
  488. </style>