From cd2b58c072e0db9ee4bd1fda369893845e86e00f Mon Sep 17 00:00:00 2001 From: linfso Date: Sun, 18 Aug 2024 11:38:53 +0800 Subject: [PATCH] md --- .env.development | 2 +- src/utils/TanexPrinterSdk.js | 28 ++++++++-- .../emis/EmisBaseTools/TanexPrinterPanel.vue | 53 ++++++++++++++++++- .../emisWarehouseInBatch/WarehouseStockIn.vue | 4 +- 4 files changed, 78 insertions(+), 9 deletions(-) diff --git a/.env.development b/.env.development index 4bcecd24..13c19f3d 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.100:17080' +VUE_APP_PRINTER_HOST = '192.168.88.189:17080' # 路由懒加载 diff --git a/src/utils/TanexPrinterSdk.js b/src/utils/TanexPrinterSdk.js index 12ac063f..5b974260 100644 --- a/src/utils/TanexPrinterSdk.js +++ b/src/utils/TanexPrinterSdk.js @@ -21,14 +21,13 @@ class TanexPrinterSdk { VERSION="1.0.0" MAX_SENT_RETRY_COUNT = 9; - WS_URL = 'ws://'+process.env.VUE_APP_PRINTER_HOST+'/ws'; - // WS_URL = "ws://192.168.88.189:17080/ws"; - HTTP_GET_PDF = 'http://'+process.env.VUE_APP_PRINTER_HOST+'/api/downPdfFile'; + XD_PRINTER_HOST = process.env.VUE_APP_PRINTER_HOST; + // WS_URL = 'ws://'+this.XD_PRINTER_HOST+'/ws'; + // HTTP_GET_PDF = 'http://'+this.XD_PRINTER_HOST+'/api/downPdfFile'; // HTTP_GET_PDF = "http://192.168.88.100:17080/api/downPdfFile"; - AUTH_TOKEN=null; WS_INIT = 0; @@ -96,6 +95,23 @@ class TanexPrinterSdk { this.start(); } + getPrinterHost(){ + return this.XD_PRINTER_HOST; + } + + restPrinterHost(host){ + this.XD_PRINTER_HOST=host; + if (this.ws && this.getWSReadyState() != this.WS_CLOSING && this.getWSReadyState() != this.WS_CLOSE) { + this.ws.close(); + this.ws=null; + }else{ + this.ws=null; + } + + this.connect(); + this.start(); + } + setOnOpen(callback){ this.onOpenCallback.push(callback); @@ -389,7 +405,9 @@ class TanexPrinterSdk { if (!this.ws || this.getWSReadyState() === this.WS_CLOSING || this.getWSReadyState() === this.WS_CLOSE) { try { - this.ws = new WebSocket(this.WS_URL); + let wsUrl = 'ws://'+this.XD_PRINTER_HOST+'/ws'; + + this.ws = new WebSocket(wsUrl); this.ws.onerror = () => { // console.log("ws onerror!"); diff --git a/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue b/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue index d056134a..5e820ad4 100644 --- a/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue +++ b/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue @@ -47,11 +47,14 @@
-
下载打印组件
+
+ + +
@@ -69,6 +72,30 @@ + + + + + + + + + + + + + + @@ -152,7 +179,17 @@ currentSelection:[], - pdfUtils:new PdfUtils({}) + openShowConfig:false, + + pdfUtils:new PdfUtils({}), + + form:{ + printerHost:null, + }, + + rules:{ + + }, }; }, @@ -170,6 +207,18 @@ // this.tanexPrinter.close(); }, methods: { + configPrinter(){ + this.form.printerHost=this.$tanexPrinter.getPrinterHost(); + console.log("===>===>",this.form.printerHost); + this.openShowConfig=true; + }, + setupPrinter(){ + console.log("===>===>",this.form.printerHost); + if(this.form.printerHost){ + this.$tanexPrinter.restPrinterHost(this.form.printerHost); + } + this.openShowConfig=false; + }, getUUID() { return Math.random().toString(36).substring(3,10); }, diff --git a/src/views/emis/emisWarehouseInBatch/WarehouseStockIn.vue b/src/views/emis/emisWarehouseInBatch/WarehouseStockIn.vue index d9da09ca..2531bf58 100644 --- a/src/views/emis/emisWarehouseInBatch/WarehouseStockIn.vue +++ b/src/views/emis/emisWarehouseInBatch/WarehouseStockIn.vue @@ -161,7 +161,9 @@ -