From 57bd2b81a380d56cf3520c57ea22cc937b5f81c3 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期五, 19 十二月 2025 16:58:33 +0800
Subject: [PATCH] Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev
---
components/labelPrinterComponent/labelPrinterComponent.vue | 68 ++++++++++++++++++++++++---------
1 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/components/labelPrinterComponent/labelPrinterComponent.vue b/components/labelPrinterComponent/labelPrinterComponent.vue
index 86f6279..2c408c5 100644
--- a/components/labelPrinterComponent/labelPrinterComponent.vue
+++ b/components/labelPrinterComponent/labelPrinterComponent.vue
@@ -1,10 +1,12 @@
<template>
- <view>
- <uni-popup ref="popup" type="bottom" popupshow @close="popupCloseHandler">
+ <view class="container" :hidden="isPopup === false">
+ <uni-popup ref="popup" type="bottom" popupshow @change="popupChange">
<view style="height: 80vh; background-color: #fff; padding-bottom: 2rem;">
<blueToothConnectorVue ref="bt"></blueToothConnectorVue>
</view>
</uni-popup>
+ <!-- 浣跨敤uni-popup绫荤殑缁勪欢鏃讹紝褰損opup涓嶆樉绀烘椂锛岀粍浠舵爲涓病鏈塸opup鍐呯殑妯$粍锛屾棤娉曚娇鐢╮ef璋冪敤妯$粍鍐呯殑鍑芥暟锛屾晠闇�瑕佸湪澶栭儴鎸傝浇涓�涓�忔槑鐨勭粍浠� -->
+ <blueToothConnectorVue style="display: none;position: absolute; bottom: 0;right: 0;" ref="bt2"></blueToothConnectorVue>
</view>
</template>
@@ -31,12 +33,13 @@
import {
CommonUtils
} from '../../utils/common';
+import { nextTick } from "vue";
export default {
name: "lablePrinterComponent",
data() {
return {
- blueToothConnector: null,
+ isPopup: false,
};
},
props: {
@@ -53,20 +56,24 @@
blueToothConnectorVue
},
methods: {
- openPopup() {
+ async openPopup() {
this.$refs.popup.open();
+ // 鍦╬opup涓殑鎿嶄綔閽堝ref bt瀵瑰簲鐨勭粍浠讹紝闇�瑕佸皢bt缁勪欢鐨勭姸鎬佷笌bt2杩涜涓�娆″悓姝�
this.$nextTick(() => {
- this.blueToothConnector = this.$refs.bt
+ this.$refs.bt2 = this.$refs.bt
})
-
+
},
- popupCloseHandler() {
-
+ async popupChange(e) {
+ this.isPopup = e['show']
+ await this.$nextTick()
},
async batchPrint(commandList) {
+ console.log(this.$refs.bt2)
let vm = this;
let binarys = [];
for (let command of commandList) {
+ console.log('command: ',command);
switch (vm.printMode) {
case "tspl":
let tspl = await vm.$printer.tspl().clear();
@@ -93,14 +100,34 @@
})
}
}
-
+ let sendSuccess = false
for(let binary of binarys){
- let sendSuccess = await this.blueToothConnector.sendMessage(binary);
- console.log("鍙戦�佹槸鍚︽垚鍔燂細 ", sendSuccess)
- if(sendSuccess === false) {
- return
- }
+
+ try{
+ sendSuccess = await this.$refs.bt2.sendMessage(binary);
+ console.log("褰撳墠鍙戦�佹槸鍚︽垚鍔燂細 ", sendSuccess)
+
+ }catch(e) {
+ uni.showToast({
+ icon: 'none',
+ title: e
+ })
+ // 鏂紑钃濈墮杩炴帴
+ this.$refs.bt2.closeBluetooth()
+ // 鍋滄浼犺緭
+ return
+ }
+
}
+
+ if(sendSuccess === false) {
+ return
+ }else {
+ return uni.showToast({
+ icon: 'none',
+ title: '鎵撳嵃鎴愬姛'
+ })
+ }
},
async execPrint() {
// 妫�鏌ヨ摑鐗欒繛鎺�
@@ -116,12 +143,11 @@
this.showToast("鏃犺澶囪繛鎺�!")
return
}
-
try {
if (typeof this.printInfo === 'function') {
// 浼犲叆鐨刾rintInfo鏄嚱鏁帮紝鐩存帴鎵ц
let msg = await this.printInfo()
- this.blueToothConnector.sendMessage(msg)
+ this.$refs.bt2.sendMessage(msg)
} else if (typeof this.printInfo === 'string') {
// 浼犲叆鐨勫弬鏁版槸瀛楃涓诧紝鍒欐牴鎹墦鍗版ā寮忚皟鐢ㄤ笉鍚岀殑鎵撳嵃API
// 杩欓噷鐨勫瓧绗︿覆闇�瑕佸搴旀墦鍗版ā寮�
@@ -142,21 +168,21 @@
tspl.raw(Raw.text(printStr))
console.log("print command锛歕n" + tspl.command().string())
binary = tspl.command().binary();
- await vm.blueToothConnector.sendMessage(binary);
+ await this.$refs.bt2.sendMessage(binary);
break;
case "cpcl":
const cpcl = await vm.$printer.cpcl().clear();
cpcl.raw(Raw.text(printStr))
console.log("print command锛歕n" + cpcl.command().string())
binary = cpcl.command().binary();
- await vm.blueToothConnector.sendMessage(binary);
+ await this.$refs.bt2.sendMessage(binary);
break;
case "esc":
const esc = await vm.$printer.esc().clear();
esc.raw(Raw.text(printStr))
console.log("print command锛歕n" + esc.command().string())
binary = esc.command().binary();
- await vm.blueToothConnector.sendMessage(binary);
+ await this.$refs.bt2.sendMessage(binary);
break;
default:
return uni.showToast({
@@ -188,4 +214,8 @@
* {
box-sizing: border-box;
}
+ .container[hidden] {
+ padding: 0 !important;
+ height: 0 !important;
+ }
</style>
\ No newline at end of file
--
Gitblit v1.9.1