Blame view

ant-design-vue-jeecg/src/views/jeecg/modules/PdfPreviewModal.vue 1.08 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<template>
  <div style="display: none">
    <iframe
      :id="id"
      :src="url"
      frameborder="0"
      width="100%"
      height="550px"
      scrolling="auto">
    </iframe>
  </div>
</template>

<script>
肖超群 authored
15
16
import Vue from 'vue'
import {ACCESS_TOKEN} from "@/store/mutation-types"
肖超群 authored
17
肖超群 authored
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export default {
  name: "PdfPreviewModal",
  data() {
    return {
      url: window._CONFIG['pdfDomainURL'],
      id: "pdfPreviewIframe",
      headers: {}
    }
  },
  created() {
    const token = Vue.ls.get(ACCESS_TOKEN);
    this.headers = {"X-Access-Token": token}
  },
  computed: {},
  mounted() {
    window.addEventListener('message', this.handleScanFileMessage);
  },
  methods: {
    handleScanFileMessage(event) {
      // 根据上面制定的结构来解析iframe内部发回来的数据
      const data = event.data;
      console.log(data);
肖超群 authored
40
41
    },
肖超群 authored
42
43
44
45
    previewFiles(title, token) {
      var iframe = document.getElementById("pdfPreviewIframe");
      var json = {"title": title, "token": token};
      iframe.contentWindow.postMessage(json, "*");
肖超群 authored
46
47
48
    },

  }
肖超群 authored
49
}
肖超群 authored
50
51
52
53
54
</script>

<style scoped>

</style>