diff --git a/package.json b/package.json index a33a380e..07dad3f5 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "vue-meta": "2.4.0", "vue-okr-tree": "^1.0.17", "vue-pdf": "^4.2.0", + "vue-pdf-signature": "^4.2.7", "vue-print-nb": "^1.7.5", "vue-property-decorator": "^9.1.2", "vue-router": "3.4.9", diff --git a/src/api/emis/emisWaybill.js b/src/api/emis/emisWaybill.js index ed07ac07..12f90fa3 100644 --- a/src/api/emis/emisWaybill.js +++ b/src/api/emis/emisWaybill.js @@ -9,14 +9,14 @@ export function listEmisWaybill(query) { }) } -// 查询运单列表详细 -export function getInfoByBillCode(billCode) { - return request({ - url: '/emis/emisWaybill/getInfoByBillCode', - method: 'get', - params: {billCode: billCode} - }) -} +// 查询运单详细 +// export function getInfoByBillCode(billCode) { +// return request({ +// url: '/emis/emisWaybill/getInfoByBillCode', +// method: 'get', +// params: {billCode: billCode} +// }) +// } export function getWaybillDetail(billCode) { return request({ diff --git a/src/components/PdfViewer/index.vue b/src/components/PdfViewer/index.vue index ec87fedb..c81445a4 100644 --- a/src/components/PdfViewer/index.vue +++ b/src/components/PdfViewer/index.vue @@ -1,89 +1,13 @@ @@ -126,7 +50,9 @@ export default { pdfUrl(newVal) { console.log(this.pdfUrl) if(this.pdfUrl){ - this.src=this.pdfUrl; + // this.src=this.pdfUrl; + this.pdfLoadUrl='/static/pdfjs/4.2.67/web/viewer.html?file=' + encodeURIComponent(this.pdfUrl) + console.log(this.pdfLoadUrl) } }, }, @@ -253,9 +179,10 @@ export default { .tools { display: flex; - background: #e1e1e1; - width: 100%; - z-index:9999; + z-index: 9999; + position: absolute; + top: 20px; + right: 30px; } .total { diff --git a/src/utils/TanexPrinterSdk.js b/src/utils/TanexPrinterSdk.js index 9f3d4386..a26a1948 100644 --- a/src/utils/TanexPrinterSdk.js +++ b/src/utils/TanexPrinterSdk.js @@ -64,6 +64,12 @@ class TanexPrinterSdk { // 默认打印机 defaultPrinter = null; + defaultTplCode = null; + + isSendSetToken=false; + isSendGetTpl=false; + isSendGetPrinter=false; + // 标识:是否连接成功 , 记录重试的次数,重新连接尝试的次数 connected = false; printerIsRead = false; @@ -130,29 +136,13 @@ class TanexPrinterSdk { return this.defaultPrinter; } - // 获取pdf链接 - getPdfUrl(ydSn,tplName,printerName){ - return this.HTTP_GET_PDF + '?ydSn=' + ydSn+"&tplName="+tplName+"&printerName="+printerName; - } - - // 下载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(); - // } - - // 批量获取PDF文件 - batchGetPDF(tplName,printerName,orderList,callback){ - if(tplName&&printerName&&orderList&&orderList.length>0){ + batchGetPDF(tplCode,printerName,orderList,callback){ + if(tplCode&&printerName&&orderList&&orderList.length>0){ this.setOnBatchGetPDF(callback); // 超时计算 - this.sendBatchGetPDFCMD(tplName,printerName,orderList); + this.sendBatchGetPDFCMD(tplCode,printerName,orderList); this.recievePdfFileTimer = setTimeout(function(){ if(this.onBatchGetPDFCallback){ if(this.onBatchGetPDFCallback.length>0){ @@ -170,19 +160,30 @@ class TanexPrinterSdk { } } - // 批量打印 - batchPrint(tplName,printerName,orderList){ - if(tplName&&printerName&&orderList&&orderList.length>0){ - this.sendBatchPrintCMD(tplName,printerName,orderList); + batchPrint(tplCode,printerName,orderList){ + if(tplCode&&printerName&&orderList&&orderList.length>0){ + this.sendBatchPrintCMD(tplCode,printerName,orderList); } } + refreshPrintTpl(){ + this.sendRefreshPrintTplListCMD(); + } + + getRequestId() { + let requestId = 'req' + new Date().getTime().toString(36) + Math.random().toString(36).substring(2, 9); + return requestId; + } //--内部方法-------------------------------------------------------------- sendSetTokenCMD(){ + // if(this.isSendSetToken){ + // return; + // } // {"CMD":"setToken","status":"1","Data":"token"} var printCmd={}; + printCmd['RequestId']=this.getRequestId(); printCmd['CMD']="setToken"; printCmd['Status']="1"; printCmd['Data']=getToken(); @@ -190,14 +191,15 @@ class TanexPrinterSdk { this.send(JSON.stringify(printCmd),null); } - sendBatchPrintCMD(tplName,printerName,orderList){ + sendBatchPrintCMD(tplCode,printerName,orderList){ // {"CMD":"batchPrint","status":"1","Data":["DT20210901001","DT20210901002"]} var printCmd={}; + printCmd['RequestId']=this.getRequestId(); printCmd['CMD']="batchPrint"; printCmd['Status']="1"; if(orderList!=null && orderList.length>0){ let printData={ - "tplName":tplName, + "tplCode":tplCode, "printerName":printerName, "orderList":orderList.toString() } @@ -207,14 +209,15 @@ class TanexPrinterSdk { } } - sendBatchGetPDFCMD(tplName,printerName,orderList){ + sendBatchGetPDFCMD(tplCode,printerName,orderList){ // {"CMD":"batchGetPDF","status":"1","Data":["DT20210901001","DT20210901002"]} var printCmd={}; + printCmd['RequestId']=this.getRequestId(); printCmd['CMD']="batchGetPDF"; printCmd['Status']="1"; if(orderList!=null && orderList.length>0){ let printData={ - "tplName":tplName, + "tplCode":tplCode, "printerName":printerName, "orderList":orderList.toString() } @@ -230,7 +233,13 @@ class TanexPrinterSdk { sendGetPrinterListCMD(){ // {"CMD":"getPrinterList","status":"1","Data":""} + + // if(this.isSendGetPrinter){ + // return; + // } + var printCmd={}; + printCmd['RequestId']=this.getRequestId(); printCmd['CMD']="getPrinterList"; printCmd['Status']="1"; printCmd['Data']=""; @@ -239,8 +248,12 @@ class TanexPrinterSdk { } sendGetPrintTplListCMD(){ + // if(this.isSendGetTpl){ + // return; + // } // {"CMD":"getPrintTplList","status":"1","Data":""} var printCmd={}; + printCmd['RequestId']=this.getRequestId(); printCmd['CMD']="getPrintTplList"; printCmd['Status']="1"; printCmd['Data']=""; @@ -248,12 +261,23 @@ class TanexPrinterSdk { this.send(JSON.stringify(printCmd),null); } + sendRefreshPrintTplListCMD(){ + // {"CMD":"getPrintTplList","status":"1","Data":"reInit"} + var printCmd={}; + printCmd['RequestId']=this.getRequestId(); + printCmd['CMD']="getPrintTplList"; + printCmd['Status']="1"; + printCmd['Data']="reInit"; + // console.log(JSON.stringify(printCmd)); + this.send(JSON.stringify(printCmd),null); + } + // 连接服务器的方法 connect() { // 连接服务器 if (!window.WebSocket) { - // console.log('您的浏览器不支持WebSocket'); + console.log('您的浏览器不支持WebSocket'); return null; } @@ -300,6 +324,10 @@ class TanexPrinterSdk { this.connected = false; this.connectRetryCount++; + if(this.connectRetryCount>120){ + this.connectRetryCount=0; + } + if(this.onCloseCallback.length>0){ this.onCloseCallback.forEach(callback=>{ if(callback!=null){ @@ -307,10 +335,11 @@ class TanexPrinterSdk { } }) } + // * this.connectRetryCount setTimeout(() => { this.connect() - }, 500 * this.connectRetryCount) + }, 1000 ) }; this.ws.onmessage = e => { @@ -374,6 +403,10 @@ class TanexPrinterSdk { innerGetPrinterList(msg){ // console.log("innerGetPrinterList") + + + this.isSendGetPrinter=true; + if(msg){ this.printerList=[]; // console.log(msg); @@ -391,22 +424,21 @@ class TanexPrinterSdk { innerGetPrintTplList(msg){ // console.log("innerGetPrintTplList") + + this.isSendGetTpl=false; + if(msg){ this.printTplList=[]; msg.Data.tplList.forEach(item=>{ - let optionItem={ - label:item, - value:item - } - this.printTplList.push(optionItem); - this.selTplName=this.printTplList[0].value; + this.printTplList.push(item); + this.defaultTplCode=this.printTplList[0].tplCode; }) + } } innerBatchGetPDF(msg){ // console.log("innerBatchGetPDF") - // console.log(msg) // 有出错,停止接收数据 if(msg.Status!='2'){ clearTimeout(this.recievePdfFileTimer); @@ -462,9 +494,6 @@ class TanexPrinterSdk { } - - - jsonToObj(json){ return JSON.parse(json) } @@ -487,6 +516,7 @@ class TanexPrinterSdk { // 发送数据的方法 send(data) { + console.log("send:"+data) if (this.getWSReadyState() === this.WS_OPEN ) { this.sendRetryCount = 0 this.ws.send(data) @@ -512,7 +542,7 @@ class TanexPrinterSdk { // this.ws.ping(); this.ws.send(0x9); } - }, 10000); + }, 1000); } } diff --git a/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue b/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue index 39435cf6..7b1996f2 100644 --- a/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue +++ b/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue @@ -11,15 +11,28 @@
模板:
- + +
+
+ 子单: + + - + + +
+
打印机:
@@ -40,10 +53,10 @@
- -
- -
+ +
+ +
@@ -74,7 +87,8 @@ data() { return { svalue: this.value, - + subBillStart:1, + subBillEnd:1, openPdfView:false, pdfUrl:null, @@ -89,7 +103,7 @@ printerList:[], printTplList:[], - selTplName:null, + selTplCode:null, selPrinterName:null, currentSelection:[], @@ -148,26 +162,74 @@ }, onGetPrintTpl(msg){ // console.log("onGetPrintTpl") + + this.printTplList=[]; + this.printTplList=this.tanexPrinter.getPrintTplList(); - this.selTplName=this.printTplList[0].value; + // console.log(this.printTplList) + + this.selTplCode=this.printTplList[0].tplCode; + }, + refreshPrintTpl(){ + this.printTplList=[]; + this.selTplCode=null; + this.tanexPrinter.refreshPrintTpl() + }, + lpadZero(val,len) { + return (new Array(len + 1).join('0') + val).slice(-len); }, batchPrint(orderList){ let that = this; + let newOrderList=[]; if(orderList){ this.orderList=[...orderList] } - this.tanexPrinter.batchPrint(that.selTplName,that.selPrinterName,that.orderList) + // 打印子单 + if(this.selTplCode=="TAN-GC-130"){ + for(let i=0;i { - console.log(error) + // console.log(error) that.$modal.msgError("打印出错:"+erroMsg); }); }else{ @@ -188,15 +250,30 @@ }); }, downPDF(orderList){ - let that =this; + let that = this; + let newOrderList=[]; if(orderList){ this.orderList=[...orderList] } + // 打印子单 + if(this.selTplCode=="TAN-GC-130"){ + for(let i=0;i diff --git a/src/views/emis/emisWaybill/waybillIsPrinted.vue b/src/views/emis/emisWaybill/waybillIsPrinted.vue index f1850fe5..7e4ff6f4 100644 --- a/src/views/emis/emisWaybill/waybillIsPrinted.vue +++ b/src/views/emis/emisWaybill/waybillIsPrinted.vue @@ -1,6 +1,6 @@