diff --git a/src/components/PdfViewer/A4Viewer.vue b/src/components/PdfViewer/A4Viewer.vue index 47568452..704f8dba 100644 --- a/src/components/PdfViewer/A4Viewer.vue +++ b/src/components/PdfViewer/A4Viewer.vue @@ -291,8 +291,7 @@ export default { this.showA4Page(this.currentPage) } }, - // 下载 - downPDF() { + downPDF() { // 下载所有预览的PDF文件 if(this.isA4){ if(this.cacheA4FileList&&this.cacheA4FileList.length>0){ @@ -304,35 +303,79 @@ export default { needGenList.push(thisSubList[j].pdfBase64) } item.pdfUrl=await this.pdfUtils.mergePdfToA4(needGenList); - this.downPdfFile(item.billCode,item.pdfUrl); + this.downPdfFile(item.pdfUrl); }else{ - this.downPdfFile(item.billCode,item.pdfUrl); + this.downPdfFile(item.pdfUrl); } }); } }else{ if(this.cacheFileList&&this.cacheFileList.length>0){ - this.cacheFileList.forEach( item=>{ - if(!item.pdfUrl){ - item.pdfUrl = this.pdfUtils.getBlobUrl(item.pdfBase64); + // this.cacheFileList.forEach( item=>{ + // if(!item.pdfUrl){ + // item.pdfUrl = this.pdfUtils.getBlobUrl(item.pdfBase64); + // } + // this.downPdfFile(item.billCode,item.pdfUrl); + // }); + + + this.$prompt('请输入保存文件名', "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + closeOnClickModal: false, + inputValidator (value) { + if (value) { + return true; + }else{ + return false; } - this.downPdfFile(item.billCode,item.pdfUrl); - }); + }, + inputErrorMessage: "文件名不能为空" + }).then(async ({ value }) => { + + let fileName=value+".pdf"; + let needGenList=[]; + for(let j=0;j {}); + + } } }, - downPdfFile(fileName,pdfUrl){ - var tempLink = document.createElement('a') - tempLink.style.display = 'none' - tempLink.href = pdfUrl - tempLink.setAttribute('download', fileName+'.pdf') - if (typeof tempLink.download === 'undefined') { - tempLink.setAttribute('target', '_blank') - } - document.body.appendChild(tempLink) - tempLink.click() - document.body.removeChild(tempLink) + downPdfFile(pdfUrl){ + + this.$prompt('请输入保存文件名', "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + closeOnClickModal: false, + inputValidator (value) { + if (value) { + return true; + }else{ + return false; + } + }, + inputErrorMessage: "文件名不能为空" + }).then(async ({ value }) => { + + let fileName=value+".pdf"; + var tempLink = document.createElement('a') + tempLink.style.display = 'none' + tempLink.href = pdfUrl + tempLink.setAttribute('download', fileName+'.pdf') + if (typeof tempLink.download === 'undefined') { + tempLink.setAttribute('target', '_blank') + } + document.body.appendChild(tempLink) + tempLink.click() + document.body.removeChild(tempLink) + }).catch(() => {}); + }, // 打印 printPDF() { diff --git a/src/components/PdfViewer/viewer.vue b/src/components/PdfViewer/viewer.vue index e3dea875..7a79f49e 100644 --- a/src/components/PdfViewer/viewer.vue +++ b/src/components/PdfViewer/viewer.vue @@ -33,13 +33,15 @@
- 下载 - 打印 + 下载 + 打印
-
-
+
+ +
-
- - - - - +
+ +
@@ -302,9 +299,9 @@ export default { needGenList.push(thisSubList[j].pdfBase64) } item.pdfUrl=await this.pdfUtils.mergePdfToA4(needGenList); - this.downPdfFile(item.billCode,item.pdfUrl); + this.downPdfFile(item.pdfUrl); }else{ - this.downPdfFile(item.billCode,item.pdfUrl); + this.downPdfFile(item.pdfUrl); } }); @@ -319,27 +316,63 @@ export default { // }); - let needGenList=[]; - for(let j=0;j { + + let fileName=value+".pdf"; + let needGenList=[]; + for(let j=0;j {}); + - let fileName=new Date().getTime()+".pdf"; - this.pdfUtils.mergePdf3(needGenList,fileName,true); } } }, - downPdfFile(fileName,pdfUrl){ - var tempLink = document.createElement('a') - tempLink.style.display = 'none' - tempLink.href = pdfUrl - tempLink.setAttribute('download', fileName+'.pdf') - if (typeof tempLink.download === 'undefined') { - tempLink.setAttribute('target', '_blank') - } - document.body.appendChild(tempLink) - tempLink.click() - document.body.removeChild(tempLink) + downPdfFile(pdfUrl){ + + this.$prompt('请输入保存文件名', "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + closeOnClickModal: false, + inputValidator (value) { + if (value) { + return true; + }else{ + return false; + } + }, + inputErrorMessage: "文件名不能为空" + }).then(async ({ value }) => { + + let fileName=value+".pdf"; + var tempLink = document.createElement('a') + tempLink.style.display = 'none' + tempLink.href = pdfUrl + tempLink.setAttribute('download', fileName+'.pdf') + if (typeof tempLink.download === 'undefined') { + tempLink.setAttribute('target', '_blank') + } + document.body.appendChild(tempLink) + tempLink.click() + document.body.removeChild(tempLink) + }).catch(() => {}); + + }, // 打印 printPDF() { @@ -460,7 +493,7 @@ export default { display: flex; z-index: 9999; position: absolute; - top: 5px; + top: 0px; right: 30px; } .pdf-bar { @@ -471,7 +504,7 @@ export default { z-index: 1; width: 100%; - height: 50px; + height: 36px; border: 1px solid #ddd; box-sizing: border-box; text-align: center; diff --git a/src/components/XdTable/index.vue b/src/components/XdTable/index.vue index d2922c80..bd3ea02f 100644 --- a/src/components/XdTable/index.vue +++ b/src/components/XdTable/index.vue @@ -67,7 +67,7 @@ - +
-
+
@@ -126,12 +126,12 @@ v-model="loginForm.password" type="password" maxlength="20" - auto-complete="new-password" show-password clearable :placeholder="$t('loginForm.password')" @keyup.enter.native="handleLogin" > +