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 |  198 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 170 insertions(+), 28 deletions(-)

diff --git a/src/views/followvisit/discharge/index.vue b/src/views/followvisit/discharge/index.vue
index dfe664f..0ed1b45 100644
--- a/src/views/followvisit/discharge/index.vue
+++ b/src/views/followvisit/discharge/index.vue
@@ -94,6 +94,8 @@
             :options="sourcetype"
             :props="{ expandTrigger: 'hover' }"
             @change="handleChange"
+            filterable
+            clearable
           ></el-cascader>
         </el-form-item>
 
@@ -241,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
@@ -486,7 +503,6 @@
           prop="nurseName"
         />
         <el-table-column
-          v-if="orgname != '涓芥按甯備腑鍖婚櫌'"
           label="缁忕鍖荤敓"
           align="center"
           key="managementDoctor"
@@ -1096,12 +1112,13 @@
       dynamicTags: ["閫夐」涓�", "閫夐」浜�", "閫夐」涓�"], //閫夐」
       inputVisible: false,
       Labelchange: false,
-      ycvalue: "",
+      ycvalue: 0,
       jgvalue: "",
       yfsvalue: "",
       inputValue: "",
       preachform: "",
       previewVisible: false, //褰卞儚闅忚棰勮寮规
+      isRestoring: false,
       radio: "",
       radios: [],
       previewtype: 2, //棰勮褰卞儚闅忚绫诲瀷
@@ -1109,6 +1126,8 @@
       // 婊℃剰搴﹁皟鏌ユ暟鎹�
       scoreDialogVisible: false,
       selectedRows: [],
+      selectedRowMap: new Map(), // key: row.id, value: row 鏁版嵁
+
       // 绾ц仈閫夋嫨鍣ㄧ粦瀹氬��
       serviceStatusValue: 10,
       cascaderProps: {
@@ -1205,7 +1224,8 @@
         btstatus: "",
       },
       // endOut: 1,
-      endOut: localStorage.getItem("orgname") == "涓芥按甯備腑鍖婚櫌" ? 0 : 1, //0 鍑洪櫌鏃堕棿(姝e簭)    1 鍑洪櫌鏃堕棿(鍊掑簭)   2 鍙戦�佹椂闂�(姝e簭)    3 鍙戦�佹椂闂�(鍊掑簭)  7搴旈殢璁挎棩鏈�(鍊掑簭) 搴旈殢璁挎棩鏈�(姝e簭)
+      endOut:
+        localStorage.getItem("orgname") == "鏅畞鐣叉棌鑷不鍘夸汉姘戝尰闄�" ? 0 : 1, //0 鍑洪櫌鏃堕棿(姝e簭)    1 鍑洪櫌鏃堕棿(鍊掑簭)   2 鍙戦�佹椂闂�(姝e簭)    3 鍙戦�佹椂闂�(鍊掑簭)  7搴旈殢璁挎棩鏈�(鍊掑簭) 搴旈殢璁挎棩鏈�(姝e簭)
       endOuts: [
         {
           value: 0,
@@ -1362,10 +1382,9 @@
     // 鐩戝惉璺敱鍙傛暟鍙樺寲
     "$route.query": {
       handler(newQuery, oldQuery) {
-        if (newQuery.errtype !== oldQuery.errtype) {
+        if (newQuery?.errtype !== oldQuery?.errtype) {
           console.log(22);
-
-          this.loadData(); // 閲嶆柊鍔犺浇鏁版嵁
+          this.loadData();
         }
       },
       immediate: true,
@@ -1434,7 +1453,7 @@
   },
   methods: {
     /** 鏌ヨ闅忚鏈嶅姟鍒楄〃 */
-    getList(refresh) {
+    async getList(refresh) {
       // 榛樿鍏ㄩ儴
       if (this.topqueryParams.searchscope == 3) {
         this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
@@ -1447,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]
@@ -1465,27 +1485,43 @@
       } 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 = response.rows[0].yc;
+          this.ycvalue = Number(response.rows[0].yc) || 0;
           this.jgvalue = response.rows[0].jg;
           this.cardlist[2].value = response.rows[0].xsf || 0;
           this.cardlist[3].value = response.rows[0].dsf || 0;
           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) {
@@ -1499,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;
@@ -1589,7 +1634,7 @@
           Number(response.rows[0].wxsf) + Number(response.rows[0].xsf) || 0;
         this.cardlist[1].value = response.rows[0].wzx;
         this.cardlist[2].value = response.rows[0].ysf;
-        this.ycvalue = response.rows[0].yc;
+        this.ycvalue = Number(response.rows[0].yc) || 0;
         this.jgvalue = response.rows[0].jg;
         this.cardlist[3].value = response.rows[0].fssb;
         this.cardlist[4].value = response.rows[0].dsf;
@@ -1694,10 +1739,20 @@
     },
     // 鎮h�呰寖鍥村鐞�
     handleChange(value) {
-      let type = value[0];
-      let code = value.slice(-1)[0];
+      console.log("閫夋嫨鐨勬偅鑰呰寖鍥�:", value);
+
+      // 娓呯┖涔嬪墠鐨勬煡璇㈠弬鏁�
       this.topqueryParams.leavehospitaldistrictcodes = [];
       this.topqueryParams.leaveldeptcodes = [];
+      this.topqueryParams.searchscope = null;
+
+      if (!value || value.length === 0) {
+        return;
+      }
+
+      let type = value[0];
+      let code = value.slice(-1)[0];
+
       if (type == 1) {
         this.topqueryParams.leaveldeptcodes.push(code);
         this.topqueryParams.leavehospitaldistrictcodes = [];
@@ -1761,9 +1816,17 @@
       this.handleQuery(1);
     },
     handleSelectionChange(rows) {
-      this.selectedRows = rows.map((row) => {
-        // 鍒濆鍖栬瘎鍒嗗瓧娈�
-        return {
+      // 鉁� 濡傛灉鏄仮澶嶉�変腑鐘舵�佽Е鍙戠殑锛岀洿鎺ヨ繑鍥�
+      if (this.isRestoring) {
+        console.log("姝e湪鎭㈠閫変腑鐘舵�侊紝璺宠繃 handleSelectionChange");
+        return;
+      }
+
+      console.log("handleSelectionChange 琚Е鍙戯紝閫変腑琛屾暟:", rows.length);
+
+      // 鍙仛娣诲姞鎿嶄綔
+      rows.forEach((row) => {
+        this.selectedRowMap.set(row.id, {
           ...row,
           authenticity: row.authenticity || 0,
           weekFinish: row.weekFinish || 0,
@@ -1773,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;
     },
 
     // 璁$畻鎬诲垎
@@ -2080,6 +2140,7 @@
       const originalPageSize = this.topqueryParams.pageSize;
       this.topqueryParams.pageNum = null;
       this.topqueryParams.pageSize = null;
+      this.topqueryParams.subIdList = this.selectedRows.map((item) => item.id);
       this.download(
         "smartor/serviceSubtask/patItemExport",
         {
@@ -2101,6 +2162,76 @@
         return "remind-row";
       }
       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() {
@@ -2371,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