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/detail.vue |   85 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/pages/QC/SJ/detail.vue b/pages/QC/SJ/detail.vue
index 2754d7e..c2acbf4 100644
--- a/pages/QC/SJ/detail.vue
+++ b/pages/QC/SJ/detail.vue
@@ -218,6 +218,42 @@
     }
   },
   methods: {
+    // 妫�鏌ユ墍鏈夋楠岄」鐩槸鍚﹀凡瀹屾垚
+    checkAllItemsCompleted() {
+      this.$post({
+        url: "/SJ/getQSItems",
+        data: {
+          pid: this.gid,
+        }
+      }).then(res => {
+        if (res.data && res.data.tbBillList) {
+          const allItems = res.data.tbBillList;
+          // 妫�鏌ユ槸鍚︽墍鏈夐」鐩兘涓嶆槸"鏈畬鎴�"鐘舵��
+          const allCompleted = allItems.every(item => item.result !== '鏈畬鎴�');
+          
+          if (allCompleted) {
+            // 鎵�鏈夐」鐩凡瀹屾垚锛屼笉鑷姩璺宠浆锛岀敤鎴锋墜鍔ㄨ繑鍥�
+            // const pages = getCurrentPages();
+            // if (pages.length >= 2) {
+            //   const prevPage = pages[pages.length - 2];
+            //   const route = '/' + prevPage.route;
+            //   const options = prevPage.options;
+            //   let query = '';
+            //   for (let key in options) {
+            //     query += `${key}=${options[key]}&`;
+            //   }
+            //   query = query.slice(0, -1);
+            //   setTimeout(() => {
+            //     uni.redirectTo({
+            //       url: query ? `${route}?${query}` : route
+            //     });
+            //   }, 1000);
+            // }
+          }
+        }
+      });
+    },
+
     // 鍒囨崲鏍囩椤�
     switchTab(index, id) {
       this.currentTab = index;
@@ -245,6 +281,15 @@
               return 0;
             }
           });
+          
+          // 鏍规嵁褰撳墠id鏌ユ壘瀵瑰簲鐨勬爣绛剧储寮曪紙鍙傝�僉LJ瀹炵幇锛�
+          const foundIndex = this.tabs.findIndex(tab => tab.id == this.id); // 浣跨敤==鑰岄潪===锛岄伩鍏嶇被鍨嬩笉鍖归厤
+          if (foundIndex !== -1) {
+            this.currentTab = foundIndex;
+          } else {
+            // 濡傛灉娌℃壘鍒帮紝榛樿璺宠浆鍒扮涓�涓爣绛�
+            this.currentTab = 0;
+          }
         } else {
           // 娌℃湁椤圭洰鏃惰嚦灏戞坊鍔犲綋鍓嶉」鐩埌鏍囩
           this.tabs = [{id: this.id, projName: this.formData.projName || '褰撳墠椤圭洰'}];
@@ -322,9 +367,38 @@
       }).then(res => {
         this.formData.fcheckResu = null;
         this.$showMessage("淇濆瓨鎴愬姛");
-        this.refreshResult();
+        
         // 閲嶆柊鍔犺浇鏍囩椤逛互鏇存柊鐘舵��
         this.loadTabItems();
+        
+        // 绛夊緟tabs鏇存柊鍚�,鏌ユ壘涓嬩竴涓湭瀹屾垚鐨勯」鐩�
+        this.$nextTick(() => {
+          // 鏌ユ壘涓嬩竴涓湭瀹屾垚鐨勯」鐩�
+          const nextUnfinishedIndex = this.tabs.findIndex((tab, index) => 
+            index > this.currentTab && tab.result === '鏈畬鎴�'
+          );
+          
+          if (nextUnfinishedIndex !== -1) {
+            // 鎵惧埌浜嗕笅涓�涓湭瀹屾垚鐨勯」鐩�,璺宠浆杩囧幓
+            this.currentTab = nextUnfinishedIndex;
+            this.id = this.tabs[nextUnfinishedIndex].id;
+            this.refreshResult();
+          } else {
+            // 娌℃湁涓嬩竴涓湭瀹屾垚鐨�,浠庡ご鏌ユ壘绗竴涓湭瀹屾垚鐨�
+            const firstUnfinishedIndex = this.tabs.findIndex(tab => tab.result === '鏈畬鎴�');
+            if (firstUnfinishedIndex !== -1) {
+              this.currentTab = firstUnfinishedIndex;
+              this.id = this.tabs[firstUnfinishedIndex].id;
+              this.refreshResult();
+            } else {
+              // 鎵�鏈夐」鐩兘宸插畬鎴�,鍒锋柊褰撳墠椤圭洰
+              this.refreshResult();
+            }
+          }
+        });
+        
+        // 妫�鏌ユ槸鍚︽墍鏈夋楠岄」鐩兘宸插畬鎴�
+        this.checkAllItemsCompleted();
       })
 
     },
@@ -435,6 +509,9 @@
         this.refreshResult();//鍒锋柊椤甸潰
         // 閲嶆柊鍔犺浇鏍囩椤逛互鏇存柊鐘舵��
         this.loadTabItems();
+        
+        // 妫�鏌ユ槸鍚︽墍鏈夋楠岄」鐩兘宸插畬鎴�
+        this.checkAllItemsCompleted();
       })
     },
     numberEdit(item) {
@@ -462,6 +539,9 @@
         this.refreshResult(); //鍒锋柊椤甸潰
         // 閲嶆柊鍔犺浇鏍囩椤逛互鏇存柊鐘舵��
         this.loadTabItems();
+        
+        // 妫�鏌ユ槸鍚︽墍鏈夋楠岄」鐩兘宸插畬鎴�
+        this.checkAllItemsCompleted();
       })
     },
     // 涓婁紶鍥剧墖
@@ -475,7 +555,8 @@
       this.remarks = this.formData.remarks;
     },
     editRemarks() {
-      if (this.remarks) {
+      // 鍏佽淇濆瓨绌哄瓧绗︿覆鎴栫┖鏍硷紝鍙鏌ユ槸鍚︿负null鎴杣ndefined
+      if (this.remarks !== null && this.remarks !== undefined) {
         //saveRemarksGid
         this.$post({
           url: "/SJ/saveRemarksPid",

--
Gitblit v1.9.3