liuguocan
2023-03-14 ef61883a5437d03c5e384ba0b35c3e0885a882ab
src/views/report/demo/print_1.vue
@@ -1,5 +1,7 @@
<template>
  <iframe ref="iframe" :src="url" scrolling="auto" :style="{height:'calc(100% - 5px)',width:'100%',border:'none'}" />
  <div class="report-box">
    <iframe id="iframe-box" @load="loadFrame" ref="iframe" :src="url" scrolling="auto" :style="{height:'100%',width:'100%',border:'none'}" />
  </div>
</template>
<script>
@@ -20,10 +22,24 @@
      let token = getToken();
      this.url = globalConf.baseUrl + `/jmreport/view/ff9bd143582a6dfed897ba8b6f93b175?token=${token}`
      this.height = window.screen.availHeight
    },
    methods:{
      loadFrame() {
        const iframeBox = document.getElementById('iframe-box')
        const doc = iframeBox.contentWindow.document
        const head = doc.getElementsByTagName('head')
        const linkTag = document.createElement('link')
        linkTag.id = 'newstyle'
        linkTag.href = `./iframe.css`
        linkTag.setAttribute('rel', 'stylesheet')
        linkTag.setAttribute('type', 'text/css')
        head[0].append(linkTag)
      }
    }
  }
</script>
<style scoped>
<style lang="scss">
.report-box{
  height: calc( 100vh - 150px );
}
</style>