From 5f8bf5e4c767ffcf47ced666883d0ec6a820c66a Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 02 十一月 2026 09:56:37 +0800
Subject: [PATCH] Merge branch 'subtask' of http://116.62.18.175:6699/r/~yxh/smartor-web into subtask

---
 src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue |  250 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 168 insertions(+), 82 deletions(-)

diff --git a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
index e5eb304..c299b30 100644
--- a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
+++ b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
@@ -12,7 +12,7 @@
         <el-form-item label="婊℃剰搴︾被鍨�" prop="satisfactionScope">
           <el-select
             v-model="satisfactionScope"
-            placeholder="榛樿绂婚櫌"
+            placeholder="榛樿鍦ㄩ櫌"
             clearable
             style="width: 150px"
             @change="handleSatisfactionScopeChange"
@@ -150,33 +150,67 @@
         @selection-change="handleSelectionChange"
         :row-key="getRowKey"
       >
-        <!-- 鐥呭尯鍒楋細浣忛櫌婊℃剰搴︾粺璁″湪闄㈢梾鍖猴紝鍏朵綑缁熻鍑洪櫌鐥呭尯 -->
+        <!-- 鐥呭尯缁熻锛氬湪闄㈢梾鍖� + 绂婚櫌鐥呭尯 -->
         <el-table-column
           v-if="queryParams.statisticaltype == 1"
-          :label="wardColumnLabel"
+          label="鍦ㄩ櫌鐥呭尯"
+          align="center"
+          sortable
+          key="hospitaldistrictname"
+          prop="hospitaldistrictname"
+          :show-overflow-tooltip="true"
+          :sort-method="sortHospitalWard"
+          min-width="120"
+        >
+          <template slot-scope="scope">
+            {{ scope.row.hospitaldistrictname || "-" }}
+          </template>
+        </el-table-column>
+
+        <el-table-column
+          v-if="queryParams.statisticaltype == 1"
+          label="绂婚櫌鐥呭尯"
           align="center"
           sortable
           key="leavehospitaldistrictname"
           prop="leavehospitaldistrictname"
           :show-overflow-tooltip="true"
-          :sort-method="sortChineseNumber"
+          :sort-method="sortLeaveWard"
           min-width="120"
         >
           <template slot-scope="scope">
-            {{ getWardName(scope.row) || "-" }}
+            {{ scope.row.leavehospitaldistrictname || "-" }}
           </template>
         </el-table-column>
 
-        <!-- 绉戝鍒� -->
+        <!-- 绉戝缁熻锛氬湪闄㈢瀹� + 绂婚櫌绉戝 -->
         <el-table-column
           v-if="queryParams.statisticaltype == 2"
-          label="绉戝"
+          label="鍦ㄩ櫌绉戝"
+          align="center"
+          key="hospitaldeptname"
+          prop="hospitaldeptname"
+          :show-overflow-tooltip="true"
+          min-width="120"
+        >
+          <template slot-scope="scope">
+            {{ scope.row.hospitaldeptname || "-" }}
+          </template>
+        </el-table-column>
+
+        <el-table-column
+          v-if="queryParams.statisticaltype == 2"
+          label="绂婚櫌绉戝"
           align="center"
           key="deptname"
           prop="deptname"
           :show-overflow-tooltip="true"
           min-width="120"
-        />
+        >
+          <template slot-scope="scope">
+            {{ scope.row.deptname || "-" }}
+          </template>
+        </el-table-column>
 
         <el-table-column
           label="鍑洪櫌浜烘"
