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 |   85 +++++++++++++++++++++++++++++++++---------
 1 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/pages/QC/SJ/Add.vue b/pages/QC/SJ/Add.vue
index f5ad192..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, // 闃叉姈瀹氭椂鍣�
 
     };
   },
@@ -253,22 +255,44 @@
     },
 
     submit() {
-      // 妫�鏌ユ槸鍚﹀凡瀹屾垚涓�鑷存�ф牳瀵�
+      // 妫�鏌ユ槸鍚﹂渶瑕佷竴鑷存�ф牳瀵�
       if (this.current && !this.formData.yzxChecked) {
-        uni.showModal({
-          title: "鎻愮ず",
-          content: "璇峰厛瀹屾垚涓�鑷存�ф牳瀵瑰悗鍐嶆彁浜ゆ楠�",
-          confirmText: "鍘绘牳瀵�",
-          cancelText: "鍙栨秷",
-          success: (res) => {
-            if (res.confirm) {
-              this.toYzxSubmitFrom(this.formData.billNo);
-            }
+        // 鍏堟鏌ヨ鐗╂枡鏄惁缁存姢浜嗕竴鑷存�ф牳瀵归」鐩�
+        this.$post({
+          url: "/SJ/getYzxItem",
+          data: {
+            id: this.formData.id
           }
+        }).then(res => {
+          // 濡傛灉缁存姢浜嗕竴鑷存�ф牳瀵归」鐩�(components.length > 0),鍒欒姹傚畬鎴愭牳瀵�
+          if (res.data && res.data.length > 0) {
+            uni.showModal({
+              title: "鎻愮ず",
+              content: "璇峰厛瀹屾垚涓�鑷存�ф牳瀵瑰悗鍐嶆彁浜ゆ楠�",
+              confirmText: "鍘绘牳瀵�",
+              cancelText: "鍙栨秷",
+              success: (modalRes) => {
+                if (modalRes.confirm) {
+                  this.toYzxSubmitFrom(this.formData.billNo);
+                }
+              }
+            });
+          } else {
+            // 鏈淮鎶や竴鑷存�ф牳瀵归」鐩�,鍏佽鐩存帴鎻愪氦
+            this.submitInspection();
+          }
+        }).catch(() => {
+          // 鎺ュ彛寮傚父,鍏佽鎻愪氦
+          this.submitInspection();
         });
         return;
       }
       
+      // 宸插畬鎴愪竴鑷存�ф牳瀵规垨涓嶉渶瑕佹牳瀵�,鐩存帴鎻愪氦
+      this.submitInspection();
+    },
+    
+    submitInspection() {
       this.$post({
         url: "/SJ/SJQaSubmit",
         data: {
@@ -286,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绉掑悗璺宠浆鍒板垪琛ㄩ〉闈�
@@ -299,12 +328,16 @@
         }
       }).catch(err => {
         console.log("鎻愪氦鍑洪敊:", err);
-        this.$showMessage("鎻愪氦澶辫触锛岃閲嶈瘯");
+        this.$showMessage("鎻愪氦澶辫触,璇烽噸璇�");
       })
     },
 
     init() {
       if (this.formData.id) {
+        // 浠庢湰鍦板瓨鍌ㄨ鍙栦竴鑷存�ф牳瀵圭姸鎬�
+        const storageKey = `yzxChecked_${this.formData.id}`;
+        const storedYzxChecked = uni.getStorageSync(storageKey);
+        
         this.$post({
           url: "/SJ/GetPage",
           data: {
@@ -315,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: {
@@ -442,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: {
@@ -549,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",
@@ -600,7 +647,7 @@
     }
   },
   onShow() {
-    //姣忔杩涘叆椤甸潰閮戒細鎵ц鐨勬柟娉�
+    // 姣忔杩涘叆椤甸潰閮戒細鎵ц鐨勬柟娉�
     this.init();
   }
 };

--
Gitblit v1.9.3