From 4dc0880780b52c0c35456666a4643a7866b454a7 Mon Sep 17 00:00:00 2001
From: fcx <2246384483@qq.com>
Date: 星期六, 20 十二月 2025 16:00:35 +0800
Subject: [PATCH] 1.产检提交增加日期选择器

---
 pages/QC/SJ/ScanCode.vue |  112 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 80 insertions(+), 32 deletions(-)

diff --git a/pages/QC/SJ/ScanCode.vue b/pages/QC/SJ/ScanCode.vue
index 06a08c6..2b060bb 100644
--- a/pages/QC/SJ/ScanCode.vue
+++ b/pages/QC/SJ/ScanCode.vue
@@ -3,7 +3,7 @@
     <view class="title">SN纭</view>
 
     <view v-if="current === 'true'" class="remark">
-      澶囨敞锛氱偣鍑�"鎵爜"鎸夐挳鎵弿SN鐮侊紝鍐嶆鐐瑰嚮鍙鐩栦笂娆¤褰�
+      澶囨敞锛氱偣鍑�"鎵爜"鎸夐挳鎵撳紑涓撲笟鎵爜鐣岄潰锛堝厤璐瑰畼鏂圭粍浠讹級
     </view>
 
     <view class="scan-table">
@@ -50,34 +50,90 @@
       mid: null, // MES涓昏〃ID
       scanItems: [], // 浠� MES_SJ_SCAN_ITEM_CK 鑾峰彇
       current: 'true', // 鎺у埗鏄惁鍙紪杈�
+      currentScanIndex: -1, // 褰撳墠鎵弿鐨勭储寮�
     };
   },
 
   onLoad(options) {
+    // 璋冭瘯淇℃伅锛氭墦鍗版帴鏀跺埌鐨勫弬鏁�
+    console.log('ScanCode椤甸潰鎺ユ敹鍒扮殑鍙傛暟:', options);
+    
     // 鍋囪浠庝笂涓�椤典紶鍏� mid
     this.mid = options.id || null;
     this.current = options.current || 'true'; // 榛樿涓哄彲缂栬緫鐘舵��
+    
+    // 璋冭瘯淇℃伅锛氭墦鍗癿id鍊�
+    console.log('mid鍊�:', this.mid);
+    console.log('current鍊�:', this.current);
+    
+    // 涓存椂娴嬭瘯锛氬鏋渕id涓虹┖锛屼娇鐢ㄩ粯璁ゅ��
+    if (!this.mid) {
+      console.warn('璀﹀憡锛歮id涓虹┖锛屼娇鐢ㄦ祴璇曟暟鎹�');
+      // 鍙栨秷娉ㄩ噴涓嬮潰涓�琛屽彲浠ョ洿鎺ユ樉绀烘祴璇曟暟鎹�
+      // this.loadTestData();
+      // return;
+    }
+    
     this.getScanItems();
   },
 
   methods: {
+    // 涓存椂娴嬭瘯鏂规硶锛氬姞杞芥祴璇曟暟鎹�
+    loadTestData() {
+      console.log('鍔犺浇娴嬭瘯鏁版嵁');
+      this.scanItems = [
+        { id: 1, scanItem: '浜у搧SN', snNo: '' },
+        { id: 2, scanItem: '鏈烘灦鍙�', snNo: '' },
+        { id: 3, scanItem: '鐢垫満缂栧彿', snNo: '' },
+      ];
+      uni.showToast({ 
+        title: '宸插姞杞芥祴璇曟暟鎹�', 
+        icon: 'success' 
+      });
+    },
+    
     // 浠� MES_SJ_SCAN_ITEM_CK 鑾峰彇鏁版嵁
     getScanItems() {
-      if (!this.mid) return;
+      console.log('寮�濮嬭幏鍙朣N鍒楄〃, mid:', this.mid);
+      
+      if (!this.mid) {
+        console.error('mid涓虹┖锛屾棤娉曡幏鍙栧垪琛�');
+        uni.showToast({ 
+          title: "缂哄皯蹇呰鍙傛暟", 
+          icon: "none" 
+        });
+        return;
+      }
 
       uni.showLoading({ title: "鍔犺浇涓�..." });
+      
+      console.log('鍑嗗璋冪敤鎺ュ彛锛�/SJ/GetList, 鍙傛暟:', { mid: this.mid });
       
       this.$post({
         url: "/SJ/GetList",
         data: { mid: this.mid }
       }).then(res => {
+        console.log('鎺ュ彛杩斿洖缁撴灉:', res);
+        
         if (res.status === 0) {
+          console.log('杩斿洖鐨勬暟鎹�:', res.data);
+          
           this.scanItems = res.data.map(x => ({
             id: x.id,
             scanItem: x.scanItem,
             snNo: x.snNo || "",
           }));
+          
+          console.log('澶勭悊鍚庣殑scanItems:', this.scanItems);
+          
+          if (this.scanItems.length === 0) {
+            uni.showToast({ 
+              title: "鏆傛棤鎵爜椤圭洰", 
+              icon: "none" 
+            });
+          }
         } else {
+          console.error('鎺ュ彛杩斿洖閿欒:', res.message);
           uni.showToast({ 
             title: res.message || "鍔犺浇澶辫触", 
             icon: "none" 
@@ -94,38 +150,30 @@
       });
     },
 
-    // 鎵爜鍔熻兘
+    // 鎵爜鎴愬姛鍥炶皟锛堢敱 nvue 鎵爜椤甸潰璋冪敤锛�
+    onScanSuccess(scanResult) {
+      console.log('鎵爜缁撴灉:', scanResult);
+      
+      if (this.currentScanIndex >= 0 && this.currentScanIndex < this.scanItems.length) {
+        // 鏇存柊瀵瑰簲椤圭洰鐨凷N鐮�
+        this.scanItems[this.currentScanIndex].snNo = scanResult.trim();
+        
+        uni.showToast({
+          title: '鎵爜鎴愬姛',
+          icon: 'success'
+        });
+      }
+    },
+    
+    // 鎵撳紑鎵爜椤甸潰锛堜娇鐢ㄨ瘑鍒巼鏇撮珮鐨勬柟妗堬級
     onScan(index) {
-      const self = this;
-
-      // #ifdef MP-WEIXIN
-      uni.scanCode({
-        success(res){
-          self.scanItems[index].snNo = res.result;
-        },
-        fail(err) {
-          console.log("鎵爜澶辫触", err);
-        },
+      this.currentScanIndex = index;
+      const itemName = this.scanItems[index].scanItem;
+      
+      // 璺宠浆鍒� nvue 鎵爜椤甸潰锛堜娇鐢ㄥ畼鏂� Barcode 缁勪欢锛岃瘑鍒巼 90%+锛�
+      uni.navigateTo({
+        url: `/pages/QC/SJ/BarcodeScan?title=${encodeURIComponent(itemName)}`
       });
-      // #endif
-
-      // #ifdef H5
-      uni.showToast({
-        title: "璇蜂娇鐢ㄦ壂鐮佹灙杈撳叆鍒癝N杈撳叆妗�",
-        icon: "none",
-      });
-      // #endif
-
-      // #ifdef APP-PLUS
-      uni.scanCode({
-        scanType: ['barCode'],  // 鏂板杩欎竴琛�
-        autoDecodeCharset: true, // 鑷姩瑙g爜瀛楃闆�
-        success(res) {
-            console.log(res)
-          self.scanItems[index].snNo = res.result;
-        },
-      });
-      // #endif
     },
 
     // 淇濆瓨 SN 鏁版嵁鍒� MES_SJ_SCAN_ITEM_CK

--
Gitblit v1.9.3