From f6fb40bfcfb844f96174e08ea0d3dfb4359377f7 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 20 十月 2025 10:29:23 +0800
Subject: [PATCH] 装箱单零件描述过长的打印样式调整

---
 pages/wareHouse/nuclearScale/nuclearscalerecord.vue |  451 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 356 insertions(+), 95 deletions(-)

diff --git a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
index b9dbc75..397062a 100644
--- a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
+++ b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -188,25 +188,34 @@
 				connectionStatus: "disconnected", // 杩炴帴鐘舵��: disconnected, connecting, connected
 				printStatus: "idle", // 鎵撳嵃鐘舵��: idle, printing, error
 				errorMessage: "", // 閿欒淇℃伅
-				verificationNo:''
+				verificationNo: "",
+				failedPrintJobs: [],
 			};
-	},
-	onLoad(options) {
-			this.verificationNo = JSON.parse(decodeURIComponent(options.verificationNo))
+		},
+		onLoad(options) {
+			this.verificationNo = JSON.parse(
+				decodeURIComponent(options.verificationNo)
+			);
 			this.getlist();
 			// 鍒濆鍖朣DK
 			jcapi.initSDK();
+
+			// 灏濊瘯鎭㈠涔嬪墠鐨勮摑鐗欒繛鎺ョ姸鎬�
+			this.restoreBluetoothConnection();
+
 			// 鐩戝惉椤电爜鍥炶皟
 			jcapi.didReadPrintCountInfo(function(r) {
-				console.log('椤电爜',r);
+				console.log("椤电爜", r);
 			});
 
 			// 鐩戝惉閿欒鍥炶皟
 			jcapi.didReadPrintErrorInfo((r) => {
-				console.log('閿欒',r);
+				console.log("閿欒", r);
 				if (r.code == 23) {
 					// 鎵撳嵃鏈烘柇寮�杩炴帴
 					this.connectedDevice = null;
+					// 娓呴櫎鏈湴瀛樺偍鐨勮繛鎺ヤ俊鎭�
+					uni.removeStorageSync("bluetoothConnection");
 					uni.showToast({
 						icon: "none",
 						title: "鎵撳嵃鏈鸿繛鎺ュ凡鏂紑锛岃閲嶆柊杩炴帴",
@@ -222,6 +231,39 @@
 			});
 		},
 		methods: {
+			restoreBluetoothConnection() {
+				try {
+					// 浠庢湰鍦板瓨鍌ㄨ幏鍙栦箣鍓嶄繚瀛樼殑杩炴帴淇℃伅
+					const savedConnection = uni.getStorageSync("bluetoothConnection");
+					if (savedConnection && savedConnection.address) {
+						console.log("灏濊瘯鎭㈠钃濈墮杩炴帴:", savedConnection);
+						// 璁剧疆涓鸿繛鎺ヤ腑鐘舵��
+						this.connectionStatus = "connecting";
+
+						// 灏濊瘯閲嶆柊杩炴帴
+						jcapi.openPrinterByDevice({
+								address: savedConnection.address,
+								name: savedConnection.name,
+								deviceType: 0, // 璁惧绫诲瀷锛�0-钃濈墮锛�1-缃戠粶
+							},
+							(r) => {
+								if (r.code == 0) {
+									this.connectedDevice = savedConnection;
+									this.connectionStatus = "connected";
+									console.log("钃濈墮杩炴帴宸叉仮澶�");
+								} else {
+									this.connectionStatus = "disconnected";
+									// 濡傛灉閲嶈繛澶辫触锛屾竻闄や繚瀛樼殑杩炴帴淇℃伅
+									uni.removeStorageSync("bluetoothConnection");
+									console.log("钃濈墮閲嶈繛澶辫触:", r);
+								}
+							}
+						);
+					}
+				} catch (e) {
+					console.error("鎭㈠钃濈墮杩炴帴澶辫触:", e);
+				}
+			},
 			getmoreList() {
 				if (this.pageSize >= this.total) {
 					this.status = "nomore";
@@ -234,41 +276,37 @@
 				}, 1000);
 			},
 			getlist() {
-				this.$u.api.NuclearScaleEntry
-					.queryPacking({
+				this.$u.api.NuclearScaleEntry.queryPacking({
+					current: this.pageNum,
+					size: this.pageSize,
+					verificationNo: this.verificationNo,
+				}).then((res) => {
+					this.list = res.data;
+					this.total = res.data.length;
+					if (this.pageSize >= this.total) {
+						this.status = "nomore";
+					} else {
+						this.status = "loadmore";
+					}
+				});
+			},
+			search(value) {
+				if (value) {
+					this.list = [];
+					this.pageSize = 10;
+					this.$u.api.NuclearScaleEntry.queryPacking({
 						current: this.pageNum,
 						size: this.pageSize,
-						verificationNo: this.verificationNo,
-					})
-					.then((res) => {
-						this.list = res.data;
-						this.total = res.data.length;
+						moNo: value,
+					}).then((res) => {
+						this.list = res.data.records;
+						this.total = res.data.total;
 						if (this.pageSize >= this.total) {
 							this.status = "nomore";
 						} else {
 							this.status = "loadmore";
 						}
 					});
-			},
-			search(value) {
-				if (value) {
-					this.list = [];
-					this.pageSize = 10;
-					this.$u.api.NuclearScaleEntry
-						.queryPacking({
-							current: this.pageNum,
-							size: this.pageSize,
-							moNo: value,
-						})
-						.then((res) => {
-							this.list = res.data.records;
-							this.total = res.data.total;
-							if (this.pageSize >= this.total) {
-								this.status = "nomore";
-							} else {
-								this.status = "loadmore";
-							}
-						});
 				} else {
 					this.getlist();
 				}
@@ -402,12 +440,12 @@
 			moveHandle() {},
 			maskclose() {},
 			//鎵撳嵃浜岀淮鐮�
-			 printQrCode(item) {
-				// return new Promise(async (resolve, reject) => {
+			printQrCode(item) {
+				return new Promise(async (resolve, reject) => {
 					// const params = {
 					// 	rwMatlBindId: item.id
 					// };
-				 try {
+					try {
 						// let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
 						if (!item) {
 							this.$refs.uToast.show({
@@ -418,14 +456,14 @@
 							return;
 						}
 
-						const ht =  item.contractNo
-						const lj =  item.partNo
-						const ljms =  item.ccontrProModel
-						const fh =  item.newNetWeight
-						const scdt =  item.outboundDate
-						const scph =  item.batchNo
-						const shdw =  item.customerName
-						const fhdw = '姹熶笢鍚堥噾鎶�鏈湁闄愬叕鍙�'
+						const ht = item.contractNo;
+						const lj = item.partNo;
+						const ljms = item.ccontrProModel;
+						const fh = item.newNetWeight;
+						const scdt = item.productionDate;
+						const scph = item.batchNo;
+						const shdw = item.customerName;
+						const fhdw = "姹熶笢鍚堥噾鎶�鏈湁闄愬叕鍙�";
 
 						// 鍒濆鍖栫敾鏉�
 						jcapi.initDrawingBoard({
@@ -435,17 +473,17 @@
 						});
 
 						// 缁樺埗浜岀淮鐮�
-					 const qrContent = {
-						company : item.customerNo,
-					 	 line_no : item.lineNo,
-						 lot_batch_no : item.batchNo,
-						 order_no :  item.contractNo,
-						 part_no :  item.partNo,
-					 	 total_qty : item.newNetWeight,
-					 	 qty_arrived : item.newNetWeight,
-					 	 release_no : item.relNo,	
-						}
-						
+						const qrContent = {
+							company: item.customerNo,
+							line_no: item.lineNo,
+							lot_batch_no: item.batchNo,
+							order_no: item.contractNo,
+							part_no: item.partNo,
+							total_qty: item.newNetWeight,
+							qty_arrived: item.newNetWeight,
+							release_no: item.relNo,
+						};
+
 						jcapi.drawLabelQrCode({
 							x: 43.5,
 							y: 2,
@@ -461,8 +499,8 @@
 						this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid);
 						this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid);
 						this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid);
-						this.getDrawLabelLine(1, 21, 42, 0.3, 0, LineType.Solid);
-						this.getDrawLabelLine(1, 27, 67, 0.3, 0, LineType.Solid);
+						this.getDrawLabelLine(1, 23, 42, 0.3, 0, LineType.Solid);
+						this.getDrawLabelLine(1, 27.5, 67, 0.3, 0, LineType.Solid);
 						this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid);
 						this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid);
 						this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid);
@@ -474,42 +512,263 @@
 						this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid); // 绔栫嚎3
 
 						// 缁樺埗鏂囨湰
-						this.getDrawLabelText(3, 2.5, 40, 8, "涓ぉ绉戞妧瑁呯娓呭崟", 2.5, 0, LineModeType.AutoHeight,
-							0, 0, 1, 1, 1);
-						this.getDrawLabelText(2, 7, 25, 8, "鍚堝悓鍙�:", 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 1, 1);
-						this.getDrawLabelText(2, 12, 25, 8, "闆朵欢鍙�:", 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 1, 1);
-						this.getDrawLabelText(2, 17, 25, 8, "闆朵欢鎻忚堪:", 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 1, 1);
-						this.getDrawLabelText(2, 22.5, 25, 8, "鍙戣揣/瑁呯鏁�:", 2.5, 0, LineModeType.AutoHeight,
-							0, 0, 0, 1, 1);
-						this.getDrawLabelText(2, 27.5, 25, 8, "鐢熶骇鏃ユ湡:", 2.5, 0, LineModeType.AutoHeight, 0,
-							0, 0, 1, 1);
-						this.getDrawLabelText(2, 32.5, 25, 8, "鐢熶骇鎵瑰彿:", 2.5, 0, LineModeType.AutoHeight, 0,
-							0, 0, 1, 1);
-						this.getDrawLabelText(2, 37.5, 25, 8, "鍙戣揣鍗曚綅:", 2.5, 0, LineModeType.AutoHeight, 0,
-							0, 0, 1, 1);
-						this.getDrawLabelText(2, 42.5, 25, 8, "鏀惰揣鍗曚綅:", 2.5, 0, LineModeType.AutoHeight, 0,
-							0, 0, 1, 1);
+						this.getDrawLabelText(
+							3,
+							2.5,
+							40,
+							8,
+							"涓ぉ绉戞妧瑁呯娓呭崟",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							1,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							7,
+							25,
+							8,
+							"鍚堝悓鍙�:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							12,
+							25,
+							8,
+							"闆朵欢鍙�:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							17,
+							25,
+							8,
+							"闆朵欢鎻忚堪:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							23.5,
+							25,
+							8,
+							"鍙戣揣/瑁呯鏁�:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							28.5,
+							25,
+							8,
+							"鐢熶骇鏃ユ湡:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							32.5,
+							25,
+							8,
+							"鐢熶骇鎵瑰彿:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							37.5,
+							25,
+							8,
+							"鍙戣揣鍗曚綅:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
+						this.getDrawLabelText(
+							2,
+							42.5,
+							25,
+							8,
+							"鏀惰揣鍗曚綅:",
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							1,
+							1
+						);
 
 						// 濉厖鍙傛暟鍊�
-						this.getDrawLabelText(11, 7, 30, 8, ht, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0,
-							0, 1);
-						this.getDrawLabelText(11, 12, 32, 8, lj, 2.5, 0, LineModeType.AutoHeight, 0, 0, 0,
-							0, 1);
-						this.getDrawLabelText(14, 17, 30, 8, ljms, 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 0, 1);
-						this.getDrawLabelText(17, 22.5, 27, 8, fh, 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 0, 1);
-						this.getDrawLabelText(14, 27.5, 55, 8, scdt, 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 0, 1);
-						this.getDrawLabelText(14, 32.7, 55, 8, scph, 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 0, 1);
-						this.getDrawLabelText(14, 37.5, 55, 8, fhdw, 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 0, 1);
-						this.getDrawLabelText(14, 42.5, 55, 8, shdw, 2.5, 0, LineModeType.AutoHeight, 0, 0,
-							0, 0, 1);
+						this.getDrawLabelText(
+							11,
+							7,
+							30,
+							8,
+							ht,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							11,
+							12,
+							32,
+							8,
+							lj,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							14,
+							17,
+							30,
+							8,
+							ljms,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							17,
+							23.5,
+							27,
+							8,
+							fh,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							14,
+							28.5,
+							55,
+							8,
+							scdt,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							14,
+							32.7,
+							55,
+							8,
+							scph,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							14,
+							37.5,
+							55,
+							8,
+							fhdw,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
+						this.getDrawLabelText(
+							14,
+							42.5,
+							55,
+							8,
+							shdw,
+							2.5,
+							0,
+							LineModeType.AutoHeight,
+							0,
+							0,
+							0,
+							0,
+							1
+						);
 						// 鐢熸垚鎵撳嵃鏁版嵁
 						let imageJsonObj = jcapi.generateLabelJson();
 
@@ -520,7 +779,7 @@
 								labelType: this.labelType,
 								printMode: this.printMode,
 							},
-							function (r) {
+							function(r) {
 								if (r.code == 0) {
 									// 鎵撳嵃鏁版嵁
 									// 瀛樺偍鍘熷鎵撳嵃璁℃暟鍥炶皟
@@ -541,8 +800,7 @@
 
 									// 娣诲姞鎵撳嵃瓒呮椂澶勭悊
 									const printTimeout = setTimeout(() => {
-										jcapi.didReadPrintCountInfo(
-											originalPrintCountCallback);
+										jcapi.didReadPrintCountInfo(originalPrintCountCallback);
 										reject(new Error("鎵撳嵃瓒呮椂鏈搷搴�"));
 									}, 20000);
 
@@ -569,7 +827,7 @@
 					} catch (error) {
 						reject(error);
 					}
-				// });
+				});
 			},
 			tapQuery(item) {
 				this.maskShow = false;
@@ -585,9 +843,12 @@
 						deviceType: 0, // 璁惧绫诲瀷锛�0-钃濈墮锛�1-缃戠粶
 					},
 					function(r) {
+						// 鍦╰apQuery鏂规硶涓紝杩炴帴鎴愬姛鏃舵坊鍔犱繚瀛樿繛鎺ヤ俊鎭殑浠g爜
 						if (r.code == 0) {
 							_this.connectedDevice = item;
 							_this.connectionStatus = "connected";
+							// 淇濆瓨杩炴帴淇℃伅鍒版湰鍦板瓨鍌�
+							uni.setStorageSync("bluetoothConnection", item);
 							uni.showToast({
 								title: "杩炴帴鎴愬姛",
 								duration: 1500,

--
Gitblit v1.9.3