PreviewPdf.vue 1.1 KB

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