From 00a363f1ef1e2ded9f7a8e933cd89d863458a3b4 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期三, 06 八月 2025 10:09:06 +0800
Subject: [PATCH] 修改工序出站汇报单前保存
---
components/blueToothConnector/blueToothConnector.vue | 74 +++++++++++++++++++++----------------
1 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/components/blueToothConnector/blueToothConnector.vue b/components/blueToothConnector/blueToothConnector.vue
index 893395c..d642203 100644
--- a/components/blueToothConnector/blueToothConnector.vue
+++ b/components/blueToothConnector/blueToothConnector.vue
@@ -50,13 +50,15 @@
getAddress
} from '../../utils/auth';
import blueToothTool from '@/plugins/BluetoothTool.js';
+import { nextTick } from "vue";
export default {
name: "blueToothPrinterConnector",
data() {
return {
discoveredDevices: [], // 鏌ヨ鍒扮殑璁惧
connectedDeviceId: "",
- readSuccess: false
+ readSuccess: false,
+ clock: null,
};
},
methods: {
@@ -94,12 +96,8 @@
},
fail: async (e) => {
console.error(e)
- switch (e.code) {
- case "10009":
- this.showToast("姝よ澶囦笉鏀寔璁惧鎼滅储鍔熻兘!");
- break;
- default:
- console.error(e);
+ if(e.errCode == 10009) {
+ this.showToast('姝よ澶囦笉鏀寔璁惧鎼滅储鍔熻兘!');
}
}
})
@@ -173,22 +171,28 @@
});
},
async checkReadSuccess(count) {
+ // 鎵归噺鎻掑叆鏃讹紝濡傛灉鍓嶄竴娆″彂閫佹垚鍔燂紝鍒欐竻闄ゅ墠涓�娆$殑鏃堕挓
+ if (this.clock != null) {
+ this.clock.stop();
+ this.clock = null;
+ }
let that = this
return new Promise((resolve, reject) => {
let currentCount = 0;
- let clock = new CommonUtils.timeClock(() => {
+ that.clock = new CommonUtils.timeClock(() => {
+ console.log(that.readSuccess)
currentCount++;
- if (this.readSuccess == true) {
- clock.stop();
+ if (that.readSuccess == true) {
+ that.clock.stop();
resolve(true);
} else if (currentCount >= count) {
- clock.stop();
+ that.clock.stop();
reject(new Error('璇诲彇瓒呮椂'));
}
}, 2000);
// 鍚姩鏃堕挓
- clock.start();
+ that.clock.start();
});
},
async sendMessage(cmd) {
@@ -196,7 +200,7 @@
uni.showLoading({
title: "鍙戦�佷腑..."
})
- console.log("msg: " + cmd);
+ // console.log("msg: " + cmd);
let toast = (msg) => {
uni.showToast({
icon: 'none',
@@ -207,23 +211,29 @@
uni.hideLoading()
}, 3000)
}
-
- const result = blueToothTool.sendByteData(cmd);
- if (!result) {
- return toast("鍙戦�佸け璐�,璇烽噸璇�...")
- }
- this.checkReadSuccess(5)
- .then((res) => {
- if(res === true) {
- toast('鍙戦�佹垚鍔�!!!')
+ let that = this
+ return new Promise((resolve, reject) => {
+ const result = blueToothTool.sendByteData(cmd);
+ if (!result) {
+ toast("鍙戦�佸け璐�,璇烽噸璇�...")
+ reject(false)
}
+ that.checkReadSuccess(5)
+ .then((res) => {
+ if (res === true) {
+ toast('鍙戦�佹垚鍔�!!!')
+ resolve(true)
+ }
+ })
+ .catch((err) => {
+ toast('璁惧寮傚父,璇锋鏌ヨ澶囩姸鎬�...')
+ reject(false)
+ })
+ .finally(() => {
+ that.readSuccess = false
+ })
})
- .catch((err) => {
- toast('璁惧寮傚父,璇锋鏌ヨ澶囩姸鎬�...')
- })
- .finally(() => {
- this.readSuccess = false
- })
+
},
uint8ArrayToSignedArray(uint8Array) {
let signedArray = new Array(uint8Array.length);
@@ -256,10 +266,10 @@
console.log("鎼滅储瀹屾垚");
},
readDataCallback: (dataByteArr) => {
- /* if(that.receiveDataArr.length >= 200) {
- that.receiveDataArr = [];
- }
- that.receiveDataArr.push.apply(that.receiveDataArr, dataByteArr); */
+ // if(that.receiveDataArr.length >= 200) {
+ // that.receiveDataArr = [];
+ // }
+ // that.receiveDataArr.push.apply(that.receiveDataArr, dataByteArr);
this.readSuccess = true
console.log("璇诲彇瀹屾垚" + dataByteArr);
},
--
Gitblit v1.9.1