PreviewPdf.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <cus-dialog
  3. :visible="previewVisible"
  4. @on-close="previewVisible = false"
  5. ref="pdfPreview"
  6. :title="$t('fm.actions.pdfPreview')"
  7. :action="false"
  8. custom-class="fm-generate-preview-pdf"
  9. :close-on-press-escape="false"
  10. :fullscreen="false"
  11. width="1200px"
  12. >
  13. <iframe :src="iframeSrc" frameborder="0" width="100%" height="600px" style="margin-bottom: -6px;"></iframe>
  14. </cus-dialog>
  15. </template>
  16. <script>
  17. import CusDialog from './CusDialog.vue'
  18. export default {
  19. components: {
  20. CusDialog
  21. },
  22. data () {
  23. return {
  24. previewVisible: false,
  25. iframeSrc: ''
  26. }
  27. },
  28. methods: {
  29. open (pdfBlob) {
  30. // 创建一个URL对象
  31. var pdfUrl = URL.createObjectURL(pdfBlob);
  32. // 创建一个新窗口并加载PDF文件
  33. this.iframeSrc = pdfUrl
  34. this.previewVisible = true
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang="scss">
  40. .fm-generate-preview-pdf{
  41. overflow: hidden !important;
  42. display: flex;
  43. flex-direction: column;
  44. .el-dialog__body{
  45. height: 100%;
  46. padding: 0;
  47. }
  48. }
  49. </style>