This commit is contained in:
aihe 2024-06-25 16:36:44 +08:00
parent 405015882a
commit 396e61fc0f

View File

@ -34,15 +34,19 @@ export default {
prtPercentage: 0, // 打印进度 prtPercentage: 0, // 打印进度
paperWidth: 480, paperWidth: 480,
imgRes: {}, imgRes: {},
prtQueList: [],
lastExeMark: undefined,
} }
}, },
mounted () { mounted () {
this.initData() this.initData()
}, },
unmounted() { unmounted() {
}, },
methods: { methods: {
async initData() { async initData() {
}, },
// 打印 // 打印
handlePrint(){ handlePrint(){
@ -81,16 +85,33 @@ export default {
} }
}, },
// 给外部调用api,打印自定义图 // 给外部调用api,打印自定义图
async callPrint({ paperWidth, imgRes } = {}) { async callPrint(obj) {
this.paperWidth = paperWidth || this.paperWidth this.prtQueList.push(obj)
this.imgRes = imgRes clearTimeout(this.lastExeMark)
this.lastExeMark = setTimeout(()=> {
this.finallyExecPrint()
}, 500)
},
async finallyExecPrint() {
let conSta = await this.$refs.curBlueTooth.autoConnect() let conSta = await this.$refs.curBlueTooth.autoConnect()
this.$emit('autoConnectCallback', conSta) this.$emit('autoConnectCallback', conSta)
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) { if(conSta) {
await this.handlePrint() await this.handlePrint()
return true this.prtQueList[i] = undefined // 打印成功 清除当前数据
} }
} }
}
this.prtQueList = []
return true
}
} }
} }
</script> </script>