chartMap.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div class="iframe-wrap">
  3. <iframe id="mapFrame" ref="mapFrame" src="/gis/index.html" frameborder="none" :onload="loadDone"/>
  4. </div>
  5. </template>
  6. <script>
  7. import { chartMap } from '@/api/dashboard-json'
  8. export default {
  9. name: 'ChartMap',
  10. created() {
  11. window['mapFrame'] = this.$refs.mapFrame
  12. },
  13. mounted() {
  14. this.$refs.mapFrame.onload = () => {
  15. this.loadDone()
  16. }
  17. },
  18. methods: {
  19. loadDone() {
  20. chartMap().then(res => {
  21. const data = (res.info || []).map(item => {
  22. const ret = {
  23. title: item.title?.replace('运行工区', ''),
  24. data: {}
  25. }
  26. item.xaxis.forEach((key, index) => {
  27. ret.data[key] = item.series[index].data
  28. })
  29. return ret
  30. })
  31. this.$refs.mapFrame.contentWindow.postMessage(
  32. {
  33. data: data
  34. },
  35. '*'
  36. )
  37. console.log('data', data)
  38. })
  39. console.log('loadDone')
  40. }
  41. }
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. .iframe-wrap {
  46. width: 100%;
  47. height: 100%;
  48. iframe {
  49. width: 100%;
  50. height: 100%;
  51. }
  52. }
  53. ::v-deep {
  54. #container {
  55. background-image: none !important;
  56. }
  57. }
  58. </style>