1
hao
2025-05-20 28997825e47018a0d9b3b8e4c003b232f62d241f
ÏÄÃÉ×¢Ëܱ¨¹¤/pages/scbg/scbg.vue
@@ -66,9 +66,13 @@
               <text>需求单据:</text>
               <text>{{ orderDetails.requirementDoc }}</text>
            </view>
            <view class="order-details-column">
            <!-- <view class="order-details-column">
               <text>推荐包装数:</text>
               <text>{{ orderDetails.bzsl }}</text>
            </view> -->
            <view class="order-details-column">
               <text>工单状态:</text>
               <text>{{ orderDetails.gdzt }}</text>
            </view>
         </view>
         <view class="order-details-row">
@@ -189,14 +193,14 @@
                        <view class="header-item" id="tm">打印条码</view>
                        <view class="header-item" id="sl">打印数量</view>
                        <view class="header-item" id="sj">打印时间</view>
                        <view class="header-item" id="ry">打印人</view>
                        <view class="header-item" id="ry">报工人</view>
                     </view>
                     <!-- è¡¨æ ¼å†…容 -->
                     <scroll-view scroll-y="true" class="history-scroll">
                        <view v-for="(record, index) in historyList" :key="index" class="history-record">
                           <view class="record-item">{{ record.itemBarcode }}</view>
                           <view class="record-item">{{ record.quantity || '未知数量' }}</view>
                           <view class="record-item">{{ record.quantity }}</view>
                           <view class="record-item">{{ record.printDate }}</view>
                           <view class="record-item">{{ record.printedBy }}</view>
                        </view>
@@ -204,8 +208,8 @@
                  </view>
               </view>
               <button @click="reprintLast" :disabled="isButtonDisabled2" class="uni-btn">{{ isButtonDisabled2 ? '请稍后...' : '补打上一张' }}</button>
            </view>
            <!--    <button @click="reprintLast" :disabled="isButtonDisabled2" class="uni-btn">{{ isButtonDisabled2 ? '请稍后...' : '补打上一张' }}</button>
             --></view>
         </view>
      </view>
@@ -226,9 +230,13 @@
                     {{ deviceState }}
                  </view>
               </view>
   <button @click="reprintLast" :disabled="isButtonDisabled2" class="uni-btn">{{ isButtonDisabled2 ? '请稍后...' : '补打上一张' }}</button>
               <!-- æŒ‰é’®æ”¾åœ¨çŠ¶æ€æ–‡æœ¬çš„ä¸‹æ–¹ -->
               <!-- <button @click="manualCheck" class="check-button">手动检测</button> -->
               <view class="version" v-if="version">
                 ç‰ˆæœ¬å·ï¼š{{ version }}
               </view>
            </view>
            <!-- <button @click="createLabel()" class="dycs">打印测试</button> -->
@@ -239,9 +247,7 @@
            <button @click="sendForFirstInspection" class="round-btn">首检送检</button>
         </view>
      </view>
      <view class="version" v-if="version">
        ç‰ˆæœ¬å·ï¼š{{ version }}
      </view>
   </view>
</template>
@@ -282,6 +288,7 @@
               orderQuantity: '', // è®¢å•数量
               producedQuantity: '', // å·²ç”Ÿäº§æ•°
               bzsl: '', // æŽ¨èåŒ…装数
               gdzt:'',
               itemId: '', // ç‰©æ–™ID
               itemNo: '', // ç‰©æ–™ç¼–码
               itemname: '', // ç‰©æ–™åç§°
