From 9903954c85f651dd5cc6d4b538cfe66b17fc5baa Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 28 十月 2026 18:23:45 +0800
Subject: [PATCH] 提交

---
 src/views/followvisit/discharge/index.vue |  322 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 299 insertions(+), 23 deletions(-)

diff --git a/src/views/followvisit/discharge/index.vue b/src/views/followvisit/discharge/index.vue
index 8af1406..fb47a9e 100644
--- a/src/views/followvisit/discharge/index.vue
+++ b/src/views/followvisit/discharge/index.vue
@@ -5,6 +5,8 @@
       :ycvalue="ycvalue"
       :jgvalue="jgvalue"
       :show-warning-condition="orgname == '鐪佺珛鍚屽痉缈犺嫅闄㈠尯'"
+      clickable
+      @card-click="handleCardClick"
     />
     <el-row :gutter="20">
       <!--鐢ㄦ埛鏁版嵁-->
@@ -243,7 +245,23 @@
             </div>
           </div>
         </el-col>
+        <div class="color-legend">
+          <span class="legend-item" v-if="orgname == '鍗楀崕澶у闄勫睘绗竴鍖婚櫌'">
+            <span class="legend-block legend-blue"></span>鏈埌闅忚鏃堕棿
+          </span>
+          <span class="legend-item">
+            <span class="legend-block legend-red"></span>濉姤鍐呭瀛樺湪寮傚父
+          </span>
+          <span class="legend-item">
+            <span class="legend-block legend-yellow"></span>濉姤鍐呭瀛樺湪璀﹀憡
+          </span>
+        </div>
       </el-row>
+      <div v-if="cardFilter" class="card-filter-tip">
+        褰撳墠鎸夐《閮ㄥ崱鐗囩瓫閫夛細<b>{{ cardFilter }}</b>
+        <span class="tip-desc">锛堜笉褰卞搷涓婃柟琛ㄥ崟鏉′欢锛岀偣銆屾悳绱€�嶅彲鎭㈠琛ㄥ崟鏉′欢锛�</span>
+        <el-button type="text" size="mini" @click="clearCardFilter">娓呴櫎</el-button>
+      </div>
       <div class="selected-info">
         宸查�変腑
         <span style="color: #409eff; font-weight: bold">{{
@@ -575,6 +593,29 @@
           prop="phone"
         />
         <el-table-column
+          v-if="
+            orgname == '鏅畞鐣叉棌鑷不鍘夸汉姘戝尰闄�' ||
+            orgname == '涓芥按甯備腑鍖婚櫌'
+          "
+          label="鎷ㄥ彿鐘舵��"
+          width="120"
+          align="center"
+          key="isManuallyCalled"
+          prop="isManuallyCalled"
+        >
+          <template slot-scope="scope">
+            <el-tag
+              v-if="Number(scope.row.isManuallyCalled) > 0"
+              type="success"
+              :disable-transitions="false"
+              >鎷ㄩ�歿{ scope.row.isManuallyCalled }}娆�</el-tag
+            >
+            <el-tag v-else type="info" :disable-transitions="false"
+              >鏈嫧閫�</el-tag
+            >
+          </template>
+        </el-table-column>
+        <el-table-column
           label="韬唤璇佸彿鐮�"
           width="200"
           align="center"
@@ -597,8 +638,8 @@
         <el-table-column
           label="绉戝"
           align="center"
-          key="deptname"
-          prop="deptname"
+          key="leaveldeptname"
+          prop="leaveldeptname"
           width="120"
         >
         </el-table-column>
@@ -1007,7 +1048,7 @@
           <el-input
             style="width: 400px"
             disabled
-            v-model="zcform.deptname"
+            v-model="zcform.leaveldeptname"
           ></el-input>
         </el-form-item>
         <el-form-item label="鐥呭尯">
@@ -1244,6 +1285,8 @@
       ],
       lastScopeType: 3, // 鎮h�呰寖鍥翠笂娆¢�夋嫨鐨勪竴绾х被鍨嬶紙1=绉戝锛�2=鐥呭尯锛�3=鍏ㄩ儴锛�
       loading: false,
