From d3c60e18b95b50751f8088fa2d23cd8ff7f173bc Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期三, 01 七月 2026 11:05:17 +0800
Subject: [PATCH] 测试完成

---
 src/views/followvisit/discharge/index.vue |  166 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 147 insertions(+), 19 deletions(-)

diff --git a/src/views/followvisit/discharge/index.vue b/src/views/followvisit/discharge/index.vue
index 8725d92..0ed1b45 100644
--- a/src/views/followvisit/discharge/index.vue
+++ b/src/views/followvisit/discharge/index.vue
@@ -243,12 +243,27 @@
           </div>
         </el-col>
       </el-row>
+      <div class="selected-info">
+        宸查�変腑
+        <span style="color: #409eff; font-weight: bold">{{
+          getSelectedCount()
+        }}</span>
+        鏉℃暟鎹�
+        <el-button
+          v-if="getSelectedCount() > 0"
+          type="text"
+          @click="clearAllSelection"
+        >
+          娓呴櫎閫変腑
+        </el-button>
+      </div>
       <el-table
         v-loading="loading"
         ref="userform"
         :data="userList"
         :row-class-name="tableRowClassName"
         @selection-change="handleSelectionChange"
+        @select-all="handleSelectAll"
       >
         <el-table-column type="selection" width="50" align="center" />
         <el-table-column
@@ -1103,6 +1118,7 @@
       inputValue: "",
       preachform: "",
       previewVisible: false, //褰卞儚闅忚棰勮寮规
+      isRestoring: false,
       radio: "",
       radios: [],
       previewtype: 2, //棰勮褰卞儚闅忚绫诲瀷
@@ -1110,6 +1126,8 @@
       // 婊℃剰搴﹁皟鏌ユ暟鎹�
       scoreDialogVisible: false,
       selectedRows: [],
