diff --git a/.env.development b/.env.development index 13c19f3d..76d41c3d 100644 --- a/.env.development +++ b/.env.development @@ -15,7 +15,7 @@ VUE_APP_BASE_API = 'http://47.96.189.20:58089/api/bizsvr' VUE_APP_WS_HOST = 'ws://47.96.189.20:58089/api/bizsvr' -VUE_APP_PRINTER_HOST = '192.168.88.189:17080' +VUE_APP_PRINTER_HOST = '192.168.88.108:17080' # 路由懒加载 diff --git a/src/components/PdfViewer/A4Viewer.vue b/src/components/PdfViewer/A4Viewer.vue index 7c60b450..26a394de 100644 --- a/src/components/PdfViewer/A4Viewer.vue +++ b/src/components/PdfViewer/A4Viewer.vue @@ -69,7 +69,8 @@ import printJS from 'print-js' // npm i pdfjs-dist@2.5.207 // npm i vue-pdf@4.2.0 -import pdf from 'xd-vue-pdf' +// import pdf from 'xd-vue-pdf' +import pdf from "./xdpdf/vuePdfNoSss.vue" import PdfUtils from '@/utils/pdfUtils.js'; export default { components: { pdf }, @@ -83,8 +84,8 @@ export default { }, isLoadComplete:{ - type: Boolean, - default: false + type: Number, + default: 0 } }, data() { @@ -117,22 +118,47 @@ export default { } }, computed: { + // currentPdfUrl() { + // if (!this.loadPdfUrl) return '' + // const publicPath ='/static/' + // return pdf.createLoadingTask({ + // url: this.loadPdfUrl, + // cMapUrl: `${publicPath}cmaps/`, + // cMapPacked: true + // }) + // } currentPdfUrl() { if (!this.loadPdfUrl) return '' + + console.log("====>currentPdfUrl==>",this.loadPdfUrl) const publicPath ='/static/' + // return pdf.createLoadingTask({ + // url: this.loadPdfUrl, + // cMapUrl: `${publicPath}cmaps/`, + // cMapPacked: true + // }) return pdf.createLoadingTask({ - url: this.loadPdfUrl, - cMapUrl: `${publicPath}cmaps/`, - cMapPacked: true + url: this.loadPdfUrl }) } }, watch: { - pdfList(){ - this.cacheFileList=this.pdfList; - this.initA4List(); - this.showFirstFile(); - }, + // pdfList(){ + // this.cacheFileList=this.pdfList; + // this.initA4List(); + // this.showFirstFile(); + // }, + "pdfList": { + handler (newValue, oldValue) { + console.log("===>watch pdfList==>",this.pdfList); + // 按照给定的数据排序 + this.cacheFileList=this.pdfList; + + this.initA4List(); + this.showFirstFile(); + }, + deep: true + }, thisPageCount(value) { if(this.isA4){ this.doScale(50); @@ -189,7 +215,12 @@ export default { this.scale=50; this.preScale=50; this.pageCount=this.cacheA4FileList.length; - setTimeout( this.showA4Page(this.cacheA4FileList.length),3000); + // setTimeout( this.showA4Page(this.cacheA4FileList.length),3000); + setTimeout( + async () => { + this.showA4Page(1); + } + ,3000); }else{ this.scale=20; this.preScale=20; @@ -290,21 +321,53 @@ export default { downPDF() { // 下载所有预览的PDF文件 if(this.isA4){ + + let that=this; + if(this.cacheA4FileList&&this.cacheA4FileList.length>0){ - this.cacheA4FileList.forEach(async item=>{ - if(!item.pdfUrl){ - let thisSubList=item.childreen; - let needGenList=[]; + + // this.cacheA4FileList.forEach(item=>{ + // if(!item.pdfUrl){ + // let thisSubList=item.childreen; + // let needGenList=[]; + // for(let j=0;j { + + let fileName=value+".pdf"; + let needGenList=[]; + for(let i=0;i {}); - }); } }else{ if(this.cacheFileList&&this.cacheFileList.length>0){ diff --git a/src/utils/pdfUtils.js b/src/utils/pdfUtils.js index 530e5e82..3321408d 100644 --- a/src/utils/pdfUtils.js +++ b/src/utils/pdfUtils.js @@ -381,16 +381,22 @@ export default class PdfUtils { pdfBuffers.push(Buffer.from(dateArray)); }); const pdfDoc = await PDFDocument.create(); - const pageA4 = pdfDoc.addPage(PageSizes.A4); - const drawHeight = pageA4.getHeight()/2; - const drawWidth = pageA4.getWidth()/2; + let pageA4 = pdfDoc.addPage(PageSizes.A4); + // const drawHeight = pageA4.getHeight()/2; + // const drawWidth = pageA4.getWidth()/2; let i=0; let x=0; let y=0; let width=0; let height=0; let spaceWidth=2; - for (let buffer of pdfBuffers) { + for (let j=0;j===> needGenList==>", needGenList); + let fileName=value+".pdf"; this.pdfUtils.mergePdfToA4(needGenList,fileName,true);