+      // 椤堕儴鍗$墖鐐瑰嚮甯︽潵鐨勪复鏃剁瓫閫夛紙鍙綔鐢ㄤ簬涓嬮潰鍒楄〃锛屼笉鍔ㄨ〃鍗曘�佷笉鏀瑰崱鐗囨暟瀛楋紱鐐广�屾悳绱€�嶆椂娓呯┖锛�
+      cardFilter: null,
       cardlist: [
         {
           name: "鎮h�呮湇鍔℃�婚噺",
@@ -1472,6 +1515,15 @@
     // 鐩戝惉璺敱鍙傛暟鍙樺寲
     "$route.query": {
       handler(newQuery, oldQuery) {
+        // 鍙充笅瑙掋�屽緟澶勭悊闅忚浠诲姟銆嶅崱鐗囧啀娆$偣鍑伙紙褰撳墠宸插湪鏈〉锛�
+        if (
+          newQuery?.month &&
+          newQuery?.fromPendingTask === "1" &&
+          this.taskQueryReady
+        ) {
+          this.applyPendingTaskQuery();
+          return;
+        }
         if (newQuery?.errtype !== oldQuery?.errtype) {
           console.log(22);
           this.loadData();
@@ -1500,7 +1552,12 @@
         value: dept.districtCode,
       };
     });
-    if (this.errtype == 1) {
+    // 鍏嶇櫥鐩磋揪锛氭牴鎹瀹�/鐥呭尯缂栫爜棰勫~鎮h�呰寖鍥�
+    this.applyFollowUpScope();
+    // 鍙充笅瑙掋�屽緟澶勭悊闅忚浠诲姟銆嶅崱鐗囪烦杞細鎸夊嚭闄㈠勾鏈� + 寰呴殢璁� + 鍑洪櫌婊� 7 澶╄繃婊�
+    if (this.applyPendingTaskQuery()) {
+      // 宸叉寜鍗$墖鏉′欢鏌ヨ锛屼笉鍐嶈蛋榛樿鍒嗘敮
+    } else if (this.errtype == 1) {
       this.toleadExport(2);
     } else if (this.errtype == 2) {
       // 寰呴殢璁�
@@ -1520,9 +1577,16 @@
     this.getConfigKey("sys.user.initPassword").then((response) => {
       this.initPassword = response.msg;
     });
+    // created 鍒濆鍖栧畬鎴愶紝涔嬪悗璺敱 query 鍙樺寲鎵嶆寜鍗$墖鏉′欢閲嶆柊鏌ヨ
+    this.taskQueryReady = true;
   },
   activated() {
+    // 浠庡埆鐨勬爣绛鹃〉鍒囧洖鏉ユ椂锛屼互琛ㄥ崟鏉′欢涓哄噯锛屼涪寮冨崱鐗囧甫鏉ョ殑涓�娆℃�х瓫閫�
+    this.cardFilter = null;
     this.errtype = this.$route.query.errtype;
+    if (this.applyPendingTaskQuery()) {
+      return;
+    }
     if (this.errtype == 1) {
       this.toleadExport(2);
     } else if (this.errtype == 2) {
@@ -1546,7 +1610,7 @@
     async getList(refresh) {
       // 榛樿鍏ㄩ儴
       this.applyDeptWardScope();
-      if (this.endOut == 0) {
+      if (this.endOut == 0 && !this.topqueryParams.endSendDateTime) {
         this.topqueryParams.endSendDateTime = this.formatDateToYYYYMMDDHHMMSS(
           this.getEndOfDay()
         );
@@ -1577,7 +1641,9 @@
       }
 
       try {
-        const response = await getTaskservelist(this.topqueryParams);
+        // 椤堕儴鍗$墖鐐瑰嚮鐨勪复鏃舵潯浠跺彧鍔犲湪鏈璇锋眰涓婏紝涓嶅啓鍥炶〃鍗�
+        const query = this.applyCardFilter({ ...this.topqueryParams });
+        const response = await getTaskservelist(query);
 
         // 鉁� 绗竴姝ワ細鍏堥攣瀹氭仮澶嶇姸鎬�
         this.isRestoring = true;
@@ -1594,15 +1660,10 @@
 
         // 鉁� 绗洓姝ワ細澶勭悊鍏朵粬鏁版嵁
         if (refresh) {
-          this.cardlist[0].value =
-            Number(response.rows[0].wxsf) + Number(response.rows[0].xsf) || 0;
-          this.cardlist[1].value = response.rows[0].wxsf || 0;
-          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;
+          // 椤堕儴鍗$墖鐨勬暟瀛椾笉璺熴�岄殢璁跨姸鎬�/寮傚父銆嶈蛋锛氬崟鐙煡涓�娆″幓鎺夌姸鎬佹潯浠剁殑缁熻锛�
+          // 鍚﹀垯绛涗簡銆屽緟闅忚銆嶅悗銆屽凡瀹屾垚銆嶆案杩滄槸 0锛岀湅鐫�鍍忕畻閿欎簡
+          this.refreshCardCounts(query);
         }
 
         // 鉁� 绗簲姝ワ細澶勭悊 preachform 绛夊叾浠栨暟鎹�
@@ -1714,8 +1775,10 @@
     onthatday() {
       this.resetQuerykj();
 
-      this.topqueryParams.startSendDateTime = this.getCurrentDate();
-      this.topqueryParams.endSendDateTime = this.getCurrentDate();
+      this.topqueryParams.sendstateView = 1; // 寰呴殢璁�
+      this.topqueryParams.sendstate = null;
+      this.topqueryParams.startSendDateTime = null;
+      this.topqueryParams.endSendDateTime = this.getCurrentDate(); // 寮�濮嬮殢璁挎棩鏈� <= 浠婂ぉ
       this.getList(1);
     },
     getCurrentDate() {
@@ -1724,10 +1787,12 @@
     },
 
     buidegetTasklist(type) {
-      if (type) {
-        this.resetQuerykj();
-      }
-      this.applyDeptWardScope();
+      // 鐢ㄦ埛鏉冮檺涓嬫墍鏈夊緟闅忚浠诲姟锛氫紶閫掑叏閮ㄧ瀹ゅ拰鐥呭尯
+      this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
+        (obj) => obj.deptCode
+      );
+      this.topqueryParams.leavehospitaldistrictcodes =
+        store.getters.belongWards.map((obj) => obj.districtCode);
       // 鎺ュ彈寮傚父璺宠浆
       if (this.errtype) {
         this.topqueryParams.leavehospitaldistrictcodes.push(
@@ -1739,7 +1804,7 @@
         pageSize: 10,
         leavehospitaldistrictcodes:
           this.topqueryParams.leavehospitaldistrictcodes,
-        sendstates: [2, 3],
+        sendstateView: 1,
         leaveldeptcodes: this.topqueryParams.leaveldeptcodes,
       };
       buidegetTasklist(obj).then((response) => {
@@ -1835,7 +1900,10 @@
     },
     /** 鎼滅储鎸夐挳鎿嶄綔 */
     handleQuery(refresh) {
+      // 鐐广�屾悳绱€�嶆椂浠ヨ〃鍗曟潯浠朵负鍑嗭紝娓呮帀鍗$墖鐐瑰嚮甯︽潵鐨勪复鏃舵潯浠�
+      this.cardFilter = null;
       this.applyDeptWardScope();
+      this.clearAllSelection();
       this.topqueryParams.pageNum = 1;
       // 鍒ゆ柇鏄笉鏄伐浣滃彴蹇嵎鏌ヨ
       if (this.errtype != 2) {
@@ -1845,6 +1913,71 @@
         this.topqueryParams.endSendDateTime = this.dateRangefs[1];
       }
       this.getList(refresh);
+    },
+    // 鍏嶇櫥鐩磋揪锛氭牴鎹矾鐢变腑鐨勭瀹�/鐥呭尯缂栫爜棰勫~鎮h�呰寖鍥�
+    applyFollowUpScope() {
+      const deptCode = this.$route.query.followUpDeptCode;
+      const wardCode = this.$route.query.followUpWardCode;
+      if (!deptCode && !wardCode) return;
+      const scope = [];
+      if (deptCode) scope.push([1, deptCode]);
+      if (wardCode) scope.push([2, wardCode]);
+      this.topqueryParams.scopetype = scope;
+      this.lastScopeType = deptCode ? 1 : 2;
+    },
+    /**
+     * 鍙充笅瑙掋�屽緟澶勭悊闅忚浠诲姟銆嶅崱鐗囩偣鍑绘暟瀛楄烦杞繃鏉ワ細
+     * 鎸夊嚭闄㈠勾鏈� + 寰呴殢璁匡紙sendstate 1/2/3/5/7锛�+ 鍑洪櫌婊� 7 澶� 杩囨护锛屽彛寰勪笌鍗$墖涓�鑷�
+     * @returns {boolean} 鏄惁宸叉寜鍗$墖鏉′欢鍙戣捣鏌ヨ
+     */
+    applyPendingTaskQuery() {
+      const query = this.$route.query || {};
+      if (!query.month || query.fromPendingTask !== "1") {
+        return false;
+      }
+      // 椤甸潰琚� keep-alive 澶嶇敤鏃朵細閲嶅瑙﹀彂 activated锛屽悓涓�娆$偣鍑诲彧澶勭悊涓�娆�
+      if (this.pendingTaskToken && this.pendingTaskToken === query._t) {
+        return false;
+      }
+      this.pendingTaskToken = query._t;
+
+      const month = String(query.month);
+      const serviceType = Number(query.serviceType) === 3 ? 3 : 2;
+      this.errtype = undefined;
+      const start = month + "-01";
+      let end = this.pendingTaskMonthEnd(month);
+      // 鏈堝垵 7 澶╁唴锛�"浠婂ぉ-7澶�" 浼氭棭浜庢湀鍒濓紝鍏滃簳鎴愭湀鍒濓紝閬垮厤鏃ユ湡鍖洪棿鍊掓寕
+      if (end < start) {
+        end = start;
+      }
+      this.dateRange = [start, end];
+      this.topqueryParams.serviceType = serviceType;
+      this.topqueryParams.sendstateView = 1;
+      this.topqueryParams.sendstate = null;
+      // 鍗$墖缁熻鐨勬槸鍏ㄩ儴寰呴殢璁夸换鍔★紙涓嶅尯鍒嗛杞�/澶嶈瘖锛夛紝鍒楄〃杩欓噷鍚屾鏀惧紑
+      this.topqueryParams.visitCount = null;
+      this.topqueryParams.pageNum = 1;
+      this.handleQuery(1);
+      return true;
+    },
+    /**
+     * 鍗$墖鍙e緞鐨勬湀浠界粨鏉熸棩锛�
+     * 褰撴湀鍙粺璁″嚭闄㈡弧 7 澶╃殑锛屾墍浠ュ彇銆屼粖澶� - 7 澶┿�嶏紱鍘嗗彶鏈堜唤鍙栧綋鏈堟渶鍚庝竴澶�
+     */
+    pendingTaskMonthEnd(month) {
+      const parts = String(month).split("-");
+      const year = Number(parts[0]);
+      const mon = Number(parts[1]);
+      const now = new Date();
+      let date;
+      if (year === now.getFullYear() && mon === now.getMonth() + 1) {
+        date = new Date(year, mon - 1, now.getDate() - 7);
+      } else {
+        date = new Date(year, mon, 0);
+      }
+      const mm = String(date.getMonth() + 1).padStart(2, "0");
+      const dd = String(date.getDate()).padStart(2, "0");
+      return date.getFullYear() + "-" + mm + "-" + dd;
     },
     // 鎮h�呰寖鍥村鐞嗭細浠庡閫夌骇鑱� scopetype 瑙f瀽绉戝/鐥呭尯
     applyDeptWardScope() {
@@ -2289,6 +2422,74 @@
       }
       this.handleQuery(1);
     },
+    // 椤堕儴缁熻鍗$墖鐐瑰嚮锛氭妸瀵瑰簲绛涢�夋潯浠朵笅甯﹀埌涓嬮潰鐨勫垪琛紙鏁板�间负 0 鐨勫崱鐗囧悓鏍峰彲鐐癸級
+    // 椤堕儴鍗$墖缁熻锛氬幓鎺夈�岄殢璁跨姸鎬� / 寮傚父銆嶆潯浠跺悗鍐嶇粺璁★紝
+    // 杩欐牱鍗$墖鏁板瓧鍙窡鏃ユ湡銆佺瀹�/鐥呭尯绛夋潯浠惰蛋锛屼笉浼氬洜涓虹瓫浜嗐�屽緟闅忚銆嶅氨鎶娿�屽凡瀹屾垚銆嶇畻鎴� 0
+    async refreshCardCounts(baseQuery) {
+      const query = {
+        ...(baseQuery || this.topqueryParams),
+        pageNum: 1,
+        pageSize: 1,
+        sendstate: null,
+        sendstateView: null,
+        sendstates: null,
+        excep: null,
+      };
+      try {
+        const res = await getTaskservelist(query);
+        const row = (res && res.rows && res.rows[0]) || {};
+        this.cardlist[0].value = Number(row.wxsf || 0) + Number(row.xsf || 0);
+        this.cardlist[1].value = Number(row.wxsf) || 0;
+        this.cardlist[2].value = Number(row.xsf) || 0;
+        this.cardlist[3].value = Number(row.dsf) || 0;
+        this.cardlist[4].value = Number(row.ywc) || 0;
+        this.ycvalue = Number(row.yc) || 0;
+        this.jgvalue = Number(row.jg) || 0;
+      } catch (e) {
+        console.warn("鍒锋柊椤堕儴鍗$墖缁熻澶辫触", e);
+      }
+    },
+    // 椤堕儴缁熻鍗$墖鐐瑰嚮锛氬彧缁欎笅闈㈢殑鍒楄〃鍔犱复鏃舵潯浠讹紝涓嶅姩涓婃柟琛ㄥ崟銆佷篃涓嶆敼鍗$墖鏁板瓧锛�
+    // 鍗$墖鏁板瓧鍙湪鐐广�屾悳绱€�嶆椂鎸夎〃鍗曟潯浠堕噸绠�
+    handleCardClick(item) {
+      this.cardFilter = item && item.name ? item.name : null;
+      this.topqueryParams.pageNum = 1;
+      // 浼� 0锛氬埛鏂板垪琛紝浣嗕笉鍥炲啓椤堕儴鍗$墖鏁板瓧
+      this.getList(0);
+    },
+    // 鎶婂崱鐗囩偣鍑荤殑鏉′欢鍙犲姞鍒版煡璇㈠弬鏁帮紙杩斿洖鏂板璞★紝涓嶄慨鏀硅〃鍗曟湰韬級
+    applyCardFilter(query) {
+      const name = this.cardFilter;
+      if (!name) return query;
+      // 鍗$墖鏁板瓧鏄�屼笉鍚殢璁跨姸鎬�/寮傚父銆嶇殑鎬婚噺锛屾墍浠ョ偣鍗$墖鏃朵篃鎶婅〃鍗曢噷鐨勭姸鎬佹潯浠跺幓鎺夛紝
+      // 鍙寜鍗$墖鑷繁鐨勬潯浠舵煡锛屽惁鍒欎細鍑虹幇銆屽崱鐗� 922銆佸垪琛� 3 鏉°��
+      query.sendstate = null;
+      query.sendstateView = null;
+      query.sendstates = null;
+      query.excep = null;
+
+      if (name === "鏃犻渶闅忚") {
+        query.sendstateView = 3;
+      } else if (name === "寰呴殢璁�") {
+        query.sendstateView = 1;
+      } else if (name === "宸插畬鎴�") {
+        query.sendstateView = 2;
+      } else if (name === "闇�闅忚") {
+        query.sendstates = [1, 2, 3, 5, 6, 7];
+      } else if (name === "寮傚父") {
+        query.excep = "1";
+      } else if (name === "璀﹀憡") {
+        query.excep = "2";
+      }
+      // 銆屾偅鑰呮湇鍔℃�婚噺銆�= 鍙幓鎺夌姸鎬佹潯浠讹紝涓嶅姞鍒殑
+      return query;
+    },
+    // 娓呴櫎鍗$墖绛涢�夛紝鍥炲埌琛ㄥ崟鏉′欢
+    clearCardFilter() {
+      this.cardFilter = null;
+      this.topqueryParams.pageNum = 1;
+      this.getList(0);
+    },
     /** 瀵煎嚭鎸夐挳鎿嶄綔 */
     handleExport() {
       const originalPageNum = this.topqueryParams.pageNum;
@@ -2309,14 +2510,41 @@
         this.getList();
       });
     },
-    // 寮傚父鍒楁覆鏌�
+    // 琛岄鑹叉覆鏌擄細钃濊壊(鏈埌闅忚鏃堕棿) / 绾㈣壊(寮傚父) / 榛勮壊(璀﹀憡)
     tableRowClassName({ row, rowIndex }) {
+      // 褰撳墠鏃堕棿灏忎簬搴旈殢璁挎椂闂翠笖浠诲姟鐘舵�佷负寰呴殢璁� 鈫� 鏁磋钃濊壊锛堝崡鍗庡ぇ瀛﹂檮灞炵涓�鍖婚櫌涓嶇敓鏁堬級
+      if (
+        this.orgname == "鍗楀崕澶у闄勫睘绗竴鍖婚櫌" &&
+        row.sendstate == 2 &&
+        this.isBeforeVisitTime(row.visitTime)
+      ) {
+        return "blue-row";
+      }
       if (row.excep == 1) {
         return "warning-row";
       } else if (row.excep == 2) {
         return "remind-row";
       }
       return "";
+    },
+    // 鍒ゆ柇褰撳墠鏃堕棿鏄惁鏃╀簬搴旈殢璁挎椂闂达紙鎸夆�滃ぉ鈥濇瘮杈冿級
+    isBeforeVisitTime(visitTime) {
+      if (!visitTime) return false;
+      let date;
+      if (typeof visitTime === "number") {
+        date = new Date(visitTime);
+      } else {
+        date = new Date(String(visitTime).replace(/-/g, "/"));
+      }
+      if (isNaN(date.getTime())) return false;
+      const now = new Date();
+      const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
+      const visitDay = new Date(
+        date.getFullYear(),
+        date.getMonth(),
+        date.getDate()
+      );
+      return today.getTime() < visitDay.getTime();
     },
     restoreSelection() {
       if (!this.$refs.userform) {
@@ -2447,7 +2675,7 @@
         leavelDeptName: "",
         leavehospitaldistrictcode: "",
         leavehospitaldistrictname: "",
-        currentDeptName: row.deptname || row.deptName || "",
+        currentDeptName: row.leaveldeptname || row.deptName || "",
         currentWardName:
           row.leavehospitaldistrictname || row.leavehospitaldistrictName || "",
       };
@@ -2549,10 +2777,44 @@
 ::v-deep.el-table .remind-row {
   background: #fcf5aa;
 }
+::v-deep.el-table .blue-row {
+  background: #c6e2ff;
+}
 
 .documentf {
   display: flex;
   justify-content: flex-end;
+}
+
+.color-legend {
+  float: right;
+  display: flex;
+  align-items: center;
+  height: 40px;
+  gap: 16px;
+  margin-right: 5px;
+}
+.legend-item {
+  display: inline-flex;
+  align-items: center;
+  font-size: 16px;
+  color: #666;
+}
+.legend-block {
+  display: inline-block;
+  width: 14px;
+  height: 14px;
+  border-radius: 3px;
+  margin-right: 6px;
+}
+.legend-blue {
+  background: #9cc9fa;
+}
+.legend-red {
+  background: #f1aaaa;
+}
+.legend-yellow {
+  background: #faf18d;
 }
 
 .download {
@@ -2769,6 +3031,20 @@
   font-size: 14px;
   color: #666;
 }
+.card-filter-tip {
+  margin: 2px 0 4px;
+  padding: 6px 10px;
+  font-size: 13px;
+  color: #303133;
+  background: #f0f7ff;
+  border: 1px solid #d6e9ff;
+  border-radius: 4px;
+}
+.card-filter-tip .tip-desc {
+  margin: 0 6px;
+  font-size: 12px;
+  color: #909399;
+}
 /* ================= 娓呮柊楂樼骇绠�绾﹂ ================= */
 .app-container {
   background: #f5f7fb;

--
Gitblit v1.9.3