index.vue 2.29 KB
Newer Older
co_dengxiongwen's avatar
co_dengxiongwen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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
<template>
            <div v-if='isShow' class="map_right"> 
              <iframe :src="src" ref="iframe"></iframe>
            </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from 'vuex'

    export default {
        data() {
            return {
                code:'',
                src: window.CONFIG.bimPath,
                
            }
        },
        computed: {
            ...mapState('d2admin/bjCode', ['resourceCode']),
            ...mapState('d2admin/bim', ['isShow'])
        },
        watch: {
            resourceCode(val) {
            console.log('resourceCode:', val)
            if (this.transformationSta == 2) {
                this.sendBjMessage(val.substring(0, val.indexOf('+')))
            }
            }
  },
        mounted() {
            this.code = this.resourceCode
            console.log(this.isShow,'111111111111')

        //   this.sendMessage()
        },
        methods: {
                sendMessage(code) {
                    console.log(111)
                    setTimeout(() => {
                        if (!this.$refs.iframe) {
                        return
                        }
                        this.$refs.iframe.contentWindow.postMessage(
                        {
                            func: 'locateByCode',
                            data: {
                                code: code
                            }
                        },
                        this.src
                        )
                    }, 1000)
                    },
                    sendBjMessage(code) {
                        console.log('********' + code)
                        setTimeout(() => {
                            if (!this.$refs.iframe) {
                            return
                            }
                            this.$refs.iframe.contentWindow.postMessage({
                            func: 'alarm',
                            data: {
                                code: code
                                }
                            }, this.src)
                        }, 1000)
                    },
        },  
    }
</script>

<style lang="scss" scoped>

    iframe {
      width: 1580px;
      height: 770px;
      position:absolute;
      top:50px;
      right:0;
      z-index:99;
    }
</style>