From 396e61fc0ffebc770432883e82114123a368a9a2 Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Tue, 25 Jun 2024 16:36:44 +0800 Subject: [PATCH] uu --- .../render-template-native.vue | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/components/tpx-bluetooth-print/render-template-native.vue b/components/tpx-bluetooth-print/render-template-native.vue index 75593be..15361d8 100644 --- a/components/tpx-bluetooth-print/render-template-native.vue +++ b/components/tpx-bluetooth-print/render-template-native.vue @@ -34,15 +34,19 @@ export default { prtPercentage: 0, // 打印进度 paperWidth: 480, imgRes: {}, + prtQueList: [], + lastExeMark: undefined, } }, mounted () { this.initData() }, unmounted() { + }, methods: { async initData() { + }, // 打印 handlePrint(){ @@ -81,15 +85,32 @@ export default { } }, // 给外部调用api,打印自定义图 - async callPrint({ paperWidth, imgRes } = {}) { - this.paperWidth = paperWidth || this.paperWidth - this.imgRes = imgRes + async callPrint(obj) { + this.prtQueList.push(obj) + clearTimeout(this.lastExeMark) + this.lastExeMark = setTimeout(()=> { + this.finallyExecPrint() + }, 500) + }, + + async finallyExecPrint() { let conSta = await this.$refs.curBlueTooth.autoConnect() this.$emit('autoConnectCallback', conSta) - if(conSta) { - await this.handlePrint() - return true + + for(let i = 0; i < this.prtQueList.length; i ++) { + let { paperWidth, imgRes } = this.prtQueList[i] + if(imgRes) { + this.paperWidth = paperWidth || this.paperWidth + this.imgRes = imgRes + if(conSta) { + await this.handlePrint() + this.prtQueList[i] = undefined // 打印成功 清除当前数据 + } + } + } + this.prtQueList = [] + return true } } }