sealManagement.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <ele-modal
  3. :visible.sync="showEditFlag"
  4. :close-on-click-modal="false"
  5. custom-class="ele-dialog-form"
  6. append-to-body
  7. :fullscreen="true"
  8. v-if="showEditFlag"
  9. >
  10. <iframe
  11. :src="fileUrl"
  12. width="100%"
  13. v-if="showEditFlag"
  14. style="height: calc(100vh - 100px); position: absolute; left: -1000000px"
  15. frameborder="0"
  16. allowfullscreen="true"
  17. ref="Iframe"
  18. id="Iframe"
  19. ></iframe>
  20. <seal ref="sealRef" @pdf-generated="pdfGenerated"></seal>
  21. <template slot="footer">
  22. <el-button
  23. type="primary"
  24. size="small"
  25. @click="handleSave"
  26. :disabled="false"
  27. >保存</el-button
  28. >
  29. <el-button size="small" @click="showEditFlag = false" :disabled="false"
  30. >取消</el-button
  31. >
  32. </template>
  33. </ele-modal>
  34. </template>
  35. <script>
  36. import seal from './seal.vue';
  37. import { uploadFileNew } from './api';
  38. export default {
  39. data() {
  40. return {
  41. fileUrl: '',
  42. showEditFlag: false,
  43. restoreData: null
  44. };
  45. },
  46. components: { seal },
  47. methods: {
  48. open(row) {
  49. this.showEditFlag = true;
  50. this.restoreData = row;
  51. this.setFileUrl(row);
  52. },
  53. restore() {
  54. this.setFileUrl(this.restoreData);
  55. },
  56. handleSave() {
  57. this.$refs.sealRef.exportToPDF();
  58. },
  59. pdfGenerated({ pdfFile, droppedImages }) {
  60. this.$emit('save', {
  61. pdfFile: pdfFile,
  62. id: this.restoreData.id,
  63. droppedImages
  64. });
  65. this.showEditFlag = false;
  66. // uploadFileNew({
  67. // module: 'fm',
  68. // multiPartFile: pdfFile
  69. // })
  70. // .then((res) => {
  71. // this.$emit('save', {
  72. // stampStoragePath: res.data ? [res.data] : [],
  73. // id: this.restoreData.id,
  74. // droppedImages
  75. // });
  76. // this.showEditFlag = false;
  77. // })
  78. // .finally(() => {
  79. // this.loading = false;
  80. // });
  81. },
  82. setFileUrl(row) {
  83. let file = row.stampStoragePath[0] || row.storagePath[0];
  84. let fileNames = file.storePath.split('/');
  85. let url =
  86. window.location.origin +
  87. '/api/main/file/getFile?objectName=' +
  88. file.storePath +
  89. '&fullfilename=' +
  90. fileNames[fileNames.length - 1];
  91. this.fileUrl = '/kkfile/onlinePreview?url=' + btoa(url);
  92. this.$nextTick(() => {
  93. this.$refs.Iframe.onload = () => {
  94. var iframe = document.getElementById('Iframe');
  95. console.log(iframe);
  96. var iframeDocument = iframe.contentWindow.document;
  97. console.log(iframeDocument);
  98. var container = iframeDocument.querySelectorAll('.container');
  99. console.log(container);
  100. this.$refs.sealRef.init(
  101. container[0].innerHTML.replace(
  102. /src="https?:\/\/[^\/]+(\/[^"]*)"/g,
  103. `src="${window.location.origin}$1"`
  104. ),
  105. {
  106. droppedImages: row.droppedImages || ''
  107. }
  108. );
  109. };
  110. });
  111. }
  112. }
  113. };
  114. </script>
  115. <style scoped lang="scss"></style>