@@ -496,9 +503,9 @@
               }
               let res = UsbModule.isUsbConnect();
               this.deviceState = res ? "USB è¿žæŽ¥æ­£å¸¸" : "USB è¿žæŽ¥å¤±è´¥";
               console.log("USB æ£€æµ‹ç»“æžœ:", this.deviceState);
               if (this.deviceState == "USB è¿žæŽ¥å¤±è´¥") {
               this.deviceState = res ? "打印机 è¿žæŽ¥æ­£å¸¸" : "打印机 è¿žæŽ¥å¤±è´¥";
               console.log("打印机 æ£€æµ‹ç»“æžœ:", this.deviceState);
               if (this.deviceState == "打印机 è¿žæŽ¥å¤±è´¥") {
                  uni.showToast({
                     title: ` ${this.deviceState}`,
@@ -520,10 +527,10 @@
            } catch (error) {
               console.error("USB æ£€æµ‹é”™è¯¯:", error);
               this.deviceState = "USB æ£€æµ‹å¤±è´¥";
               console.error("打印机 æ£€æµ‹é”™è¯¯:", error);
               this.deviceState = "打印机 æ£€æµ‹å¤±è´¥";
               uni.showToast({
                  title: "USB æ£€æµ‹å¤±è´¥ï¼Œè¯·æ£€æŸ¥æ’ä»¶",
                  title: "打印机 æ£€æµ‹å¤±è´¥ï¼Œè¯·æ£€æŸ¥æ’ä»¶",
                  duration: 2000,
                  icon: "none"
               });
@@ -590,9 +597,9 @@
            console.log("111", UsbModule)
            let res = UsbModule.initUsbDevice();
            if (res) {
               this.deviceState = "USB è¿žæŽ¥æ­£å¸¸"
               this.deviceState = "打印机 è¿žæŽ¥æ­£å¸¸"
            } else {
               this.deviceState = "USB è¿žæŽ¥å¤±è´¥"
               this.deviceState = "打印机 è¿žæŽ¥å¤±è´¥"
            }
            uni.showToast({
               title: this.deviceState,
@@ -751,7 +758,7 @@
                        itemBarcode: record.itemBarcode || '未知条码', // ç¡®ä¿è§£æžå­—段
                        quantity: record.quantity || '未知数量', // æ‰“印数量字段
                        printDate: record.printDate || '未知时间', // æ‰“印时间
                        printedBy: record.printedBy || '未知用户' // æ‰“印人
                        printedBy: record.printedBy || '' // æŠ¥å·¥äºº
                     }));
                     console.log('History records loaded:', this.historyList);
                  } else {
@@ -911,6 +918,7 @@
               productionOrder: '', // ç”Ÿäº§è®¢å•
               orderQuantity: '', // è®¢å•数量
               bzsl: '', // æŽ¨èåŒ…装数
               gdzt:'',
               producedQuantity: '', // å·²ç”Ÿäº§æ•°
               itemId: '', // ç‰©æ–™ID
               itemNo: '', // ç‰©æ–™ç¼–码
@@ -939,6 +947,7 @@
                        productionOrder: res.data.productionOrder, // ç”Ÿäº§è®¢å•
                        orderQuantity: res.data.orderQuantity, // è®¢å•数量
                        bzsl: res.data.bzsl, // æŽ¨èåŒ…装数
                        gdzt: res.data.gdzt, // å·¥å•状态
                        producedQuantity: res.data.producedQuantity, // å·²ç”Ÿäº§æ•°
                        itemId: res.data.itemId, // ç‰©æ–™ID
                        itemNo: res.data.itemNO, // ç‰©æ–™ç¼–码
@@ -1041,6 +1050,61 @@
                  });
               }
            });
         // è°ƒç”¨ API èŽ·å–å·¥å•è¯¦æƒ…
         uni.request({
            url: `http://192.168.0.107:44380/api/orderDetails?orderNo=${encodeURIComponent(this.orderNo)}`, // ä½¿ç”¨å­˜å‚¨çš„orderNo
            method: 'GET',
            header: {
               'Content-Type': 'application/json'
            },
            success: (res) => {
               console.log('gongdanxinx', res.data);
               if (res.statusCode === 200) {
                  this.orderDetails = {
                     requirementDoc: res.data.requirementDoc, // éœ€æ±‚单据
                     productionOrder: res.data.productionOrder, // ç”Ÿäº§è®¢å•
                     orderQuantity: res.data.orderQuantity, // è®¢å•数量
                     bzsl: res.data.bzsl, // æŽ¨èåŒ…装数
                     gdzt: res.data.gdzt, // å·¥å•状态
                     producedQuantity: res.data.producedQuantity, // å·²ç”Ÿäº§æ•°
                     itemId: res.data.itemId, // ç‰©æ–™ID
                     itemNo: res.data.itemNO, // ç‰©æ–™ç¼–码
                     itemname: res.data.itemname, // ç‰©æ–™åç§°
                     itemmodel: res.data.itemmodel, // è§„格型号
                  };
                  // æ ¹æ® sj å’Œ xj çš„值来设置首检和巡检状态
                  // æ ¹æ® sj å’Œ xj çš„值来设置首检和巡检状态
                  if (res.data.sj === 1) {
                     this.checkFirstPass = true; // é¦–检合格
                  } else if (res.data.sj === 2) {
                     this.checkFirstPass = false; // é¦–检不合格
                  } else {
                     this.checkFirstPass = null; // é¦–检未做
                  }
                  if (res.data.xj === 1) {
                     this.checkXJ = true; // å·¡æ£€åˆæ ¼
                  } else if (res.data.xj === 2) {
                     this.checkXJ = false; // å·¡æ£€ä¸åˆæ ¼
                  } else {
                     this.checkXJ = null; // å·¡æ£€æœªåš
                  }
                  console.log('Order details loaded:', this.orderDetails);
               } else {
                  console.error('Failed to fetch order details:', res);
               }
            },
            fail: (err) => {
               console.error('Error fetching order details:', err);
            }
         });
         },
         mapStatus(status) {
            if (status === 3) {
@@ -1184,7 +1248,7 @@
            if (!UsbModule || !UsbModule.isUsbConnect || !UsbModule.isUsbConnect()) {
               uni.showModal({
                  title: ` ${this.networkState}`,
                  content: "请检查USB连接",
                  content: "请检查打印机连接",
                  showCancel: false,
                  success: () => {
                     this.modalVisible = false;
@@ -1330,7 +1394,7 @@
                     // ç¬¬ä¸€éƒ¨åˆ†ï¼šæ¡ç ã€å·¥å•号、供应商信息 + å¤§äºŒç»´ç 
                     command.setBar(20, 40, "128", 100, 1, 0, 2, requestData.uniqueValue); // æ¡ç 
                     command.setText(20, 40, "TSS24.BF2", 1, 1, "条码: ");
                     command.setText(20, 40, "TSS24.BF2", 1, 1, "物料条码: ");
                     command.setText(150, 40, "TSS24.BF2", 1, 1, requestData.uniqueValue);
                     // å·¥å•号
@@ -1356,7 +1420,7 @@
                     // ç¬¬å››éƒ¨åˆ†ï¼šæ•°é‡ä¸Žéœ€æ±‚单据号
                     command.setText(20, 340, "TSS24.BF2", 1, 1, "数量: ");
                     command.setText(120, 340, "TSS24.BF2", 1, 1, this.reportedQuantity);
                     command.setText(200, 340, "TSS24.BF2", 1, 1, "打印人: ");
                     command.setText(200, 340, "TSS24.BF2", 1, 1, "报工人: ");
                     command.setText(290, 340, "TSS24.BF2", 1, 1, this.selectedPerson);
@@ -1379,11 +1443,23 @@
                     // command.setFeed(30);
                     this.sendData = command.getData();
                     // å‘送数据
                     this.senUSBData();
             // **先记录 "打印后" äº‹ä»¶**
                                this.logPrintEvent("打印后", "打印", requestData.uniqueValue);
               // 1. æ‰§è¡Œå‘送
               let printResult = this.senUSBData();
               // 2. åˆ¤æ–­å‘送是否成功
               if (printResult.success) {
                 // âœ… å‘送成功,记录打印日志
                 this.logPrintEvent("打印后", "打印", requestData.uniqueValue);
               } else {
                 // âŒ å‘送失败,提示用户,不记录日志
                 uni.showToast({
                   title: "打印失败,未记录日志",
                   duration: 2000
                 });
               }
                           this.oldbgs =  this.reportedQuantity;
                           this.bgr=
                     //从新刷新工单信息
                     loadOrderDetails();
                     //从新刷新历史记录
@@ -1423,7 +1499,7 @@
            if (!UsbModule || !UsbModule.isUsbConnect || !UsbModule.isUsbConnect()) {
               uni.showModal({
                  title: ` ${this.networkState}`,
                  content: "请检查USB连接",
                  content: "请检查打印机连接",
                  showCancel: false,
                  success: () => {
                     this.modalVisible = false;
@@ -1454,7 +1530,7 @@
                  });
               }
            });
         this.selectedPerson = this.lastRequestData.printedBy;
            // è¡¥æ‰“上一张记录
            this.fetchHistoryRecords(this.orderNo);
            if (!this.lastRequestData) {
@@ -1465,6 +1541,8 @@
               });
               return;
            }
               //20250507 æ–°åŠ èµ‹å€¼åŽ†å²æ¡ç æŠ¥å·¥äºº
               this.selectedPerson = this.lastRequestData.printedBy;
            console.log("老条码", this.oldbgs);
            // é‡æ–°æ‰“印上一张记录
            // async reprintLast() {
@@ -1498,7 +1576,7 @@
            // ç¬¬ä¸€éƒ¨åˆ†ï¼šæ¡ç ã€å·¥å•号、供应商信息 + å¤§äºŒç»´ç 
            command.setBar(20, 40, "128", 100, 1, 0, 2, this.lastRequestData); // æ¡ç 
            command.setText(20, 40, "TSS24.BF2", 1, 1, "条码: ");
            command.setText(20, 40, "TSS24.BF2", 1, 1, "物料条码: ");
            command.setText(150, 40, "TSS24.BF2", 1, 1, this.lastRequestData);
            // å·¥å•号
@@ -1544,11 +1622,25 @@
            command.setPagePrint();
            command.setFeed(3);
            this.sendData = command.getData();
         // 1. æ‰§è¡Œå‘送
         let printResult = this.senUSBData();
         // 2. åˆ¤æ–­å‘送是否成功
         if (printResult.success) {
         // å‘送成功,记录打印日志
           this.logPrintEvent("打印后", "补打", this.lastRequestData);
         } else {
         // å‘送失败,提示用户,不记录日志
         uni.showToast({
            title: "打印失败,未记录日志",
            duration: 2000
         });
         }
F
            // å‘送数据
            this.senUSBData();
          // **记录 "补打后" äº‹ä»¶**
          this.logPrintEvent("打印后", "补打", this.lastRequestData);
         }
      ,
   logPrintEvent(eventType, printType, barcodeValue) {