diff --git a/.env.development b/.env.development index a95d140d..7f3f05e0 100644 --- a/.env.development +++ b/.env.development @@ -8,6 +8,7 @@ VUE_APP_VERSION = '20240516' # 开发环境 #VUE_APP_BASE_API = '/dev-api' VUE_APP_PDOMAIN = 'tanex56' +VUE_APP_DATA_FROM = 'pc' # VUE_APP_BASE_API = 'http://api.emis.tanex56.com/api/bizsvr' VUE_APP_BASE_API = 'http://47.102.220.189:58089/api/bizsvr' # VUE_APP_BASE_API = 'http://47.96.189.20:58089/api/bizsvr' diff --git a/.env.production b/.env.production index 0e7620a5..8945de09 100644 --- a/.env.production +++ b/.env.production @@ -8,6 +8,7 @@ VUE_APP_VERSION = '20240520' # 管理系统/生产环境 VUE_APP_PDOMAIN = 'tanex56' +VUE_APP_DATA_FROM = 'pc' VUE_APP_BASE_API = 'https://api.emis.tanex56.com/api/bizsvr' VUE_APP_PRINTER_HOST = '127.0.0.1:17080' diff --git a/.env.staging b/.env.staging index a1fb67c7..f0c03348 100644 --- a/.env.staging +++ b/.env.staging @@ -11,6 +11,7 @@ VUE_APP_VERSION = '20240516' # 测试环境 VUE_APP_BASE_API = '/stage-api' VUE_APP_PDOMAIN = 'tanex56' +VUE_APP_DATA_FROM = 'pc' VUE_APP_BASE_API = 'http://api.emis.tanex56.com/api/bizsvr' VUE_APP_PRINTER_HOST = '127.0.0.1:17080' diff --git a/src/components/PdfViewer/viewer.vue b/src/components/PdfViewer/viewer.vue index 06b2b2fd..11f6b7b5 100644 --- a/src/components/PdfViewer/viewer.vue +++ b/src/components/PdfViewer/viewer.vue @@ -227,10 +227,18 @@ export default { }, // 下载 downPDF() { - var tempLink = document.createElement('a') + // 下载所有预览的PDF文件 + if(this.cacheFileList&&this.cacheFileList.length>0){ + this.cacheFileList.forEach(item=>{ + this.downPdfFile(item.billCode,item.pdfUrl); + }); + } + }, + downPdfFile(fileName,pdfUrl){ + var tempLink = document.createElement('a') tempLink.style.display = 'none' - tempLink.href = this.loadPdfUrl - tempLink.setAttribute('download', (new Date()).getTime()+'.pdf') + tempLink.href = pdfUrl + tempLink.setAttribute('download', fileName+'.pdf') if (typeof tempLink.download === 'undefined') { tempLink.setAttribute('target', '_blank') } diff --git a/src/utils/pdfUtils.js b/src/utils/pdfUtils.js index c3f3d41c..61291c6f 100644 --- a/src/utils/pdfUtils.js +++ b/src/utils/pdfUtils.js @@ -50,6 +50,53 @@ export default class PdfUtils { // } } + /** + * 通过模版生成A4纸面单 + * @param {*} templatePath + * @param {*} outputPath + * @param {*} data + */ +// const { PDFDocument, StandardFonts } = require('pdf-lib'); +// const fs = require('fs'); +// const fontkit = require('@pdf-lib/fontkit') +// let pdfDoc +// let font +// 使用示例 +// const templatePath = 'template.pdf'; +// const outputPath = 'output.pdf'; +// const data = { +// 'key': 'value支持中文参数', +// }; + +// fillPdfForm(templatePath, outputPath, data) +// .then(() => { +// console.log('PDF生成成功'); +// }) +// .catch((error) => { +// console.log('PDF生成失败:', error); +// }); + + async fillPdfForm(templatePath, outputPath, data) { + const templateBytes = await fs.promises.readFile(templatePath); + const fontBytes = await fs.promises.readFile('xxx.ttf'); + pdfDoc = await PDFDocument.load(templateBytes); + pdfDoc.registerFontkit(fontkit); + font = await pdfDoc.embedFont(fontBytes); + const form = pdfDoc.getForm(); + + for (const fieldKey in data) { + const field = form.getTextField(fieldKey); + if (field) { + field.setText(data[fieldKey]); + field.updateAppearances(font) + } + } + + const modifiedPdfBytes = await pdfDoc.save(); + + await fs.promises.writeFile(outputPath, modifiedPdfBytes); + } + // 添加 Text 水印 async addTextWatermark({ pdfDoc, text, docTitle }) { // console.log(StandardFonts, 'StandardFonts-->>') // 字体 diff --git a/src/utils/request.js b/src/utils/request.js index 15202ad5..e9994db9 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -23,6 +23,10 @@ const service = axios.create({ // request拦截器 service.interceptors.request.use(config => { + + // 设置标识来源 + config.headers['dataFrom'] = process.env.VUE_APP_DATA_FROM + // 是否需要设置 token const isToken = (config.headers || {}).isToken === false // 是否需要防止数据重复提交 @@ -30,8 +34,8 @@ service.interceptors.request.use(config => { if (getToken() && !isToken) { // config.headers['X-O-Auth'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers['X-Token'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - } + // 获取语言 let sLang = localStorage.getItem('locale') || navigator.language || 'zh-CN'; config.headers['lang'] = sLang; diff --git a/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue b/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue index fd458843..7d87d4bd 100644 --- a/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue +++ b/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue @@ -57,7 +57,7 @@ - +
@@ -108,7 +108,7 @@ return { svalue: this.value, subBillStart:1, - subBillEnd:1, + subBillEnd:null, openPdfView:false, // 计数器 @@ -290,29 +290,6 @@ that.showCounter++; - // const pdfDataList=[...pdfList]; - // for(let i=0;i{ - // loadingInstance.close(); - // that.pdfUrl=url; - // that.openPdfView = true; - // }) - // .catch(error => { - // // console.log(error) - // that.$modal.msgError("打印出错:"+erroMsg); - // }); - - } else if(code == 800){ // 全部获取完成 @@ -338,11 +315,21 @@ if(this.selTplCode=="TAN-GC-130"){ for(let i=0;i0){ + subBillStart=this.subBillStart; + } + + let subBillEnd=50; + if(this.subBillEnd){ + subBillEnd = this.subBillEnd; + } // 循环子单范围 - for(let i=this.subBillStart;i<=this.subBillEnd;i++){ + for(let i=subBillStart;i<=subBillEnd;i++){ let subBillCode = billCode+""+this.lpadZero(i,4); newOrderList.push(subBillCode); } + } }else{ newOrderList=[...orderList]; @@ -375,28 +362,6 @@ } that.showCounter++; - // const pdfDataList=[...pdfList]; - // for(let i=0;i{ - // loadingInstance.close(); - // that.pdfUrl=url; - // that.openPdfView = true; - // }) - // .catch(error => { - // // console.log(error) - // that.$modal.msgError("打印出错:"+erroMsg); - // }); - } else if(code == 800){ // 全部获取完成 @@ -423,7 +388,17 @@ for(let i=0;i0){ + subBillStart=this.subBillStart; + } + + let subBillEnd=50; + if(this.subBillEnd){ + subBillEnd = this.subBillEnd; + } + + for(let i=subBillStart;i<=subBillEnd;i++){ let subBillCode = billCode+""+this.lpadZero(i,4); newOrderList.push(subBillCode); } @@ -447,52 +422,21 @@ loadingInstance.close(); let pdfUtils=new PdfUtils({}); pdfUtils.getBlobUrl(pdfData.file, pdfData.ydSn+".pdf",true ) - - - // const pdfDataList=[...pdfList]; - // for(let i=0;i{ - // loadingInstance.close(); - // that.pdfUrl=url; - // that.openPdfView = true; - // }) - // .catch(error => { - // // console.log(error) - // that.$modal.msgError("打印出错:"+erroMsg); - // }); - } else if(code == 800){ // 全部获取完成 // console.log("===全部获取完成====>"); } - // if(success){ - // const pdfDataList=[...pdfList]; - // let pdfUtils=new PdfUtils({}); - // // for() - // // pdfUtils.mergePdf3(pdfDataList, (new Date()).getTime()+".pdf",true ) - // pdfUtils.mergePdf3(pdfDataList, fileName+".pdf",true ) - - // }else{ - // that.$modal.msgError("下载出错:"+erroMsg); - // } }); }, // 响应PDF预览 onPdfViewPrint(){ this.$emit("onPrint"); + }, + handleClose(){ + this.$emit("onPrintComplete"); } } diff --git a/src/views/emis/EmisBaseTools/WarehouseInNoPicker.vue b/src/views/emis/EmisBaseTools/WarehouseInNoPicker.vue index 253a61ce..f78f6760 100644 --- a/src/views/emis/EmisBaseTools/WarehouseInNoPicker.vue +++ b/src/views/emis/EmisBaseTools/WarehouseInNoPicker.vue @@ -1,28 +1,19 @@