From dbfb045ad92072e880104e13fddb4dc7574499a1 Mon Sep 17 00:00:00 2001
From: fcx <2246384483@qq.com>
Date: 星期五, 19 十二月 2025 13:56:02 +0800
Subject: [PATCH] 1.给SJ获取检验项目添加防抖

---
 pages/QC/SJ/Add.vue |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/pages/QC/SJ/Add.vue b/pages/QC/SJ/Add.vue
index c1cb9e1..a6737da 100644
--- a/pages/QC/SJ/Add.vue
+++ b/pages/QC/SJ/Add.vue
@@ -52,7 +52,7 @@
         <view class="info-label">宸ュ崟鏁伴噺锛�</view>
         <view class="info-value highlight">{{ formData.daa008 }}</view>
       </view>
-      <view v-if="formData.remarks && current" class="info-block">
+      <view v-if="formData.remarks" class="info-block">
         <view class="info-label">澶囨敞锛�</view>
         <view class="info-value">{{ formData.remarks }}</view>
       </view>
@@ -175,6 +175,8 @@
       comments: "",
       commentsPopup: false,
       current: true,
+      
+      getTableTimer: null, // 闃叉姈瀹氭椂鍣�
 
     };
   },
@@ -308,6 +310,11 @@
         if (res.statusCode === 200 || res.status === 0 || res.data === true || res.data.tbBillList === true) {
 
           this.$showMessage("鎴愬姛鎻愪氦妫�楠�");
+          
+          // 娓呴櫎鏈湴瀛樺偍鐨勪竴鑷存�ф牳瀵圭姸鎬�
+          const storageKey = `yzxChecked_${this.formData.id}`;
+          uni.removeStorageSync(storageKey);
+          
           // 鎻愪氦鎴愬姛鍚庡埛鏂伴〉闈㈡暟鎹�
           this.init();
           // 1.5绉掑悗璺宠浆鍒板垪琛ㄩ〉闈�
@@ -327,6 +334,10 @@
 
     init() {
       if (this.formData.id) {
+        // 浠庢湰鍦板瓨鍌ㄨ鍙栦竴鑷存�ф牳瀵圭姸鎬�
+        const storageKey = `yzxChecked_${this.formData.id}`;
+        const storedYzxChecked = uni.getStorageSync(storageKey);
+        
         this.$post({
           url: "/SJ/GetPage",
           data: {
@@ -337,11 +348,11 @@
         }).then(res => {
           let tbBillListElement = res.data.tbBillList[0];
           if (tbBillListElement) {
-            // 淇濆瓨褰撳墠鐨剏zxChecked鐘舵��
-            const currentYzxChecked = this.formData.yzxChecked;
             this.formData = tbBillListElement;
-            // 鎭㈠yzxChecked鐘舵�侊紝閬垮厤琚湇鍔″櫒鏁版嵁瑕嗙洊
-            this.formData.yzxChecked = currentYzxChecked;
+            // 鎭㈠鏈湴瀛樺偍鐨勪竴鑷存�ф牳瀵圭姸鎬�
+            if (storedYzxChecked) {
+              this.formData.yzxChecked = true;
+            }
             this.$post({
               url: "/SJ/getQSItems",
               data: {
@@ -464,13 +475,26 @@
           duration: 2000,
         });
       } else {
+        const currentStatus = this.current ? 'A' : 'B'; // 娣诲姞current鍙傛暟
         uni.navigateTo({
           url: 'detail?id=' + item.id + '&billNo=' + this.formData.billNo + '&gid=' + this.formData
-              .id + '&index=' + index
+              .id + '&index=' + index + '&current=' + currentStatus
         });
       }
     },
     getTable() {
+      // 娓呴櫎涓婁竴娆$殑瀹氭椂鍣�
+      if (this.getTableTimer) {
+        clearTimeout(this.getTableTimer);
+      }
+      
+      // 璁剧疆1绉掗槻鎶�
+      this.getTableTimer = setTimeout(() => {
+        this.executeGetTable();
+      }, 1000);
+    },
+    
+    executeGetTable() {
       this.$post({
         url: "/SJ/SetQSItems",
         data: {
@@ -571,7 +595,8 @@
       this.comments = this.formData.comments;
     },
     editRemarks() {
-      if (this.remarks) {
+      // 鍏佽淇濆瓨绌哄瓧绗︿覆鎴栫┖鏍硷紝鍙鏌ユ槸鍚︿负null鎴杣ndefined
+      if (this.remarks !== null && this.remarks !== undefined) {
         //saveRemarksGid
         this.$post({
           url: "/SJ/saveRemarksGid",
@@ -623,8 +648,7 @@
   },
   onShow() {
     // 姣忔杩涘叆椤甸潰閮戒細鎵ц鐨勬柟娉�
-    // 娉ㄩ噴鎺塱nit()璋冪敤,閬垮厤瑕嗙洊涓�鑷存�ф牳瀵圭姸鎬�
-    // this.init();
+    this.init();
   }
 };
 </script>

--
Gitblit v1.9.3