EchartsMap.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  1. <template>
  2. <div class="EchartsMap" v-if="show">
  3. <div class="chart" ref="middleMap"></div>
  4. <!-- <div class="back" v-show="backShow" @click="backClick">〈 返回</div> -->
  5. </div>
  6. </template>
  7. <script>
  8. import * as echarts from 'echarts'
  9. import 'echarts-gl'
  10. //引入map相关json配置
  11. import mapJson from './mapJson/config.json'
  12. import mainMap from './mapJson/china.json'
  13. import moment from 'moment'
  14. export default {
  15. name: 'EchartsMap',
  16. props: {
  17. show: {}
  18. },
  19. data() {
  20. return {
  21. groupAttr: null,
  22. //项目数据信息
  23. projectChart: null,
  24. mdata: null,
  25. //集团以及区域数据信息
  26. groupChart: null,
  27. mapname: null, //子地图json数据
  28. mapData: [], //地图图上数据
  29. mapBuildingData: [], //地图建管项目
  30. mapEPCData: [], //地图EPC项目
  31. mapSuspendData: [], //地图暂停项目
  32. mapNohandedData: [], //地图未移交项目
  33. isSilent: null, //图形是否不响应和触发鼠标事件
  34. mapDistance: null, //地图视角距离主体的距离
  35. mapBoxWidth: null, //三维地图在三维场景中的宽度
  36. offset: null, //三维地图中心偏移
  37. clickSymbol: null, //地图点击标识,0为区域点击,1为项目点击
  38. domImg: null, //地图背景图片
  39. //
  40. backShow: false,
  41. clickPermissions: false,
  42. //防抖
  43. timeout: null,
  44. //标题栏组件引用
  45. headerComp: null
  46. }
  47. },
  48. computed: {
  49. groupData() {
  50. return this.$store.state.bigScreen.groupProject
  51. },
  52. //区域名称存储
  53. groupName() {
  54. return this.$store.state.bigScreen.groupName
  55. }
  56. },
  57. watch: {
  58. // show: {
  59. // handler(n, o) {
  60. // if (n)
  61. // this.$nextTick(() => {
  62. // this.getData()
  63. // })
  64. // },
  65. // immediate: true
  66. // },
  67. groupData: {
  68. handler(val) {
  69. this.$nextTick(() => {
  70. this.getData()
  71. })
  72. },
  73. deep: true
  74. },
  75. groupName: {
  76. handler(val) {
  77. this.$nextTick(() => {
  78. this.getData()
  79. })
  80. },
  81. deep: true
  82. }
  83. },
  84. mounted() {
  85. this.resizeChart()
  86. },
  87. methods: {
  88. resizeChart() {
  89. //图表大小自适应
  90. window.addEventListener('resize', () => {
  91. this.$nextTick(() => {
  92. this.getData()
  93. })
  94. })
  95. },
  96. debounce(fn, wait) {
  97. if (this.timeout !== null) clearTimeout(this.timeout)
  98. this.timeout = setTimeout(fn, wait)
  99. },
  100. getData() {
  101. this.debounce(() => {
  102. if (!this.$refs.middleMap) return
  103. this.destroyChart()
  104. // if(this.groupAttr!==true){
  105. // this.showWorkArea()
  106. // }else{
  107. // this.composeScanInfo(this.groupInfoData)
  108. // }
  109. this.composeScanInfo(this.groupData)
  110. }, 650)
  111. },
  112. /**
  113. * 项目信息模块
  114. */
  115. //获取工区数据
  116. async showWorkArea() {
  117. let mapData1 = [] //存储未开工信息
  118. let mapData2 = [] //存储在建信息
  119. let mapData3 = [] //存储完工信息
  120. let mapData4 = [] //存储停工信息
  121. let mapDataScan = [] //存储今日扫码信息
  122. const res = await GetBuildAreaStatistic_api({ prjId: this.pData.prjId })
  123. const { code, result } = res.data
  124. if (code === 1) {
  125. let arr = []
  126. result.forEach((item) => {
  127. arr.push(item.builtStatus)
  128. switch (item.builtStatus) {
  129. //无状态情况特殊处理,归于未施工
  130. case null:
  131. mapData1.push({
  132. name: item.zdwName,
  133. value: [item.longitude, item.latitude, 1],
  134. designLength: item.tfPipeLength,
  135. lengthPercentNew: item.lengthPercentNew
  136. })
  137. break
  138. case 1:
  139. mapData1.push({
  140. name: item.zdwName,
  141. value: [item.longitude, item.latitude, 1],
  142. designLength: item.tfPipeLength,
  143. lengthPercentNew: item.lengthPercentNew
  144. })
  145. break
  146. case 2:
  147. mapData2.push({
  148. name: item.zdwName,
  149. value: [item.longitude, item.latitude, 2],
  150. designLength: item.tfPipeLength,
  151. lengthPercentNew: item.lengthPercentNew
  152. })
  153. break
  154. case 3:
  155. mapData3.push({
  156. name: item.zdwName,
  157. value: [item.longitude, item.latitude, 3],
  158. designLength: item.tfPipeLength,
  159. lengthPercentNew: item.lengthPercentNew
  160. })
  161. break
  162. case 4:
  163. mapData4.push({
  164. name: item.zdwName,
  165. value: [item.longitude, item.latitude, 4],
  166. designLength: item.tfPipeLength,
  167. lengthPercentNew: item.lengthPercentNew
  168. })
  169. break
  170. }
  171. if (item.todayScan != null && item.todayScan > 0) {
  172. mapDataScan.push({
  173. name: item.zdwName,
  174. value: [item.longitude, item.latitude, 5],
  175. designLength: item.tfPipeLength,
  176. lengthPercentNew: item.lengthPercentNew
  177. })
  178. }
  179. })
  180. this.showMapInfo(
  181. mapData1,
  182. mapData2,
  183. mapData3,
  184. mapData4,
  185. mapDataScan,
  186. mapData1.length,
  187. mapData2.length,
  188. mapData3.length,
  189. mapData4.length,
  190. mapDataScan.length
  191. )
  192. } else {
  193. this.$message.error('工区信息获取失败')
  194. }
  195. },
  196. //显示地图信息
  197. // showMapInfo(mapData1, mapData2, mapData3, mapData4, mapDataScan, data1, data2, data3, data4, dataScan) {
  198. // var that = this
  199. // let mapname = null
  200. // let mapRegion = null
  201. // //地图数据加载
  202. // let match = (name) => mapJson.regionData.filter((o) => o.name == name)
  203. // if (match(that.pData.projectName.substring(0, 2)).length > 0) {
  204. // mapname = require(`@/components/HomePage${match(that.pData.projectName.substring(0, 2))[0].json}`)
  205. // }
  206. // if (that.pData.projectName.indexOf('宜昌') != -1) {
  207. // mapname = require('@/components/HomePage/mapJson/HB-YC.json') //地图json数据
  208. // }
  209. // if (mapname == null) return
  210. // //初始加载
  211. // this.projectChart = echarts.init(this.$refs.middleMap)
  212. // this.projectChart.showLoading('default', {
  213. // text: '统计中,请稍候...',
  214. // maskColor: '#2957A2',
  215. // textColor: '#fff',
  216. // fontSize: 14,
  217. // zlevel: 9999
  218. // })
  219. // let domImg = document.createElement('img')
  220. // domImg.crossOrigin = 'anonymous'
  221. // // domImg.src = require('@/components/HomePage/images/projectMapImage.png')
  222. // setTimeout(function () {
  223. // mapInit()
  224. // }, 1000)
  225. // //加载方法
  226. // let mapInit = () => {
  227. // echarts.registerMap('mainMap', mapname)
  228. // this.projectChart.hideLoading()
  229. // var option = {
  230. // backgroundColor: 'transparent',
  231. // title: {
  232. // top: 20,
  233. // text: mapRegion,
  234. // subtext: '',
  235. // x: 'right',
  236. // textStyle: {
  237. // color: '#fff',
  238. // fontWeight: 500,
  239. // fontSize: 14
  240. // }
  241. // },
  242. // legend: {
  243. // orient: 'vertical',
  244. // left: 0,
  245. // bottom: 20,
  246. // data: [
  247. // {
  248. // name: '未开工:' + data1 + '个'
  249. // },
  250. // {
  251. // name: '施工中:' + data2 + '个'
  252. // },
  253. // {
  254. // name: '已完工:' + data3 + '个'
  255. // },
  256. // {
  257. // name: '停 工:' + data4 + '个'
  258. // },
  259. // {
  260. // name: '今日扫码:' + dataScan + '个'
  261. // }
  262. // ],
  263. // inactiveBorderWidth: 0,
  264. // itemStyle: {
  265. // borderWidth: 0,
  266. // opacity: 1
  267. // },
  268. // textStyle: {
  269. // color: '#fff'
  270. // }
  271. // },
  272. // tooltip: {
  273. // enterable: true,
  274. // backgroundColor: 'rgba(0,2,89,0.8)',
  275. // triggerOn: 'mousemove',
  276. // borderWidth: 0,
  277. // formatter: function (params) {
  278. // var showData = params['data']
  279. // if (showData) {
  280. // return `<div><div style="color:#fff;float:left">${
  281. // showData.name +
  282. // '<br>设计里程:' +
  283. // (that.setNullAndUndefinedEmpty(showData.designLength) / 1000).toFixed(3) +
  284. // 'km<br>实际施工百分比:' +
  285. // that.setNullAndUndefinedEmpty(showData.lengthPercentNew) +
  286. // '%'
  287. // }</div></div>`
  288. // } else {
  289. // return ``
  290. // }
  291. // }
  292. // },
  293. // geo: {
  294. // map: 'mainMap',
  295. // aspectScale: 0.75,
  296. // layoutCenter: ['50%', '50%'],
  297. // layoutSize: '90%',
  298. // silent: true,
  299. // roam: true,
  300. // z: 0,
  301. // itemStyle: {
  302. // areaColor: {
  303. // image: domImg,
  304. // repeat: 'repeat'
  305. // },
  306. // shadowColor: 'rgba(0, 0, 0, 0.7)',
  307. // shadowBlur: 0,
  308. // shadowOffsetX: 0,
  309. // shadowOffsetY: 5,
  310. // borderColor: 'rgba(0, 0, 0, 0.7)',
  311. // borderWidth: 0.5,
  312. // opacity: 1
  313. // },
  314. // emphasis: {
  315. // areaColor: '#2AB8FF',
  316. // borderWidth: 1,
  317. // color: 'red',
  318. // label: {
  319. // show: false
  320. // }
  321. // }
  322. // },
  323. // series: [
  324. // {
  325. // name: '未开工:' + data1 + '个',
  326. // type: 'scatter',
  327. // coordinateSystem: 'geo',
  328. // itemStyle: {
  329. // color: '#FFFFFF',
  330. // borderWidth: 1,
  331. // borderColor: '#696969'
  332. // },
  333. // symbol: 'circle',
  334. // zlevel: 3,
  335. // data: mapData1
  336. // },
  337. // {
  338. // name: '施工中:' + data2 + '个',
  339. // type: 'scatter',
  340. // coordinateSystem: 'geo',
  341. // itemStyle: {
  342. // color: '#00FFFF',
  343. // borderWidth: 1,
  344. // borderColor: '#696969'
  345. // },
  346. // symbol: 'circle',
  347. // zlevel: 3,
  348. // data: mapData2
  349. // },
  350. // {
  351. // name: '已完工:' + data3 + '个',
  352. // type: 'scatter',
  353. // coordinateSystem: 'geo',
  354. // itemStyle: {
  355. // color: '#08CA5F',
  356. // borderWidth: 1,
  357. // borderColor: '#696969'
  358. // },
  359. // symbol: 'circle',
  360. // zlevel: 3,
  361. // data: mapData3
  362. // },
  363. // {
  364. // name: '停 工:' + data4 + '个',
  365. // type: 'scatter',
  366. // coordinateSystem: 'geo',
  367. // itemStyle: {
  368. // color: '#EA4551',
  369. // borderWidth: 1,
  370. // borderColor: '#696969'
  371. // },
  372. // symbol: 'circle',
  373. // zlevel: 3,
  374. // data: mapData4
  375. // },
  376. // {
  377. // name: '今日扫码:' + dataScan + '个',
  378. // type: 'effectScatter',
  379. // coordinateSystem: 'geo',
  380. // rippleEffect: {
  381. // scale: 5,
  382. // brushType: 'stroke'
  383. // },
  384. // showEffectOn: 'render',
  385. // itemStyle: {
  386. // color: '#E2F039'
  387. // },
  388. // label: {
  389. // color: '#fff'
  390. // },
  391. // symbol: 'circle',
  392. // data: mapDataScan,
  393. // zlevel: 3
  394. // }
  395. // ]
  396. // }
  397. // this.projectChart.resize()
  398. // this.projectChart.setOption(option, {
  399. // notMerge: true
  400. // })
  401. // //图表大小自适应
  402. // window.addEventListener('resize', () => {
  403. // this.projectChart.resize()
  404. // })
  405. // }
  406. // },
  407. //组装施工数据
  408. composeScanInfo(result) {
  409. //清空存储
  410. this.mapBuildingData.splice(0, this.mapBuildingData.length)
  411. this.mapEPCData.splice(0, this.mapEPCData.length)
  412. this.mapSuspendData.splice(0, this.mapSuspendData.length)
  413. this.mapNohandedData.splice(0, this.mapNohandedData.length)
  414. result.forEach((item) => {
  415. let median = { name: item.prjName, value: [item.longitude, item.latitude], datas: item }
  416. this.mapBuildingData.push(median)
  417. if (item.type == '建管/EPC') {
  418. let median = { name: item.prjName, value: [item.longitude, item.latitude], datas: item }
  419. this.mapEPCData.push(median)
  420. }
  421. if (item.stage == '暂停阶段') {
  422. let median = { name: item.prjName, value: [item.longitude, item.latitude], datas: item }
  423. this.mapSuspendData.push(median)
  424. }
  425. if (item.type == '未移交') {
  426. let median = { name: item.prjName, value: [item.longitude, item.latitude], datas: item }
  427. this.mapNohandedData.push(median)
  428. }
  429. })
  430. // //加载空数据防止图上数据下陷
  431. this.mapBuildingData.push({ name: '', value: [0, 0], datas: {} })
  432. this.mapEPCData.push({ name: '', value: [0, 0], datas: {} })
  433. this.mapSuspendData.push({ name: '', value: [0, 200], datas: {} })
  434. this.mapNohandedData.push({ name: '', value: [0, 0], datas: {} })
  435. //地图json数据加载
  436. this.getMapJsonData()
  437. },
  438. //地图json数据
  439. getMapJsonData() {
  440. this.mapData = []
  441. //地图json数据
  442. if (this.groupName === '三峡发展') {
  443. // if(this.groupName==null){
  444. this.mapname = mainMap
  445. // this.userBindInfo.forEach(item=>{
  446. // if(item.pid=="1"){
  447. // if(item.orgName.substring(0,2)=='上游'){
  448. // this.mapData.push({"name":"云南省","value":{'orgId':item.orgID,'showName':item.groupName+"/"+item.orgName}})
  449. // this.mapData.push({"name":"贵州省","value":{'orgId':item.orgID,'showName':item.groupName+"/"+item.orgName}})
  450. // this.mapData.push({"name":"重庆市","value":{'orgId':item.orgID,'showName':item.groupName+"/"+item.orgName}})
  451. // }
  452. // else{
  453. // this.mapData.push({"name":item.orgName.substring(0,3),"value":{'orgId':item.orgID,'showName':item.groupName+"/"+item.orgName}})
  454. // }
  455. // }
  456. // })
  457. this.mapname.features.map((item) => {
  458. const { name } = item.properties
  459. const province = name.substring(0, 2)
  460. if (
  461. province === '四川' ||
  462. province === '重庆' ||
  463. province === '云南' ||
  464. province === '贵州' ||
  465. province === '湖南' ||
  466. province === '湖北' ||
  467. province === '江西' ||
  468. province === '安徽' ||
  469. province === '浙江' ||
  470. province === '江苏' ||
  471. province === '长江'
  472. ) {
  473. this.mapData.push({
  474. name: name,
  475. height: province !== '长江' ? 10 : 11,
  476. itemStyle: {
  477. color: province !== '长江' ? '#40426B' : '#fff',
  478. borderColor: '#000',
  479. borderWidth: province !== '长江' ? 2 : 0
  480. },
  481. label: {
  482. show: province !== '长江' ? true : false,
  483. color: '#fff',
  484. fontSize: 14,
  485. fontWeight: 'bold'
  486. },
  487. emphasis: { label: { fontSize: 16, fontWeight: 'bold', color: '#fff' } }
  488. })
  489. }
  490. })
  491. this.clickSymbol = 1
  492. this.isSilent = true
  493. this.mapDistance = 320
  494. this.mapBoxWidth = 550
  495. this.offset = 40
  496. } else {
  497. let match = (name) => mapJson.groupData.filter((o) => o.name == name)
  498. if (match(this.groupName.substring(0, 2)).length > 0) {
  499. this.mapname = require(`@/views/groupPage/baseMap/components${match(this.groupName.substring(0, 2))[0].json}`)
  500. }
  501. this.clickSymbol = 1
  502. this.isSilent = true
  503. this.mapDistance = 320
  504. this.mapBoxWidth = 200
  505. this.offset = 0
  506. this.mapData = []
  507. }
  508. //地图初始化
  509. this.mapInit()
  510. },
  511. //地图初始化
  512. mapInit() {
  513. var that = this
  514. //容器加载
  515. this.groupChart = echarts.init(this.$refs.middleMap)
  516. // let EPCImg = `path://M 20 17 Z M 22.93 3.06 a 20 20 0 1 0 20 20 A 20 20 0 0 0 22.93 3.06 Z M 29 33 H 17 V 13 h 12 v 4 h -8 v 4 h 8 v 4 H 21 v 4 h 8 Z Z Z M 22 43 h 2.13 v 39 h -2.13 z M 18.26 86.27 a 4.67 4.67 0 1 0 9.34 0 a 4.67 4.67 0 1 0 -9.34 0 z`
  517. // let PRJImg = `path://M 20 17 Z M 22.93 3.06 a 20 20 0 1 0 20 20 A 20 20 0 0 0 22.93 3.06 Z M 22 43 h 2.13 v 39 h -2.13 z M 18.26 86.27 a 4.67 4.67 0 1 0 9.34 0 a 4.67 4.67 0 1 0 -9.34 0 z`
  518. let img =
  519. 'path://M839.68 337.8176L512 665.3952 184.32 337.8176 512 0l327.68 337.8176z M384 956.5184a128 67.4816 0 1 0 256 0 128 67.4816 0 1 0-256 0Z M496.64 635.1872h30.72V915.456h-30.72z'
  520. this.groupChart.showLoading('default', {
  521. text: '统计中,请稍候...',
  522. maskColor: 'transparent',
  523. textColor: '#fff',
  524. fontSize: 14,
  525. zlevel: 9999
  526. })
  527. //地图背景图预加载
  528. let domImg = document.createElement('img')
  529. domImg.crossOrigin = 'anonymous'
  530. domImg.src = require('@/views/groupPage/images/mapbj.png')
  531. function tooltipCustom(toolTipSource) {
  532. if (!toolTipSource) {
  533. return ''
  534. }
  535. if (!toolTipSource.body.data.datas) return
  536. const data = toolTipSource.body.data.datas
  537. let header = `<div class="echart-tooltip-header"><div class="name" title=${data.type}>${data.type}</div><div class="status">${data.stage}</div></div>`
  538. let body = []
  539. body.push(
  540. `<div class="echart-tooltip-body-item"><div class="name">项目名称:</div><div class="value" title=${toolTipSource.body.name}>${toolTipSource.body.name}</div></div>`
  541. )
  542. body.push(
  543. `<div class="echart-tooltip-body-item"><div class="name">开工时间:</div><div class="value">${
  544. data.realBeginTime !== '/' ? moment(data.realBeginTime).format('YYYY-MM-DD') : data.realBeginTime
  545. }</div></div>`
  546. )
  547. body.push(
  548. `<div class="echart-tooltip-body-item"><div class="name">计划工期:</div><div class="value">${
  549. data.planEndTime !== '/' ? moment(data.planEndTime).format('YYYY-MM-DD') : data.planEndTime
  550. }</div></div>`
  551. )
  552. body.push(
  553. `<div class="echart-tooltip-body-item"><div class="name">投资总额:</div><div class="value" title=${data.planInvestment}>${data.planInvestment}亿</div></div>`
  554. )
  555. body.push(
  556. `<div class="echart-tooltip-body-item"><div class="name">建设地点:</div><div class="value" title=${data.city}>${data.city}</div></div>`
  557. )
  558. return `<div class="echart-tooltip-wrap">
  559. ${header}
  560. <div class="echart-tooltip-body">
  561. ${body.join('')}
  562. </div>
  563. </div>`
  564. }
  565. let viewControl = {
  566. autoRotate: true, //是否自动旋转
  567. autoRotateSpeed: 5, //旋转速度
  568. autoRotateAfterStill: 10, //在鼠标静止操作后恢复自动旋转的时间间隔。在开启 autoRotate 后有效。
  569. alpha: 40, //上下旋转的角度
  570. maxBeta: 15, //沿y轴旋转的角度,设置Infinity控制其一直旋转
  571. distance: that.mapDistance, //地图视角 控制初始大小
  572. // minDistance: 0,
  573. center: [that.offset, 0, 0]
  574. }
  575. var option
  576. let mapInitialize = () => {
  577. echarts.registerMap('riverBasin', this.mapname)
  578. this.groupChart.hideLoading()
  579. //地图背景图
  580. //配置项
  581. option = {
  582. backgroundColor: 'transparent',
  583. geo3D: {
  584. map: 'riverBasin',
  585. show: false,
  586. silent: that.isSilent,
  587. boxWidth: that.mapBoxWidth, //三维地图在三维场景中的宽度
  588. viewControl: viewControl,
  589. zlevel: -10
  590. },
  591. tooltip: {
  592. enterable: true,
  593. className: 'echart-tooltip-content',
  594. triggerOn: 'mousemove',
  595. backgroundColor: 'transparent',
  596. formatter(params) {
  597. return tooltipCustom({ body: params })
  598. }
  599. },
  600. series: [
  601. {
  602. type: 'map3D',
  603. name: this.groupName,
  604. map: 'riverBasin',
  605. silent: that.isSilent,
  606. regionHeight: 2,
  607. boxWidth: that.mapBoxWidth, //三维地图在三维场景中的宽度
  608. roam: true,
  609. itemStyle: {
  610. // color:'rgb(14,105,174)',
  611. color: 'rgb(14,105,120)',
  612. opacity: 1,
  613. borderWidth: 1,
  614. borderColor: '#0B496C'
  615. },
  616. emphasis: {
  617. label: {
  618. show: false
  619. }
  620. },
  621. viewControl: viewControl,
  622. shading: 'realistic',
  623. realisticMaterial: {
  624. //纹理材质
  625. detailTexture: domImg,
  626. textureTiling: 1
  627. },
  628. // shading: 'color',
  629. light: {
  630. main: {
  631. color: '#fff', //光照颜色#E4F7FE
  632. intensity: 5.2, //光照强度
  633. shadowQuality: 'high', //阴影亮度
  634. shadow: true, //是否显示阴影
  635. // alpha: 90,
  636. beta: 45
  637. },
  638. ambient: {
  639. intensity: 0.3
  640. }
  641. },
  642. // postEffect: {
  643. // enable: true,
  644. // bloom: {
  645. // enable: false
  646. // },
  647. // SSAO: {
  648. // enable: true,
  649. // quality: 'medium',
  650. // radius: 10,
  651. // intensity: 0.2
  652. // }
  653. // },
  654. zlevel: 1,
  655. data: this.mapData
  656. },
  657. {
  658. name: '建管项目',
  659. type: 'scatter3D',
  660. coordinateSystem: 'geo3D',
  661. itemStyle: {
  662. color: '#E3B434'
  663. },
  664. emphasis: {
  665. label: {
  666. show: false
  667. }
  668. },
  669. symbol: img,
  670. // symbolSize: [35, 70], //宽度、高度
  671. symbolSize: [18, 30], //宽度、高度
  672. data: this.mapBuildingData,
  673. blendMode: 'source-over',
  674. zlevel: 10
  675. },
  676. {
  677. name: 'EPC项目',
  678. type: 'scatter3D',
  679. coordinateSystem: 'geo3D',
  680. itemStyle: {
  681. color: '#00C98F'
  682. },
  683. emphasis: {
  684. label: {
  685. show: false
  686. }
  687. },
  688. symbol: img,
  689. // symbolSize: [35, 70], //宽度、高度
  690. symbolSize: [18, 30], //宽度、高度
  691. data: this.mapEPCData,
  692. blendMode: 'source-over',
  693. zlevel: 20
  694. },
  695. {
  696. name: '暂停项目',
  697. type: 'scatter3D',
  698. coordinateSystem: 'geo3D',
  699. itemStyle: {
  700. color: '#ffffff',
  701. opacity: 1
  702. },
  703. emphasis: {
  704. label: {
  705. show: false
  706. }
  707. },
  708. symbol: img,
  709. // symbolSize: [35, 70], //宽度、高度
  710. symbolSize: [18, 30], //宽度、高度
  711. data: this.mapSuspendData,
  712. blendMode: 'source-over',
  713. zlevel: 30
  714. },
  715. {
  716. name: '未移交',
  717. type: 'scatter3D',
  718. coordinateSystem: 'geo3D',
  719. itemStyle: {
  720. color: '#ff4040',
  721. opacity: 1
  722. },
  723. emphasis: {
  724. label: {
  725. show: false
  726. }
  727. },
  728. symbol: img,
  729. // symbolSize: [35, 70], //宽度、高度
  730. symbolSize: [18, 30], //宽度、高度
  731. data: this.mapNohandedData,
  732. blendMode: 'source-over',
  733. zlevel: 40
  734. }
  735. ]
  736. }
  737. // this.groupChart.resize()
  738. this.groupChart.setOption(option, {
  739. notMerge: true
  740. })
  741. }
  742. domImg.onload = () => {
  743. setTimeout(() => {
  744. mapInitialize()
  745. }, 1000)
  746. }
  747. //地图点击事件
  748. if (this.clickSymbol == 0) {
  749. // this.chartRegionClickEvent()
  750. this.chartProjectClickEvent()
  751. } else {
  752. this.chartProjectClickEvent()
  753. }
  754. },
  755. //地图区域点击事件
  756. chartRegionClickEvent() {
  757. if (!this.groupChart) return
  758. //图表点击事件
  759. var that = this
  760. this.groupChart.off('click') //清除原有的点击事件
  761. this.groupChart.on('click', 'series.map3D', function (e) {
  762. console.log('地图点击', e)
  763. if (e.value == null) return
  764. let changeData = {
  765. orgId: e.value.orgId,
  766. groupName: e.name,
  767. unitSymbol: e.value.orgId,
  768. pidSymbol: '1',
  769. showName: e.value.showName
  770. }
  771. that.$emit('changeGroupData', changeData)
  772. that.backShow = true
  773. that.clickPermissions = true
  774. })
  775. },
  776. //地图项目点击事件
  777. chartProjectClickEvent() {
  778. if (!this.groupChart) return
  779. var that = this
  780. this.groupChart.off('click') //清除原有的点击事件
  781. this.groupChart.on('click', 'series.scatter3D', function (e) {
  782. if (e.value == null) return
  783. that.debounce(() => {
  784. that.$store.state.bigScreen.currentMenuItem = {
  785. name: e.name.split('项目')[0],
  786. value: 'HB06',
  787. pid: 2
  788. }
  789. }, 600)
  790. })
  791. },
  792. //返回至初始
  793. backClick() {
  794. if (this.clickPermissions) {
  795. let changeData = {
  796. orgId: null,
  797. groupName: null,
  798. unitSymbol: '',
  799. pidSymbol: '0',
  800. showName: '环保集团'
  801. }
  802. this.$emit('changeGroupData', changeData)
  803. this.backShow = false
  804. }
  805. },
  806. //图表销毁
  807. destroyChart() {
  808. if (this.projectChart != null) {
  809. this.projectChart.dispose()
  810. this.projectChart = null
  811. }
  812. if (this.groupChart != null) {
  813. this.groupChart.dispose()
  814. this.groupChart = null
  815. }
  816. }
  817. },
  818. beforeDestroy() {
  819. this.destroyChart()
  820. }
  821. }
  822. </script>
  823. <style lang="scss" scoped>
  824. .EchartsMap {
  825. width: 100%;
  826. height: 100%;
  827. position: relative;
  828. background: url('~@/views/groupPage/images/bj.png') no-repeat;
  829. background-size: 100% 100%;
  830. .chart {
  831. width: 100%;
  832. height: 100%;
  833. }
  834. .back {
  835. position: absolute;
  836. left: 17px;
  837. top: 25px;
  838. color: rgb(222, 222, 222);
  839. font-size: 12px;
  840. cursor: pointer;
  841. border: 1px solid rgba(255, 255, 255, 0.5);
  842. padding: 0px 6px 1px 0px;
  843. border-radius: 3px;
  844. z-index: 100;
  845. display: block;
  846. }
  847. /deep/ .echart-tooltip-content {
  848. background: linear-gradient(0deg, rgba(2, 20, 37, 0.82) 0%, rgba(7, 38, 67, 0.89) 100%);
  849. box-shadow: 0px 3px 13px 0px #000000;
  850. border: 1px solid;
  851. border-image: linear-gradient(90deg, rgba(24, 255, 168, 1), rgba(25, 137, 252, 1)) 1;
  852. // height: 1.041667rem /* 200/192 */;
  853. width: 1.375rem; /* 264/192 */
  854. font-size: 0.0625rem /* 12/192 */ !important;
  855. padding: 0.052083rem /* 10/192 */ !important;
  856. font-family: Source Han Sans CN;
  857. .echart-tooltip-wrap {
  858. .echart-tooltip-header {
  859. height: 0.104167rem /* 20/192 */;
  860. display: flex;
  861. justify-content: space-between;
  862. .name {
  863. flex: 1;
  864. overflow: hidden;
  865. text-overflow: ellipsis;
  866. white-space: nowrap;
  867. font-size: 0.083333rem /* 16/192 */;
  868. font-weight: bold;
  869. color: #16c6ea;
  870. }
  871. .status {
  872. flex: 0.5;
  873. // width: 0.229167rem /* 44/192 */;
  874. // height: 100%;
  875. background: linear-gradient(90deg, #1695ee, #06bc82);
  876. border-radius: 2px;
  877. color: #fff;
  878. display: flex;
  879. justify-content: center;
  880. align-items: center;
  881. font-size: 0.072917rem; /* 14/192 */
  882. }
  883. }
  884. .echart-tooltip-body {
  885. height: calc(100% - 20px);
  886. width: 100%;
  887. display: flex;
  888. flex-flow: column;
  889. .echart-tooltip-body-item {
  890. font-size: 0.072917rem /* 14/192 */;
  891. font-weight: 400;
  892. padding: 0.026042rem /* 5/192 */ 0;
  893. display: flex;
  894. .name {
  895. color: #ffffff;
  896. }
  897. .value {
  898. color: rgba(14, 202, 240, 1);
  899. flex: 1;
  900. // overflow: hidden;
  901. // text-overflow: ellipsis;
  902. white-space: normal;
  903. }
  904. }
  905. }
  906. }
  907. }
  908. }
  909. </style>