| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <template>
- <ele-modal
- :visible.sync="showEditFlag"
- :close-on-click-modal="false"
- custom-class="ele-dialog-form"
- append-to-body
- :fullscreen="true"
- v-if="showEditFlag"
- >
- <iframe
- :src="fileUrl"
- width="100%"
- v-if="showEditFlag"
- style="height: calc(100vh - 100px); position: absolute; left: -1000000px"
- frameborder="0"
- allowfullscreen="true"
- ref="Iframe"
- id="Iframe"
- ></iframe>
- <seal ref="sealRef" @pdf-generated="pdfGenerated"></seal>
- <template slot="footer">
- <el-button
- type="primary"
- size="small"
- @click="handleSave"
- :disabled="false"
- >保存</el-button
- >
- <el-button size="small" @click="showEditFlag = false" :disabled="false"
- >取消</el-button
- >
- </template>
- </ele-modal>
- </template>
- <script>
- import seal from './seal.vue';
- import { uploadFileNew } from './api';
- export default {
- data() {
- return {
- fileUrl: '',
- showEditFlag: false,
- restoreData: null
- };
- },
- components: { seal },
- methods: {
- open(row) {
- this.showEditFlag = true;
- this.restoreData = row;
- this.setFileUrl(row);
- },
- restore() {
- this.setFileUrl(this.restoreData);
- },
- handleSave() {
- this.$refs.sealRef.exportToPDF();
- },
- pdfGenerated({ pdfFile, droppedImages }) {
- this.$emit('save', {
- pdfFile: pdfFile,
- id: this.restoreData.id,
- droppedImages
- });
- this.showEditFlag = false;
- // uploadFileNew({
- // module: 'fm',
- // multiPartFile: pdfFile
- // })
- // .then((res) => {
- // this.$emit('save', {
- // stampStoragePath: res.data ? [res.data] : [],
- // id: this.restoreData.id,
- // droppedImages
- // });
- // this.showEditFlag = false;
- // })
- // .finally(() => {
- // this.loading = false;
- // });
- },
- setFileUrl(row) {
- let file = row.stampStoragePath[0] || row.storagePath[0];
- let fileNames = file.storePath.split('/');
- let url =
- window.location.origin +
- '/api/main/file/getFile?objectName=' +
- file.storePath +
- '&fullfilename=' +
- fileNames[fileNames.length - 1];
- this.fileUrl = '/kkfile/onlinePreview?url=' + btoa(url);
- this.$nextTick(() => {
- this.$refs.Iframe.onload = () => {
- var iframe = document.getElementById('Iframe');
- console.log(iframe);
- var iframeDocument = iframe.contentWindow.document;
- console.log(iframeDocument);
- var container = iframeDocument.querySelectorAll('.container');
- console.log(container);
- this.$refs.sealRef.init(
- container[0].innerHTML.replace(
- /src="https?:\/\/[^\/]+(\/[^"]*)"/g,
- `src="${window.location.origin}$1"`
- ),
- {
- droppedImages: row.droppedImages || ''
- }
- );
- };
- });
- }
- }
- };
- </script>
- <style scoped lang="scss"></style>
|