| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <template>
- <div class="iframe-wrap">
- <iframe id="mapFrame" ref="mapFrame" src="/gis/index.html" frameborder="none" :onload="loadDone"/>
- </div>
- </template>
- <script>
- import {chartMap} from '@/api/dashboard-json'
- export default {
- name: 'ChartMap',
- created() {
- window['mapFrame'] = this.$refs.mapFrame
- },
- mounted() {
- this.$refs.mapFrame.onload = () => {
- this.loadDone()
- }
- },
- methods: {
- loadDone() {
- chartMap().then(res => {
- const data = (res.info || []).map(item => {
- const ret = {
- title: item.title?.replace('运行工区', ''),
- data: {}
- }
- item.xaxis.forEach((key, index) => {
- ret.data[key] = item.series[index].data
- })
- return ret
- })
- window['mapData'] = data;
- this.$refs.mapFrame.contentWindow.postMessage(
- {
- data: data
- },
- '*'
- )
- this.$refs.mapFrame.contentWindow.addEventListener('message', (evt) => {
- console.log('onMessage', evt)
- })
- console.log('data', data)
- })
- console.log('loadDone')
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .iframe-wrap {
- width: 100%;
- height: 100%;
- iframe {
- width: 100%;
- height: 100%;
- }
- }
- ::v-deep {
- #container {
- background-image: none !important;
- }
- }
- </style>
|