From b57c6c97c7de4cb5aeeb6c766a4642fac5b9b500 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期五, 21 八月 2026 15:07:10 +0800
Subject: [PATCH] 测试完成

---
 src/views/followvisit/discharge/index.vue |  108 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 63 insertions(+), 45 deletions(-)

diff --git a/src/views/followvisit/discharge/index.vue b/src/views/followvisit/discharge/index.vue
index 15b77d9..2412250 100644
--- a/src/views/followvisit/discharge/index.vue
+++ b/src/views/followvisit/discharge/index.vue
@@ -92,10 +92,11 @@
             v-model="topqueryParams.scopetype"
             placeholder="榛樿鍏ㄩ儴"
             :options="sourcetype"
-            :props="{ expandTrigger: 'hover' }"
+            :props="{ expandTrigger: 'hover', multiple: true }"
             @change="handleChange"
             filterable
             clearable
+            collapse-tags
           ></el-cascader>
         </el-form-item>
 
@@ -1192,6 +1193,7 @@
           label: "鍏ㄩ儴",
         },
       ],
+      lastScopeType: 3, // 鎮h�呰寖鍥翠笂娆¢�夋嫨鐨勪竴绾х被鍨嬶紙1=绉戝锛�2=鐥呭尯锛�3=鍏ㄩ儴锛�
       loading: false,
       cardlist: [
         {
@@ -1293,7 +1295,7 @@
         visitCount: 1,
         scopetype: [],
         managementDoctor:
-          localStorage.getItem("orgname") == "缂欎簯鍘夸汉姘戝尰闄�"
+          localStorage.getItem("orgname") == "缂欎簯鍘夸汉姘戝尰闄�"||localStorage.getItem("orgname") == "涓芥按甯備腑鍖婚櫌"
             ? store.getters.nickName
             : "",
         leaveldeptcodes: [],
@@ -1493,13 +1495,7 @@
     /** 鏌ヨ闅忚鏈嶅姟鍒楄〃 */
     async getList(refresh) {
       // 榛樿鍏ㄩ儴
-      if (this.topqueryParams.searchscope == 3) {
-        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
-          (obj) => obj.deptCode
-        );
-        this.topqueryParams.leavehospitaldistrictcodes =
-          store.getters.belongWards.map((obj) => obj.districtCode);
-      }
+      this.applyDeptWardScope();
       if (this.endOut == 0) {
         this.topqueryParams.endSendDateTime = this.formatDateToYYYYMMDDHHMMSS(
           this.getEndOfDay()
@@ -1681,13 +1677,7 @@
       if (type) {
         this.resetQuerykj();
       }
-      if (this.topqueryParams.searchscope == 3) {
-        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
-          (obj) => obj.deptCode
-        );
-        this.topqueryParams.leavehospitaldistrictcodes =
-          store.getters.belongWards.map((obj) => obj.districtCode);
-      }
+      this.applyDeptWardScope();
       // 鎺ュ彈寮傚父璺宠浆
       if (this.errtype) {
         this.topqueryParams.leavehospitaldistrictcodes.push(
@@ -1795,13 +1785,7 @@
     },
     /** 鎼滅储鎸夐挳鎿嶄綔 */
     handleQuery(refresh) {
-      if (this.topqueryParams.searchscope == 3) {
-        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
-          (obj) => obj.deptCode
-        );
-        this.topqueryParams.leavehospitaldistrictcodes =
-          store.getters.belongWards.map((obj) => obj.districtCode);
-      }
+      this.applyDeptWardScope();
       this.topqueryParams.pageNum = 1;
       // 鍒ゆ柇鏄笉鏄伐浣滃彴蹇嵎鏌ヨ
       if (this.errtype != 2) {
@@ -1812,33 +1796,65 @@
       }
       this.getList(refresh);
     },
-    // 鎮h�呰寖鍥村鐞�
+    // 鎮h�呰寖鍥村鐞嗭細浠庡閫夌骇鑱� scopetype 瑙f瀽绉戝/鐥呭尯
+    applyDeptWardScope() {
+      const value = this.topqueryParams.scopetype || [];
+      const deptCodes = [];
+      const wardCodes = [];
+      let isAll = false;
+
+      value.forEach((item) => {
+        const type = item[0];
+        if (type == 3) {
+          isAll = true;
+        } else if (type == 1) {
+          deptCodes.push(item[item.length - 1]);
+        } else if (type == 2) {
+          wardCodes.push(item[item.length - 1]);
+        }
+      });
+
+      // 閫変簡鍏ㄩ儴 鎴� 鏈�夋嫨 鈫� 鐢ㄦ埛鍏ㄩ儴绉戝/鐥呭尯
+      if (isAll || (!deptCodes.length && !wardCodes.length)) {
+        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
+          (obj) => obj.deptCode
+        );
+        this.topqueryParams.leavehospitaldistrictcodes =
+          store.getters.belongWards.map((obj) => obj.districtCode);
+      } else {
+        this.topqueryParams.leaveldeptcodes = deptCodes;
+        this.topqueryParams.leavehospitaldistrictcodes = wardCodes;
+      }
+    },
+    // 鎮h�呰寖鍥村閫夊彉鏇达紙绉戝/鐥呭尯浜掓枼锛�
     handleChange(value) {
-      console.log("閫夋嫨鐨勬偅鑰呰寖鍥�:", value);
+      const types = (value || []).map((item) => item[0]);
+      const hasDept = types.includes(1);
+      const hasWard = types.includes(2);
 
-      // 娓呯┖涔嬪墠鐨勬煡璇㈠弬鏁�
-      this.topqueryParams.leavehospitaldistrictcodes = [];
-      this.topqueryParams.leaveldeptcodes = [];
-      this.topqueryParams.searchscope = null;
-
-      if (!value || value.length === 0) {
+      // 浜掓枼锛氱瀹ゅ拰鐥呭尯涓嶈兘鍚屾椂閫�
+      if (hasDept && hasWard) {
+        if (this.lastScopeType == 1) {
+          // 涓婃閫変簡绉戝锛岃繖娆℃柊澧炵梾鍖� 鈫� 淇濈暀鐥呭尯
+          this.topqueryParams.scopetype = value.filter(
+            (item) => item[0] === 2
+          );
+          this.lastScopeType = 2;
+          this.$message.warning("绉戝鍜岀梾鍖轰笉鑳藉悓鏃堕�夋嫨锛屽凡鍒囨崲涓虹梾鍖�");
+        } else {
+          // 涓婃閫変簡鐥呭尯锛岃繖娆℃柊澧炵瀹� 鈫� 淇濈暀绉戝
+          this.topqueryParams.scopetype = value.filter(
+            (item) => item[0] === 1
+          );
+          this.lastScopeType = 1;
+          this.$message.warning("绉戝鍜岀梾鍖轰笉鑳藉悓鏃堕�夋嫨锛屽凡鍒囨崲涓虹瀹�");
+        }
+        this.applyDeptWardScope();
         return;
       }
 
-      let type = value[0];
-      let code = value.slice(-1)[0];
-
-      if (type == 1) {
-        this.topqueryParams.leaveldeptcodes.push(code);
-        this.topqueryParams.leavehospitaldistrictcodes = [];
-        this.topqueryParams.searchscope = 1;
-      } else if (type == 2) {
-        this.topqueryParams.leavehospitaldistrictcodes.push(code);
-        this.topqueryParams.leaveldeptcodes = [];
-        this.topqueryParams.searchscope = 2;
-      } else {
-        this.topqueryParams.searchscope = 3;
-      }
+      this.lastScopeType = hasDept ? 1 : hasWard ? 2 : 3;
+      this.applyDeptWardScope();
     },
     // 鏈嶅姟鐘舵�佸彉鏇村鐞�
     handleServiceStatusChange(value) {
@@ -1876,6 +1892,7 @@
       this.dateRange = [];
       this.dateRangefs = [];
       this.serviceStatusValue = 10;
+      this.lastScopeType = 3;
       this.topqueryParams = {
         pageNum: 1,
         pageSize: 10,
@@ -1895,6 +1912,7 @@
       this.dateRange = [];
       this.dateRangefs = [];
       this.serviceStatusValue = null;
+      this.lastScopeType = 3;
       this.topqueryParams = {
         pageNum: 1,
         pageSize: 10,

--
Gitblit v1.9.3