From 984953abe1b6e5dca7075ba4adda6a41b8ce9272 Mon Sep 17 00:00:00 2001 From: linfso Date: Thu, 23 May 2024 21:41:55 +0800 Subject: [PATCH] md --- src/components/XdTextareaInput/index.vue | 7 +- src/utils/TanexPrinterSdk.js | 107 ++++++++++++++++-- .../emis/emisTmsPack/emisTmsPackForm.vue | 2 +- src/views/emis/emisTmsPack/index.vue | 4 +- .../emis/emisWaybill/waybillIsPrinted.vue | 33 +++--- 5 files changed, 120 insertions(+), 33 deletions(-) diff --git a/src/components/XdTextareaInput/index.vue b/src/components/XdTextareaInput/index.vue index 9a65aad1..6992a083 100644 --- a/src/components/XdTextareaInput/index.vue +++ b/src/components/XdTextareaInput/index.vue @@ -9,7 +9,7 @@ @@ -45,6 +45,11 @@ export default { } }, methods: { + onClear(){ + this.svalue=''; + this.$emit("input", this.svalue); + this.dispatch('ElFormItem', 'el.form.blur'); + }, onBlur(val){ this.$emit("input", this.svalue); this.dispatch('ElFormItem', 'el.form.blur'); diff --git a/src/utils/TanexPrinterSdk.js b/src/utils/TanexPrinterSdk.js index fe19e930..82ded3f4 100644 --- a/src/utils/TanexPrinterSdk.js +++ b/src/utils/TanexPrinterSdk.js @@ -6,6 +6,7 @@ import { download } from '@/utils/request' getPrinterList: 获取打印机列表 getPrintTplList: 获取打印模版列表 batchPrint:发送打印 + batchGetPDF:PDF预览和下载 getPrinterVer:获取打印组件版本信息 printerIsRead:打印机已经OK的信号 @@ -44,6 +45,7 @@ class TanexPrinterSdk { onGetPrinterCallback =[]; onGetPrintTplCallback =[]; + onBatchGetPDFCallback = []; // 自定义 回调函数 callbacks ={} @@ -53,6 +55,11 @@ class TanexPrinterSdk { // 打印模版列表 printTplList = [] + // PDF文件缓存 + recievePdfFileList = [] + sendPdfFileListCount = 0 + pdfFileReceiveMap = new Map(); + // 默认打印机 defaultPrinter = null; @@ -100,6 +107,10 @@ class TanexPrinterSdk { this.onGetPrintTplCallback.push(callback); } + setOnBatchGetPDF(callback){ + this.onBatchGetPDFCallback.push(callback); + } + // 获取打印机列表 getPrinterTplList(){ return this.printerList; @@ -121,15 +132,24 @@ class TanexPrinterSdk { } // 下载PDF文件 - downPdfFile(ydSn,tplName,printerName){ - let link = document.createElement('a'); - link.style.display = 'none'; - link.href = this.HTTP_GET_PDF + '?ydSn=' + ydSn+"&tplName="+tplName+"&printerName="+printerName; - // window.open(link.href, '_blank'); - document.body.appendChild(link); - link.click(); + // downPdfFile(ydSn,tplName,printerName){ + // let link = document.createElement('a'); + // link.style.display = 'none'; + // link.href = this.HTTP_GET_PDF + '?ydSn=' + ydSn+"&tplName="+tplName+"&printerName="+printerName; + // // window.open(link.href, '_blank'); + // document.body.appendChild(link); + // link.click(); + // } + + + // 批量获取PDF文件 + batchGetPDF(tplName,printerName,orderList){ + if(tplName&&printerName&&orderList&&orderList.length>0){ + this.sendBatchGetPDFCMD(tplName,printerName,orderList); + } } + // 批量打印 batchPrint(tplName,printerName,orderList){ if(tplName&&printerName&&orderList&&orderList.length>0){ @@ -166,6 +186,27 @@ class TanexPrinterSdk { } } + sendBatchGetPDFCMD(tplName,printerName,orderList){ + // {"CMD":"batchGetPDF","status":"1","Data":["DT20210901001","DT20210901002"]} + var printCmd={}; + printCmd['CMD']="batchGetPDF"; + printCmd['Status']="1"; + if(orderList!=null && orderList.length>0){ + let printData={ + "tplName":tplName, + "printerName":printerName, + "orderList":orderList.toString() + } + + this.recievePdfFileList = [] + this.sendPdfFileListCount = orderList.length; + + printCmd['Data']=printData + console.log(JSON.stringify(printCmd)); + this.send(JSON.stringify(printCmd),null); + } + } + sendGetPrinterListCMD(){ // {"CMD":"getPrinterList","status":"1","Data":""} var printCmd={}; @@ -272,7 +313,7 @@ class TanexPrinterSdk { } } - if(msg["CMD"]=='getPrintTplList'){ + else if(msg["CMD"]=='getPrintTplList'){ this.innerGetPrintTplList(msg) if(this.onGetPrintTplCallback.length>0){ this.onGetPrintTplCallback.forEach(callback=>{ @@ -282,6 +323,10 @@ class TanexPrinterSdk { }) } } + else if(msg["CMD"]=='batchGetPDF'){ + this.innerBatchGetPDF(msg) + + } // 通知其他客户端 @@ -339,6 +384,50 @@ class TanexPrinterSdk { } } + innerBatchGetPDF(msg){ + console.log("innerBatchGetPDF") + + console.log(msg) + if(this.recievePdfFileList.length= this.sendPdfFileListCount){ + + if(this.onBatchGetPDFCallback.length>0){ + this.onBatchGetPDFCallback.forEach(callback=>{ + if(callback!=null){ + // 把PDF文件传给终端处理 + callback(this.recievePdfFileList); + + // 发送完成后数据清空 + this.recievePdfFileList=[]; + this.pdfFileReceiveMap=new Map(); + } + }) + } + + console.log("文件已接收完成"); + return; + } + + + + } + + + jsonToObj(json){ return JSON.parse(json) @@ -367,7 +456,7 @@ class TanexPrinterSdk { this.ws.send(data) return 1; } else { - // console.log("Ws is abnormal,send faild!!") + console.log("Ws is abnormal,send faild!!") return -1 } } diff --git a/src/views/emis/emisTmsPack/emisTmsPackForm.vue b/src/views/emis/emisTmsPack/emisTmsPackForm.vue index c3acaa94..0cbd51b6 100644 --- a/src/views/emis/emisTmsPack/emisTmsPackForm.vue +++ b/src/views/emis/emisTmsPack/emisTmsPackForm.vue @@ -172,7 +172,7 @@ export default { destCountryName: null, blUnpack: null, sendStiteCode: null, - nextStiteCode: null, + nextSiteCode: null, nextStation: null, totalParcelQty: null, totalWaybillQty: null, diff --git a/src/views/emis/emisTmsPack/index.vue b/src/views/emis/emisTmsPack/index.vue index f0ea009c..e1a03e17 100644 --- a/src/views/emis/emisTmsPack/index.vue +++ b/src/views/emis/emisTmsPack/index.vue @@ -265,7 +265,7 @@ @@ -438,7 +438,7 @@ export default { const curList = response.rows import('@/vendor/Export2Excel').then(excel => { const tHeader = ['id','合包号','合包名称','合包时间','目的国家','目的国家名称','是否可拆','发出网点','下一网点','下一站','总件数','总运单数','总体积','总重量','合包状态','扩展数据','操作员','ext1','ext2','ext3','ext4','备注','租户ID','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','创建网点','更新网点',]; - const filterVal = ['id','packNo','packName','packDate','destCountry','destCountryName','blUnpack','sendStiteCode','nextStiteCode','nextStation','totalParcelQty','totalWaybillQty','totalVolume','totalWeight','packStatus','extData','opMan','ext1','ext2','ext3','ext4','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime','createSite','updateSite',]; + const filterVal = ['id','packNo','packName','packDate','destCountry','destCountryName','blUnpack','sendStiteCode','nextSiteCode','nextStation','totalParcelQty','totalWaybillQty','totalVolume','totalWeight','packStatus','extData','opMan','ext1','ext2','ext3','ext4','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime','createSite','updateSite',]; const data = this.formatJson(filterVal, curList, response.rows) excel.export_json_to_excel({ header: tHeader, diff --git a/src/views/emis/emisWaybill/waybillIsPrinted.vue b/src/views/emis/emisWaybill/waybillIsPrinted.vue index 44bfd01b..cb17b84f 100644 --- a/src/views/emis/emisWaybill/waybillIsPrinted.vue +++ b/src/views/emis/emisWaybill/waybillIsPrinted.vue @@ -245,26 +245,6 @@ - - - - - - @@ -736,6 +716,11 @@ export default { this.tanexPrinter.setOnError(this.onPrinterError); this.tanexPrinter.setOnGetPrinter(this.onGetPrinter); this.tanexPrinter.setOnGetPrintTpl(this.onGetPrintTpl); + this.tanexPrinter.setOnBatchGetPDF(this.onBatchGetPDF); + + }, + onBatchGetPDF(list){ + console.log(list); }, onPrinterOpen(evt){ console.log("onPrinterOpen") @@ -783,6 +768,13 @@ export default { }, async handlePrintPreview(){ + let orderList=[]; + this.currentSelection.forEach(item=>{ + orderList.push(item.billCode); + }); + this.tanexPrinter.batchGetPDF(this.selTplName,this.selPrinterName,orderList) + }, + async handlePrintPreview_old(){ let pdfUrlList=[]; this.currentSelection.forEach(item=>{ let url=this.tanexPrinter.getPdfUrl(item.billCode,this.selTplName,this.selPrinterName); @@ -813,6 +805,7 @@ export default { pdfUtils.mergePdf2(pdfUrlList, (new Date()).getTime()+".pdf" ,true); }, + /** 查询运单列表列表 */ getList() { this.loading = true;