From 747613d7e856a7c104b8b4709442d34a51cdb9aa Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期六, 11 十月 2025 16:19:05 +0800
Subject: [PATCH] 核磅录入页面的打印功能调试,修复全部打印只出一张的问题,修复首次连接蓝牙后推出页面再进蓝牙无法连接问题

---
 pages/wareHouse/nuclearScale/nuclearscalerecord.vue |  420 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 359 insertions(+), 61 deletions(-)

diff --git a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
index d80cbfe..37ecc64 100644
--- a/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
+++ b/pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -54,7 +54,7 @@
                   <view class="_label-name">鎵规鍙凤細</view>
                 </view>
                 <view class="_content">
-                  {{ item.outBatchNo }}
+                  {{ item.batchNo }}
                 </view>
               </view>
               <view class="row-list">
@@ -63,7 +63,7 @@
                   <view class="_label-name">浜у搧鎻忚堪锛�</view>
                 </view>
                 <view class="_content">
-                  {{ item.netWeight }}
+                  {{ item.partDescription }}
                 </view>
               </view>
               <view class="row-list">
@@ -81,7 +81,7 @@
                   <view class="_label-name">姣涢噸锛�</view>
                 </view>
                 <view class="_content">
-                  {{ item.grossWeight }}
+                  {{ item.newGrossWeight }}
                 </view>
               </view>
               <view class="row-list">
@@ -90,7 +90,7 @@
                   <view class="_label-name">鐩橀噸锛�</view>
                 </view>
                 <view class="_content">
-                  {{ item.trayWeight }}
+                  {{ item.newWeight }}
                 </view>
               </view>
               <view class="row-list">
@@ -99,7 +99,7 @@
                   <view class="_label-name">鍑�閲嶏細</view>
                 </view>
                 <view class="_content">
-                  {{ item.value5 }}
+                  {{ item.newNetWeight }}
                 </view>
               </view>
               <view class="row-list">
@@ -108,7 +108,7 @@
                   <view class="_label-name">鏍哥閲嶉噺锛�</view>
                 </view>
                 <view class="_content">
-                  {{ item.netWeight }}
+                  {{ item.verificationWeight }}
                 </view>
               </view>
               <view class="row-list">
@@ -117,7 +117,7 @@
                   <view class="_label-name">鍙夎溅鐩橀噸锛�</view>
                 </view>
                 <view class="_content">
-                  {{ item.value7 }}
+                  {{ item.forkliftWeight }}
                 </view>
               </view>
             </view>
@@ -224,23 +224,34 @@
       connectionStatus: "disconnected", // 杩炴帴鐘舵��: disconnected, connecting, connected
       printStatus: "idle", // 鎵撳嵃鐘舵��: idle, printing, error
       errorMessage: "", // 閿欒淇℃伅
+      verificationNo: "",
+      failedPrintJobs: [],
     };
   },
-  onLoad() {
+  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: "鎵撳嵃鏈鸿繛鎺ュ凡鏂紑锛岃閲嶆柊杩炴帴",
@@ -256,6 +267,40 @@
     });
   },
   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";
@@ -268,12 +313,29 @@
       }, 1000);
     },
     getlist() {
-      this.$u.api.workReporting
-        .getWorkshopOrder({
+      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,
-        })
-        .then((res) => {
+          moNo: value,
+        }).then((res) => {
           this.list = res.data.records;
           this.total = res.data.total;
           if (this.pageSize >= this.total) {
@@ -282,26 +344,6 @@
             this.status = "loadmore";
           }
         });
-    },
-    search(value) {
-      if (value) {
-        this.list = [];
-        this.pageSize = 10;
-        this.$u.api.workReporting
-          .getWorkshopOrder({
-            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();
       }
@@ -435,14 +477,14 @@
     moveHandle() {},
     maskclose() {},
     //鎵撳嵃浜岀淮鐮�
-    async printQrCode(item) {
+    printQrCode(item) {
       return new Promise(async (resolve, reject) => {
-        const params = {
-        	rwMatlBindId: item.id
-        };
+        // const params = {
+        // 	rwMatlBindId: item.id
+        // };
         try {
-          let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
-          if (!res.data) {
+          // let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
+          if (!item) {
             this.$refs.uToast.show({
               title: "鏈煡璇㈠埌璇ユ爣绛句俊鎭紒",
               type: "warning ",
@@ -451,8 +493,14 @@
             return;
           }
 
-          // 浠嶢PI鍝嶅簲涓彁鍙栨墍闇�鏁版嵁
-          const { ht, lj, ljms, fh, scdt, scph, fhdw, shdw } = res.data;
+          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 = "姹熶笢鍚堥噾鎶�鏈湁闄愬叕鍙�";
 
           // 鍒濆鍖栫敾鏉�
           jcapi.initDrawingBoard({
@@ -462,7 +510,17 @@
           });
 
           // 缁樺埗浜岀淮鐮�
-          const qrContent = `ht:${ht}\nlj:${lj}\nljms:${ljms}\nfh:${fh}\nscdt:${scdt}\nscph:${scph}\nfhdw:${fhdw}\nshdw:${shdw}`;
+          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,
@@ -491,26 +549,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,
+            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(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,
+            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
+          );
           // 鐢熸垚鎵撳嵃鏁版嵁
           let imageJsonObj = jcapi.generateLabelJson();
 
@@ -587,9 +882,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