From 5821664d8e34973ec0e0123228c3591da51cdd2f Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期一, 28 七月 2025 17:38:00 +0800
Subject: [PATCH] 全选问题,动态url

---
 src/views/doctor/inspectCheck/index.vue |  101 ++++++++++++++++++++++++++++----------------------
 1 files changed, 56 insertions(+), 45 deletions(-)

diff --git a/src/views/doctor/inspectCheck/index.vue b/src/views/doctor/inspectCheck/index.vue
index 943887e..10bcf44 100644
--- a/src/views/doctor/inspectCheck/index.vue
+++ b/src/views/doctor/inspectCheck/index.vue
@@ -22,7 +22,8 @@
       <div class="table-header">妫�楠岃褰�</div>
       <div>
         <el-table :data="exaLists" border style="width: 100%" @selection-change="handleSelectionChange"
-          :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }" height="350" ref="firstTable">
+          @select-all="handleSelectAll" :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }"
+          height="350" ref="firstTable">
           <el-table-column fixed type="selection" align="center" label="閫夋嫨" width="50" />
           <el-table-column label="濮撳悕" align="center" prop="name" width="80" />
           <el-table-column label="鎬у埆" align="center" prop="gender" width="80" />
@@ -89,7 +90,6 @@
     </el-table>
   </div>
 </template>
-
 <script>
 import { getlisList, getJyTjList, asyncPacs } from "@/api/doctor/pacsCheck";
 import { getOrderList } from "@/api/hosp/order";
@@ -145,57 +145,59 @@
       this.exaLists = [];
       this.checkList = [];
       this.infoList = {};
+      this.selectedFirstTable = [];
+      this.selectedSecondTable = [];
     },
-    handleSelectionChange(selected) {
+
+    // 鉁� 鍒嗙粍澶氶�夌ǔ鍥虹増
+    handleSelectionChange(selection) {
       if (this.isProcessingSelection) return;
       this.isProcessingSelection = true;
 
-      // 鎵惧埌鐢ㄦ埛鍒氭搷浣滅殑閭d竴鏉★紙瀵规瘮涔嬪墠鍜岀幇鍦ㄧ殑宸紓锛�
-      const old = this.selectedFirstTable;
-      let changedRow = null;
+      // 璁$畻鎵�鏈夎閫変腑鐨勫垎缁� brid
+      const allBrids = new Set();
+      selection.forEach(row => allBrids.add(row.brid));
 
-      if (selected.length > old.length) {
-        // 鏂板锛氭壘鍑烘柊澧炵殑
-        changedRow = selected.find(row => !old.includes(row));
-      } else {
-        // 鍒犻櫎锛氭壘鍑哄垹闄ょ殑
-        changedRow = old.find(row => !selected.includes(row));
-      }
+      // 娓呯┖鍚庨噸閫�
+      this.$refs.firstTable.clearSelection();
+      this.$nextTick(() => {
+        const newSelection = this.exaLists.filter(row => allBrids.has(row.brid));
+        newSelection.forEach(row => {
+          this.$refs.firstTable.toggleRowSelection(row, true);
+        });
+        this.selectedFirstTable = newSelection;
+        this.isProcessingSelection = false;
+        this.fetchRightTableData();
+      });
+    },
 
-      if (changedRow) {
-        const group = this.exaLists.filter(r => r.brid === changedRow.brid);
-        const isAdding = selected.length > old.length;
+    handleSelectAll(selection) {
+      if (this.isProcessingSelection) return;
+      this.isProcessingSelection = true;
 
+      if (selection.length === 0) {
+        // 鍙栨秷鍏ㄩ��
         this.$refs.firstTable.clearSelection();
-        if (isAdding) {
-          // 娣诲姞锛屾暣涓粍閫変笂 + 鍘熸湁閫夌殑 brid 涔熼�変笂
-          const allBrids = new Set();
-          selected.forEach(row => allBrids.add(row.brid));
-          allBrids.add(changedRow.brid);
+        this.selectedFirstTable = [];
+        this.isProcessingSelection = false;
+        this.fetchRightTableData();
+      } else {
+        // 鍏ㄩ�夋墍鏈夊垎缁�
+        const allBrids = new Set(this.exaLists.map(row => row.brid));
+        this.$refs.firstTable.clearSelection();
+        this.$nextTick(() => {
           const newSelection = this.exaLists.filter(row => allBrids.has(row.brid));
           newSelection.forEach(row => {
             this.$refs.firstTable.toggleRowSelection(row, true);
           });
           this.selectedFirstTable = newSelection;
-        } else {
-          // 鍒犻櫎锛屾暣涓粍鍙栨秷锛屽啀鎶婂墿涓� brid 鍒嗙粍琛ュ洖鍘�
-          const remaining = old.filter(row => row.brid !== changedRow.brid);
-          const remainBrids = [...new Set(remaining.map(r => r.brid))];
-          const newSelection = this.exaLists.filter(row => remainBrids.includes(row.brid));
-          newSelection.forEach(row => {
-            this.$refs.firstTable.toggleRowSelection(row, true);
-          });
-          this.selectedFirstTable = newSelection;
-        }
-      } else {
-        this.selectedFirstTable = selected;
+          this.isProcessingSelection = false;
+          this.fetchRightTableData();
+        });
       }
-
-      this.fetchRightTableData();
-      this.isProcessingSelection = false;
     },
 
-
+    // 绗簩涓〃鏍煎彧鍏佽鍗曢��
     handleSelectionChangeSecond(selected) {
       this.selectedSecondTable = selected.slice(0, 1);
     },
@@ -215,16 +217,24 @@
     tongbu() {
       this.$modal.loading("姝e湪鍚屾锛岃绋嶅��...");
       const requestData = {
-        lis: this.selectedFirstTable ? this.selectedFirstTable.map((item) => ({
-          ...item,
-          tjNum: this.queryParams.tjNum,
-        })) : [],
-        jcxmid: this.selectedFirstTable && this.selectedFirstTable.length > 0 ? this.selectedFirstTable[0].jcxmid : null,
-        shys: this.selectedFirstTable && this.selectedFirstTable.length > 0 ? this.selectedFirstTable[0].shys : null,
+        lis: this.selectedFirstTable
+          ? this.selectedFirstTable.map(item => ({
+              ...item,
+              tjNum: this.queryParams.tjNum,
+            }))
+          : [],
+        jcxmid:
+          this.selectedFirstTable && this.selectedFirstTable.length > 0
+            ? this.selectedFirstTable[0].jcxmid
+            : null,
+        shys:
+          this.selectedFirstTable && this.selectedFirstTable.length > 0
+            ? this.selectedFirstTable[0].shys
+            : null,
         tj: this.selectedSecondTable[0],
       };
       asyncPacs(requestData)
-        .then((res) => {
+        .then(res => {
           if (res.code === 200) {
             this.fetchRightTableData();
             clearInterval(this.clearTimeSet);
@@ -235,7 +245,7 @@
             this.$message.error(res.message || "鍚屾澶辫触锛岃绋嶅悗閲嶈瘯");
           }
         })
-        .catch((error) => {
+        .catch(() => {
           clearInterval(this.clearTimeSet);
           this.clearTimeSet = null;
           this.$modal.closeLoading();
@@ -245,6 +255,7 @@
 };
 </script>
 
+
 <style lang="scss" scoped>
 .app-container {
   padding: 20px;

--
Gitblit v1.8.0