@@ -367,6 +401,7 @@
   data() {
     return {
       // 婊℃剰搴︾被鍨嬶細leave=绂婚櫌婊℃剰搴︼紙鎸夊嚭闄㈢梾鍖虹粺璁★級锛宧ospital=鍦ㄩ櫌婊℃剰搴︼紙鎸夊湪闄㈢梾鍖虹粺璁★級
+      // 榛樿绂婚櫌婊℃剰搴�
       satisfactionScope: "leave",
 
       // 鏌ヨ鍙傛暟
@@ -374,7 +409,8 @@
         statisticaltype: 1,
         leavehospitaldistrictcodes: ["all"],
         deptcodes: [],
-        serviceType: [2],
+        // 榛樿鏈嶅姟绫诲瀷锛�6=浣忛櫌婊℃剰搴︼紙鍑哄叆闄㈡弧鎰忓害锛�
+        serviceType: [6],
         dateRange: [],
         pageNum: 1,
         pageSize: 20,
@@ -396,7 +432,7 @@
       options: [
         {
           value: 6,
-          label: "浣忛櫌婊℃剰搴�",
+          label: "鍑哄叆闄㈡弧鎰忓害",
           raw: {
             cssClass: "",
             listClass: "",
@@ -480,15 +516,11 @@
   },
 
   computed: {
-    // 鏄惁鎸夈�屽湪闄㈡弧鎰忓害銆嶅彛寰勭粺璁★細鍦ㄩ櫌鎮h�呮寜鍦ㄩ櫌鐥呭尯(hospitaldistrictcodes)缁熻锛�
-    // 绂婚櫌婊℃剰搴︿粛鎸夊嚭闄㈢梾鍖�(leavehospitaldistrictcodes)缁熻
+    // 鏄惁鎸夈�屽湪闄㈡弧鎰忓害銆嶅彛寰勭粺璁★細鍦ㄩ櫌鐢� hospitaldistrictcodes / hospitaldeptcodes锛�
+    // 绂婚櫌鐢� leavehospitaldistrictcodes / leaveldeptcodes
+    // 榛樿鍦ㄩ櫌锛屾墍浠ユ竻绌轰笅鎷夋椂浠嶆寜鍦ㄩ櫌鍙e緞澶勭悊
     isInHospitalSatisfaction() {
-      return this.satisfactionScope === "hospital";
-    },
-
-    // 鐥呭尯鍒楁爣棰�
-    wardColumnLabel() {
-      return this.isInHospitalSatisfaction ? "鍦ㄩ櫌鐥呭尯" : "鍑洪櫌鐥呭尯";
+      return this.satisfactionScope !== "leave";
     },
   },
 
@@ -507,8 +539,11 @@
 
     // 鑾峰彇绉戝鏍�
     getDeptTree() {
-      // 鑾峰彇鏈嶅姟绫诲瀷
-      this.options = this.$store.getters.tasktypes || [];
+      // 鑾峰彇鏈嶅姟绫诲瀷锛堝瓧鍏搁噷鐨勩�屼綇闄㈡弧鎰忓害銆嶅湪鏈〉鏄剧ず涓恒�屽嚭鍏ラ櫌婊℃剰搴︺�嶏級
+      const labelFix = { 浣忛櫌婊℃剰搴�: "鍑哄叆闄㈡弧鎰忓害" };
+      this.options = (this.$store.getters.tasktypes || []).map((o) =>
+        labelFix[o.label] ? { ...o, label: labelFix[o.label] } : o
+      );
 
       // 鑾峰彇绉戝鍒楄〃
       this.flatArraydept = (this.$store.getters.belongDepts || []).map(
@@ -554,7 +589,8 @@
           params.endTime = this.queryParams.dateRange[1];
         }
 
-        // 澶勭悊鐥呭尯/绉戝閫夋嫨
+        // 澶勭悊鐥呭尯/绉戝閫夋嫨锛氬彧淇濈暀褰撳墠缁熻绫诲瀷 + 褰撳墠婊℃剰搴︾被鍨嬪搴旂殑瀛楁锛�
+        // 閬垮厤鍦ㄩ櫌/绂婚櫌涓ゅ鏉′欢鍚屾椂鎷艰繘 SQL
         if (params.statisticaltype == 1) {
           // 鐥呭尯缁熻
           let wardCodes = params.leavehospitaldistrictcodes || [];
@@ -564,9 +600,11 @@
               (ward) => ward.districtCode
             );
           }
-          // 浣忛櫌婊℃剰搴﹂拡瀵瑰湪闄㈡偅鑰咃紝鎸夊湪闄㈢梾鍖�(hospitaldistrictcodes)缁熻锛�
-          // 鍑洪櫌闅忚绛夊叾浠栨湇鍔$被鍨嬩粛鎸夊嚭闄㈢梾鍖�(leavehospitaldistrictcodes)缁熻
           delete params.leavehospitaldistrictcodes;
+          delete params.hospitaldistrictcodes;
+          delete params.deptcodes;
+          delete params.leaveldeptcodes;
+          delete params.hospitaldeptcodes;
           if (this.isInHospitalSatisfaction) {
             params.hospitaldistrictcodes = wardCodes;
           } else {
@@ -574,20 +612,33 @@
           }
         } else if (params.statisticaltype == 2) {
           // 绉戝缁熻
-          if (params.deptcodes.includes("all")) {
+          let deptCodes = params.deptcodes || [];
+          if (deptCodes.includes("all")) {
             // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯绉婚櫎"all"鍊�
-            params.deptcodes = params.deptcodes.filter(
-              (item) => item !== "all"
-            );
+            deptCodes = deptCodes.filter((item) => item !== "all");
             // 濡傛灉闇�瑕佷紶鎵�鏈夌瀹や唬鐮侊紝鍙互浠巗tore涓幏鍙�
-            params.deptcodes = (this.$store.getters.belongDepts || []).map(
+            deptCodes = (this.$store.getters.belongDepts || []).map(
               (dept) => dept.deptCode
             );
+          }
+          delete params.deptcodes;
+          delete params.leaveldeptcodes;
+          delete params.hospitaldeptcodes;
+          delete params.leavehospitaldistrictcodes;
+          delete params.hospitaldistrictcodes;
+          if (this.isInHospitalSatisfaction) {
+            params.hospitaldeptcodes = deptCodes;
+          } else {
+            params.leaveldeptcodes = deptCodes;
           }
         }
 
         const response = await getSfStatisticsJoy(params);
-        this.userList = this.customSort(response.data) || [];
+        // 绉戝缁熻鎸夋帴鍙h繑鍥為『搴忥紝鐥呭尯缁熻淇濇寔鍘熸湁鐨勪腑鏂囧簭鍙锋帓搴�
+        this.userList =
+          this.queryParams.statisticaltype == 1
+            ? this.customSort(response.data) || []
+            : response.data || [];
         this.total = response.total || 0;
       } catch (error) {
         console.error("鑾峰彇缁熻鍒楄〃澶辫触:", error);
@@ -597,9 +648,22 @@
       }
     },
     sortChineseNumber(aRow, bRow) {
-      const a = this.getWardName(aRow);
-      const b = this.getWardName(bRow);
-
+      return this.compareWardNames(this.getWardName(aRow), this.getWardName(bRow));
+    },
+    sortHospitalWard(aRow, bRow) {
+      return this.compareWardNames(
+        aRow && aRow.hospitaldistrictname,
+        bRow && bRow.hospitaldistrictname
+      );
+    },
+    sortLeaveWard(aRow, bRow) {
+      return this.compareWardNames(
+        aRow && aRow.leavehospitaldistrictname,
+        bRow && bRow.leavehospitaldistrictname
+      );
+    },
+    // 姣旇緝涓や釜鐥呭尯鍚嶇О鐨勪腑鏂囧簭鍙凤紱鏃犲簭鍙锋椂鎸夊瓧绗︿覆姣旇緝
+    compareWardNames(a, b) {
       // 涓枃鏁板瓧鍒伴樋鎷変集鏁板瓧鐨勬槧灏勶紙鎵╁睍鍒�45锛�
       const chineseNumMap = {
         涓�: 1,
@@ -793,13 +857,14 @@
       this.getList();
     },
 
-    // 閲嶇疆鏌ヨ
+    // 閲嶇疆鏌ヨ锛堟仮澶嶉粯璁わ細绂婚櫌婊℃剰搴� + 鏈嶅姟绫诲瀷 6锛�
     resetQuery() {
+      this.satisfactionScope = "leave";
       this.queryParams = {
         statisticaltype: 1,
         leavehospitaldistrictcodes: [],
         deptcodes: [],
-        serviceType: [2],
+        serviceType: [6],
         dateRange: [],
         pageNum: 1,
         pageSize: 20,
@@ -827,17 +892,19 @@
       this.multiple = !selection.length;
     },
 
-    // 鑾峰彇琛宬ey
+    // 鑾峰彇琛宬ey锛堟寜褰撳墠缁熻绫诲瀷鍙栧搴旂淮搴︾紪鐮侊級
     getRowKey(row) {
-      return row.statisticaltype === 1
+      return this.queryParams.statisticaltype == 1
         ? row.hospitaldistrictcode || row.leavehospitaldistrictcode
-        : row.deptcode;
+        : row.hospitaldeptcode || row.deptcode;
     },
 
-    // 鐥呭尯鍚嶇О锛氫綇闄㈡弧鎰忓害鎺ュ彛杩斿洖鍦ㄩ櫌鐥呭尯瀛楁锛屽叾浣欒繑鍥炲嚭闄㈢梾鍖哄瓧娈�
+    // 褰撳墠婊℃剰搴︾被鍨嬪搴旂殑鐥呭尯鍚嶇О锛堢敤浜庢帓搴�/瀵煎嚭/璇︽儏鏍囬锛�
     getWardName(row) {
       if (!row) return "";
-      return row.hospitaldistrictname || row.leavehospitaldistrictname || "";
+      return this.isInHospitalSatisfaction
+        ? row.hospitaldistrictname || ""
+        : row.leavehospitaldistrictname || "";
     },
 
     // 鏍煎紡鍖栫櫨鍒嗘瘮
@@ -874,22 +941,33 @@
           params.endTime = this.queryParams.dateRange[1];
         }
 
+        // 璇︽儏鍙寜褰撳墠鍒嗙粍缁村害杩囨护锛屾竻鎺夊叾浣欑淮搴︼紝閬垮厤鍦ㄩ櫌/绂婚櫌鏉′欢浜掔浉骞叉壈
+        delete params.deptcodes;
+        delete params.leaveldeptcodes;
+        delete params.hospitaldeptcodes;
+        delete params.leavehospitaldistrictcodes;
+        delete params.hospitaldistrictcodes;
+
         if (this.queryParams.statisticaltype == 1) {
-          this.topicvalue.name = this.getWardName(row);
-          // 浣忛櫌婊℃剰搴︽寜鍦ㄩ櫌鐥呭尯缁熻锛屽叾浣欐寜鍑洪櫌鐥呭尯缁熻
           if (this.isInHospitalSatisfaction) {
-            delete params.leavehospitaldistrictcodes;
-            params.hospitaldistrictcodes = [
-              row.hospitaldistrictcode || row.leavehospitaldistrictcode,
-            ];
+            this.topicvalue.name = row.hospitaldistrictname || "-";
+            params.hospitaldistrictcodes = [row.hospitaldistrictcode].filter(
+              Boolean
+            );
           } else {
+            this.topicvalue.name = row.leavehospitaldistrictname || "-";
             params.leavehospitaldistrictcodes = [
               row.leavehospitaldistrictcode,
-            ];
+            ].filter(Boolean);
           }
         } else {
-          this.topicvalue.name = row.deptname;
-          params.deptcodes = [row.deptcode];
+          if (this.isInHospitalSatisfaction) {
+            this.topicvalue.name = row.hospitaldeptname || "-";
+            params.hospitaldeptcodes = [row.hospitaldeptcode].filter(Boolean);
+          } else {
+            this.topicvalue.name = row.deptname || "-";
+            params.leaveldeptcodes = [row.deptcode].filter(Boolean);
+          }
         }
 
         const response = await getSfStatisticsJoyInfo(params);
@@ -1012,25 +1090,29 @@
           },
         };
 
-        // 娣诲姞鎬绘爣棰�
-        worksheet.mergeCells(1, 1, 1, 10);
-        const titleCell = worksheet.getCell(1, 1);
-        titleCell.value = `婊℃剰搴﹂殢璁跨粺璁¤〃锛�${sheetNameSuffix}锛塦;
-        titleCell.style = titleStyle;
-        worksheet.getRow(1).height = 35;
-
-        // 娣诲姞琛ㄥご
+        // 琛ㄥご鎸夐〉闈㈠垪鍔ㄦ�佺敓鎴愶細绉戝/鐥呭尯缁熻鍒椾笉鍚岋紝銆屽強鏃剁巼銆嶅彧鏈夋櫙瀹侀櫌鍖洪〉闈㈡墠鏄剧ず
+        const isWardStatistics = this.queryParams.statisticaltype == 1;
+        const showTimelyRate = this.orgname === "鏅畞鐣叉棌鑷不鍘夸汉姘戝尰闄�";
         const headers = [
-          this.queryParams.statisticaltype == 1 ? this.wardColumnLabel : "绉戝",
+          isWardStatistics ? "鍦ㄩ櫌鐥呭尯" : "鍦ㄩ櫌绉戝",
+          isWardStatistics ? "绂婚櫌鐥呭尯" : "绂婚櫌绉戝",
           "鍑洪櫌浜烘",
           "鏃犻渶闅忚浜烘",
           "搴旈殢璁夸汉娆�",
           "闅忚鐜�",
-          "鍙婃椂鐜�",
-          "婊℃剰搴﹂鐩�婚噺",
-          "婊℃剰搴﹀~鎶ラ噺",
-          "瀹屾垚姣旂巼",
         ];
+        if (showTimelyRate) {
+          headers.push("鍙婃椂鐜�");
+        }
+        headers.push("婊℃剰搴﹂鐩�婚噺", "婊℃剰搴﹀~鎶ラ噺", "瀹屾垚姣旂巼");
+        const colCount = headers.length;
+
+        // 娣诲姞鎬绘爣棰�
+        worksheet.mergeCells(1, 1, 1, colCount);
+        const titleCell = worksheet.getCell(1, 1);
+        titleCell.value = `婊℃剰搴﹂殢璁跨粺璁¤〃锛�${sheetNameSuffix}锛塦;
+        titleCell.style = titleStyle;
+        worksheet.getRow(1).height = 35;
 
         const headerRow = worksheet.addRow(headers);
         headerRow.eachCell((cell) => {
@@ -1038,21 +1120,33 @@
         });
         headerRow.height = 25;
 
-        // 娣诲姞鏁版嵁琛�
+        // 娣诲姞鏁版嵁琛岋紙绌哄�肩粺涓�鏄剧ず鈥�-鈥濓紝涓庨〉闈繚鎸佷竴鑷达級
+        const dash = (v, formatter) => {
+          if (v === null || v === undefined || v === "") return "-";
+          return formatter ? formatter(v) : v;
+        };
         this.userList.forEach((item) => {
-          const dataRow = worksheet.addRow([
-            this.queryParams.statisticaltype == 1
-              ? this.getWardName(item)
-              : item.deptname,
+          const rowData = [
+            isWardStatistics
+              ? item.hospitaldistrictname || "-"
+              : item.hospitaldeptname || "-",
+            isWardStatistics
+              ? item.leavehospitaldistrictname || "-"
+              : item.deptname || "-",
             item.dischargeCount || 0,
             item.nonFollowUp || 0,
             item.followUpNeeded || 0,
-            item.followUpRate || "0%",
-            item.rate ? this.formatPercent(item.rate) : "0%",
+            dash(item.followUpRate),
+          ];
+          if (showTimelyRate) {
+            rowData.push(dash(item.rate, (v) => this.formatPercent(v)));
+          }
+          rowData.push(
             item.joyAllCount || 0,
             item.joyCount || 0,
-            item.joyTotal ? this.formatPercent(item.joyTotal) : "0%",
-          ]);
+            dash(item.joyTotal, (v) => this.formatPercent(v))
+          );
+          const dataRow = worksheet.addRow(rowData);
 
           dataRow.eachCell((cell) => {
             cell.style = cellStyle;
@@ -1060,18 +1154,10 @@
           dataRow.height = 22;
         });
 
-        // 璁剧疆鍒楀
-        worksheet.columns = [
-          { width: 20 },
-          { width: 12 },
-          { width: 12 },
-          { width: 12 },
-          { width: 12 },
-          { width: 12 },
-          { width: 15 },
-          { width: 15 },
-          { width: 12 },
-        ];
+        // 璁剧疆鍒楀锛堣窡鍒楁暟涓�鑷达級
+        worksheet.columns = headers.map((h, i) => ({
+          width: i < 2 ? 20 : h.length > 6 ? 15 : 12,
+        }));
 
         // 鐢熸垚骞朵笅杞芥枃浠�
         const buffer = await workbook.xlsx.writeBuffer();

--
Gitblit v1.9.3