+      selectedRowMap: new Map(), // key: row.id, value: row 鏁版嵁
+
       // 绾ц仈閫夋嫨鍣ㄧ粦瀹氬��
       serviceStatusValue: 10,
       cascaderProps: {
@@ -1435,7 +1453,7 @@
   },
   methods: {
     /** 鏌ヨ闅忚鏈嶅姟鍒楄〃 */
-    getList(refresh) {
+    async getList(refresh) {
       // 榛樿鍏ㄩ儴
       if (this.topqueryParams.searchscope == 3) {
         this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
@@ -1448,16 +1466,17 @@
         this.topqueryParams.endSendDateTime = this.formatDateToYYYYMMDDHHMMSS(
           this.getEndOfDay()
         );
-      } else {
-        // this.topqueryParams.endSendDateTime = null;
       }
+
       // 鎺ュ彈寮傚父璺宠浆
       if (this.errtype) {
         this.topqueryParams.leavehospitaldistrictcodes.push(
           this.leavehospitaldistrictcode
         );
       }
+
       this.loading = true;
+
       if (
         this.topqueryParams.leavehospitaldistrictcodes[0] &&
         this.topqueryParams.leaveldeptcodes[0]
@@ -1466,18 +1485,33 @@
       } else {
         this.topqueryParams.deptOrDistrict = 1;
       }
+
       if (!this.followupAuthority()) {
         this.$message.warning("鏈厤缃瀹�/鐥呭尯鐩稿叧鏉冮檺涓嶅彲鏌ヨ");
+        this.loading = false;
         return Promise.reject(new Error("鏃犳潈闄愭煡璇�"));
       }
 
-      getTaskservelist(this.topqueryParams).then((response) => {
+      try {
+        const response = await getTaskservelist(this.topqueryParams);
+
+        // 鉁� 绗竴姝ワ細鍏堥攣瀹氭仮澶嶇姸鎬�
+        this.isRestoring = true;
+
+        // 鉁� 绗簩姝ワ細鍐嶆洿鏂版暟鎹紙杩欎細瑙﹀彂 selection-change锛屼絾琚攣浣忎簡锛�
         this.userList = response.rows[0].serviceSubtaskList;
         this.total = response.total;
+
+        // 鉁� 绗笁姝ワ細鎭㈠閫変腑鐘舵��
+        // this.restoreSelection();
+        this.$nextTick(() => {
+          this.restoreSelection();
+        });
+
+        // 鉁� 绗洓姝ワ細澶勭悊鍏朵粬鏁版嵁
         if (refresh) {
           this.cardlist[0].value =
             Number(response.rows[0].wxsf) + Number(response.rows[0].xsf) || 0;
-          // this.cardlist[1].value = response.rows[0].wzx;
           this.cardlist[1].value = response.rows[0].wxsf || 0;
           this.ycvalue = Number(response.rows[0].yc) || 0;
           this.jgvalue = response.rows[0].jg;
@@ -1486,7 +1520,8 @@
           this.cardlist[4].value = response.rows[0].ywc || 0;
           this.yfsvalue = response.rows[0].yfs;
         }
-        this.loading = false;
+
+        // 鉁� 绗簲姝ワ細澶勭悊 preachform 绛夊叾浠栨暟鎹�
         this.userList.forEach((item) => {
           let idArray = null;
           if (item.endtime) {
@@ -1500,17 +1535,26 @@
             }
 
             item.preachform = idArray.map((value) => {
-              // 鏌ユ壘id瀵瑰簲鐨勫璞�
               const item = this.checkboxlist.find(
                 (item) => item.value == value
               );
-              // 濡傛灉鎵惧埌瀵瑰簲鐨刬d锛岃繑鍥瀕abel鍊硷紝鍚﹀垯杩斿洖null
               return item ? item.label : null;
             });
           }
         });
+
         this.total = response.total;
-      });
+        this.loading = false;
+
+        // 鉁� 绗叚姝ワ細瑙i攣
+        this.$nextTick(() => {
+          this.isRestoring = false;
+        });
+      } catch (error) {
+        console.error("鑾峰彇鍒楄〃澶辫触:", error);
+        this.loading = false;
+        this.isRestoring = false;
+      }
     },
     loadData() {
       this.errtype = this.$route.query.errtype;
@@ -1772,11 +1816,17 @@
       this.handleQuery(1);
     },
     handleSelectionChange(rows) {
-      console.log(rows, 911);
+      // 鉁� 濡傛灉鏄仮澶嶉�変腑鐘舵�佽Е鍙戠殑锛岀洿鎺ヨ繑鍥�
+      if (this.isRestoring) {
+        console.log("姝e湪鎭㈠閫変腑鐘舵�侊紝璺宠繃 handleSelectionChange");
+        return;
+      }
 
-      this.selectedRows = rows.map((row) => {
-        // 鍒濆鍖栬瘎鍒嗗瓧娈�
-        return {
+      console.log("handleSelectionChange 琚Е鍙戯紝閫変腑琛屾暟:", rows.length);
+
+      // 鍙仛娣诲姞鎿嶄綔
+      rows.forEach((row) => {
+        this.selectedRowMap.set(row.id, {
           ...row,
           authenticity: row.authenticity || 0,
           weekFinish: row.weekFinish || 0,
@@ -1786,14 +1836,11 @@
           environment: row.environment || 0,
           doctorSatisfaction: row.doctorSatisfaction || 0,
           nurseSatisfaction: row.nurseSatisfaction || 0,
-        };
+        });
       });
 
-      if (this.selectedRows.length > 0) {
-        this.multiple = false;
-      } else {
-        this.multiple = true;
-      }
+      this.selectedRows = Array.from(this.selectedRowMap.values());
+      this.multiple = this.selectedRows.length === 0;
     },
 
     // 璁$畻鎬诲垎
@@ -2116,6 +2163,76 @@
       }
       return "";
     },
+    restoreSelection() {
+      if (!this.$refs.userform) {
+        console.log("琛ㄦ牸寮曠敤涓嶅瓨鍦�");
+        return;
+      }
+
+      console.log("鎵ц restoreSelection");
+
+      // 娓呴櫎褰撳墠椤电殑鎵�鏈夐�変腑鐘舵��
+      this.$refs.userform.clearSelection();
+
+      // 鎵惧嚭褰撳墠椤典腑鍝簺琛屾槸琚�変腑鐨�
+      const toBeSelected = this.userList.filter((row) =>
+        this.selectedRowMap.has(row.id)
+      );
+
+      console.log("闇�瑕佹仮澶嶇殑琛屾暟:", toBeSelected.length);
+
+      // 閲嶆柊閫変腑杩欎簺琛�
+      toBeSelected.forEach((row) => {
+        this.$refs.userform.toggleRowSelection(row, true);
+      });
+    },
+    // 鉁� 澶勭悊琛ㄥご鍏ㄩ�変簨浠�
+    handleSelectAll(selection) {
+      console.log("鍏ㄩ�変簨浠惰Е鍙戯紝閫変腑琛屾暟:", selection.length);
+
+      // 濡傛灉 selection 闀垮害绛変簬褰撳墠椤佃鏁帮紝璇存槑鏄叏閫�
+      if (selection.length === this.userList.length) {
+        // 鍏ㄩ�夊綋鍓嶉〉
+        this.userList.forEach((row) => {
+          this.selectedRowMap.set(row.id, {
+            ...row,
+            authenticity: row.authenticity || 0,
+            weekFinish: row.weekFinish || 0,
+            standard: row.standard || 0,
+            timeliness: row.timeliness || 0,
+            library: row.library || 0,
+            environment: row.environment || 0,
+            doctorSatisfaction: row.doctorSatisfaction || 0,
+            nurseSatisfaction: row.nurseSatisfaction || 0,
+          });
+        });
+      } else {
+        // 鍙栨秷鍏ㄩ�夛細娓呴櫎褰撳墠椤电殑閫変腑鐘舵��
+        this.userList.forEach((row) => {
+          this.selectedRowMap.delete(row.id);
+        });
+      }
+
+      // 鏇存柊 selectedRows
+      this.selectedRows = Array.from(this.selectedRowMap.values());
+      this.multiple = this.selectedRows.length === 0;
+    },
+
+    // 娓呴櫎鎵�鏈夐�変腑
+    clearAllSelection() {
+      this.selectedRowMap.clear();
+      this.selectedRows = [];
+      this.multiple = true;
+
+      if (this.$refs.userform) {
+        this.$refs.userform.clearSelection();
+      }
+    },
+
+    // 鑾峰彇閫変腑鏁伴噺
+    getSelectedCount() {
+      return this.selectedRowMap.size;
+    },
     // 鍒涘缓鍐嶆闅忚鏈嶅姟
     setupsubtask() {
       this.$refs["zcform"].validate((valid) => {
@@ -2385,4 +2502,15 @@
   flex-shrink: 0;
   margin-top: 2px;
 }
+
+::v-deep .el-table__row.selected-row:hover > td {
+  background-color: #e6f7ff !important;
+}
+
+/* 閫変腑淇℃伅鏄剧ず */
+.selected-info {
+  padding: 10px 0;
+  font-size: 14px;
+  color: #666;
+}
 </style>

--
Gitblit v1.9.3