From f12b3e4c7c8d55217cc1d21f814a9a3d5fc57251 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 03 十一月 2026 16:02:21 +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 |  491 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 436 insertions(+), 55 deletions(-)

diff --git a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
index 754e244..d8687d5 100644
--- a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
+++ b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
@@ -389,6 +389,7 @@
 } from "@/api/system/user";
 import ExcelJS from "exceljs";
 import { saveAs } from "file-saver";
+import { getTaskservelist } from "@/api/AiCentre/SingleTask";
 import SeedetailsDialog from "./components/SeedetailsDialog.vue";
 import TopicDialog from "./components/TopicDialog.vue";
 
@@ -398,11 +399,18 @@
     SeedetailsDialog,
     TopicDialog,
   },
+  props: {
+    // 鏄惁鍦ㄩ《閮ㄧ敓鎴愭偅鑰呰〃鍗� / 闂璇︽儏鍒嗘瀽 tab锛堜粎婊℃剰搴︾粺璁′富椤靛紑鍚級
+    showAnalysisTabs: {
+      type: Boolean,
+      default: false,
+    },
+  },
   data() {
     return {
       // 婊℃剰搴︾被鍨嬶細leave=绂婚櫌婊℃剰搴︼紙鎸夊嚭闄㈢梾鍖虹粺璁★級锛宧ospital=鍦ㄩ櫌婊℃剰搴︼紙鎸夊湪闄㈢梾鍖虹粺璁★級
-      // 榛樿鍦ㄩ櫌婊℃剰搴�
-      satisfactionScope: "hospital",
+      // 榛樿绂婚櫌婊℃剰搴�
+      satisfactionScope: "leave",
 
       // 鏌ヨ鍙傛暟
       queryParams: {
@@ -432,7 +440,7 @@
       options: [
         {
           value: 6,
-          label: "浣忛櫌婊℃剰搴�",
+          label: "鍑哄叆闄㈡弧鎰忓害",
           raw: {
             cssClass: "",
             listClass: "",
@@ -458,6 +466,10 @@
       // 鍔犺浇鐘舵��
       loading: false,
       orgname: "",
+      // 宸插畬鎴愭槑缁嗚姹傚簭鍙凤紝閬垮厤蹇�熷垏鎹㈢瓫閫夋椂鏃ц姹傝鐩栨柊缁撴灉
+      completedRequestSeq: 0,
+      // 闂璇︽儏璇锋眰搴忓彿
+      questionRequestSeq: 0,
 
       // 閫変腑鐨勮
       ids: [],
@@ -522,12 +534,21 @@
     isInHospitalSatisfaction() {
       return this.satisfactionScope !== "leave";
     },
+    // patItem 鎺ュ彛鐨� serviceType 鍙帴鏀跺崟涓�硷紝澶氶�夋椂鍙栫涓�涓�
+    currentServiceType() {
+      const value = this.queryParams.serviceType;
+      const first = Array.isArray(value) ? value[0] : value;
+      return first || 6;
+    },
   },
 
   created() {
     this.orgname = localStorage.getItem("orgname");
 
     this.initData();
+    // 椤堕儴鎮h�呰〃鍗� / 闂璇︽儏鍒嗘瀽 tab锛氶粯璁ゆ寜褰撳墠缁熻鍙e緞鍔犺浇涓�娆�
+    this.maybeRefreshCompletedGroups();
+    this.maybeRefreshQuestionDetails();
   },
 
   methods: {
@@ -539,8 +560,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(
@@ -592,41 +616,41 @@
           // 鐥呭尯缁熻
           let wardCodes = params.leavehospitaldistrictcodes || [];
           if (wardCodes.includes("all")) {
-            // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯浣跨敤褰撳墠鐢ㄦ埛鎵�灞炵殑鍏ㄩ儴鐥呭尯
-            wardCodes = (this.$store.getters.belongWards || []).map(
-              (ward) => ward.districtCode
-            );
+            // 閫夋嫨"鍏ㄩ儴"鏃朵笉鍔犵梾鍖洪檺鍒讹紝鏌ュ叏閮ㄧ梾鍖�
+            wardCodes = [];
           }
           delete params.leavehospitaldistrictcodes;
           delete params.hospitaldistrictcodes;
           delete params.deptcodes;
           delete params.leaveldeptcodes;
           delete params.hospitaldeptcodes;
-          if (this.isInHospitalSatisfaction) {
-            params.hospitaldistrictcodes = wardCodes;
-          } else {
-            params.leavehospitaldistrictcodes = wardCodes;
+          if (wardCodes.length) {
+            if (this.isInHospitalSatisfaction) {
+              params.hospitaldistrictcodes = wardCodes;
+            } else {
+              params.leavehospitaldistrictcodes = wardCodes;
+            }
           }
         } else if (params.statisticaltype == 2) {
           // 绉戝缁熻
           let deptCodes = params.deptcodes || [];
           if (deptCodes.includes("all")) {
-            // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯绉婚櫎"all"鍊�
+            // 閫夋嫨"鍏ㄩ儴"鏃朵笉鍔犵瀹ら檺鍒讹紝鏌ュ叏閮ㄧ瀹�
+            deptCodes = [];
+          } else {
             deptCodes = deptCodes.filter((item) => item !== "all");
-            // 濡傛灉闇�瑕佷紶鎵�鏈夌瀹や唬鐮侊紝鍙互浠巗tore涓幏鍙�
-            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;
+          if (deptCodes.length) {
+            if (this.isInHospitalSatisfaction) {
+              params.hospitaldeptcodes = deptCodes;
+            } else {
+              params.leaveldeptcodes = deptCodes;
+            }
           }
         }
 
@@ -840,23 +864,376 @@
       }
       this.queryParams.pageNum = 1;
       this.getList();
+      this.maybeRefreshCompletedGroups();
+      this.maybeRefreshQuestionDetails();
     },
 
     // 澶勭悊鏌ヨ
     handleQuery() {
       this.queryParams.pageNum = 1;
       this.getList();
+      this.maybeRefreshCompletedGroups();
+      this.maybeRefreshQuestionDetails();
     },
 
     // 鍒囨崲婊℃剰搴︾被鍨嬶紙绂婚櫌/鍦ㄩ櫌锛夊悗閲嶆柊鏌ヨ
     handleSatisfactionScopeChange() {
       this.queryParams.pageNum = 1;
       this.getList();
+      this.maybeRefreshCompletedGroups();
+      this.maybeRefreshQuestionDetails();
     },
 
-    // 閲嶇疆鏌ヨ锛堟仮澶嶉粯璁わ細鍦ㄩ櫌婊℃剰搴� + 鏈嶅姟绫诲瀷 6锛�
+    /**
+     * 椤堕儴銆屽凡瀹屾垚鎮h�呮槑缁嗐�峵ab 鏁版嵁
+     * 缁村害娌跨敤涓嬫柟銆岀粺璁$被鍨嬨�嶏細鐥呭尯缁熻 -> 鎸夌梾鍖哄垎缁勶紱绉戝缁熻 -> 鎸夌瀹ゅ垎缁�
+     * 鏃堕棿娌跨敤涓嬫柟銆岄殢璁挎椂闂淬�嶏紝鐘舵�佸浐瀹氫负宸插畬鎴�
+     */
+    maybeRefreshCompletedGroups() {
+      if (this.showAnalysisTabs) {
+        this.refreshCompletedGroups();
+      }
+    },
+
+    async refreshCompletedGroups() {
+      const seq = ++this.completedRequestSeq;
+      const payload = this.buildCompletedPayload();
+
+      // 娌℃湁绉戝/鐥呭尯鏉冮檺鏃朵笉鍙戣捣璇锋眰锛岄伩鍏嶆妸鍏ㄩ噺鏁版嵁鏌ュ嚭鏉�
+      if (!payload) {
+        this.emitCompletedGroups([], seq);
+        return;
+      }
+
+      this.$emit("completed-rows-change", {
+        ...this.buildCompletedMeta(),
+        loading: true,
+      });
+
+      try {
+        const res = await getTaskservelist(payload);
+        if (seq !== this.completedRequestSeq) return;
+
+        const rows = this.pickCompletedRows(res);
+        this.emitCompletedGroups(rows, seq);
+      } catch (error) {
+        if (seq !== this.completedRequestSeq) return;
+        console.error("鑾峰彇宸插畬鎴愭偅鑰呮槑缁嗗け璐�:", error);
+        this.emitCompletedGroups([], seq);
+      }
+    },
+
+    // 缁勮绗竴寮犮�屾弧鎰忓害鐘舵�佹煡璇€�嶉〉鍚屾鏌ヨ鏉′欢
+    buildCompletedPayload() {
+      const scope = this.buildCompletedScope();
+      if (!scope.all && !scope.depts.length && !scope.wards.length) {
+        return null;
+      }
+
+      const payload = {
+        pageNum: null,
+        pageSize: null,
+        sendstate: null,
+        sendstateView: 2, // 2 = 宸插畬鎴�
+        sort: 2,
+        serviceType: this.currentServiceType,
+        searchscope: scope.searchscope,
+        visitCount: 1,
+        scopetype: [],
+        // 涓庣涓�寮犲浘涓�鑷达細閫変簡鍏蜂綋绉戝/鐥呭尯鏃跺彧浼犲搴旂淮搴︼紱銆屽叏閮ㄣ�嶆椂涓や釜缁村害閮戒紶
+        deptOrDistrict: scope.deptOrDistrict,
+      };
+
+      // 鍦ㄩ櫌婊℃剰搴︾敤 hospital*锛岀闄㈡弧鎰忓害鐢� leave*
+      if (this.satisfactionScope === "hospital") {
+        if (scope.depts.length) {
+          payload.deptcodes = scope.depts;
+        }
+        if (scope.wards.length) {
+          payload.hospitaldistrictcodes = scope.wards;
+        }
+      } else {
+        if (scope.depts.length) {
+          payload.leaveldeptcodes = scope.depts;
+        }
+        if (scope.wards.length) {
+          payload.leavehospitaldistrictcodes = scope.wards;
+        }
+      }
+
+      const range = this.queryParams.dateRange || [];
+      if (range.length === 2 && range[0] && range[1]) {
+        payload.finishtimeStart = range[0];
+        payload.finishtimeEnd = range[1];
+      }
+
+      return payload;
+    },
+
+    // 缁勮鏌ヨ鑼冨洿锛氱粺璁$被鍨嬪喅瀹氭寜鐥呭尯杩樻槸绉戝杩囨护
+    buildCompletedScope() {
+      const allDepts = (this.$store.getters.belongDepts || [])
+        .map((dept) => dept.deptCode)
+        .filter(Boolean);
+      const allWards = (this.$store.getters.belongWards || [])
+        .map((ward) => ward.districtCode)
+        .filter(Boolean);
+
+      // 鐥呭尯缁熻锛堝惈缁熻绫诲瀷涓虹┖鐨勬儏鍐碉級
+      if (this.queryParams.statisticaltype != 2) {
+        const rawSelected = this.queryParams.leavehospitaldistrictcodes || [];
+        const selected = rawSelected.filter(
+          (code) => code && code !== "all"
+        );
+        const useAll = !rawSelected.length || rawSelected.includes("all");
+
+        if (!useAll && selected.length) {
+          return {
+            depts: [],
+            wards: selected,
+            deptOrDistrict: 1,
+            searchscope: 2,
+          };
+        }
+        // 鍏ㄩ儴锛氫笉浼犵梾鍖�/绉戝缂栫爜锛岀敱鍚庣杩斿洖褰撳墠鏈烘瀯鍏ㄩ儴鏁版嵁
+        return {
+          depts: [],
+          wards: [],
+          deptOrDistrict: 2,
+          searchscope: 3,
+          all: true,
+        };
+      }
+
+      // 绉戝缁熻
+      const rawSelected = this.queryParams.deptcodes || [];
+      const selected = rawSelected.filter((code) => code && code !== "all");
+      const useAll = !rawSelected.length || rawSelected.includes("all");
+      if (!useAll && selected.length) {
+        return {
+          depts: selected,
+          wards: [],
+          deptOrDistrict: 1,
+          searchscope: 1,
+        };
+      }
+      return {
+        depts: [],
+        wards: [],
+        deptOrDistrict: 2,
+        searchscope: 3,
+        all: true,
+      };
+    },
+
+    // 闂璇︽儏鍗犳瘮 / 鍥捐〃 / 楗煎浘 鍏辩敤鏁版嵁
+    maybeRefreshQuestionDetails() {
+      if (this.showAnalysisTabs) {
+        this.refreshQuestionDetails();
+      }
+    },
+
+    async refreshQuestionDetails() {
+      const seq = ++this.questionRequestSeq;
+      const payload = this.buildQuestionPayload();
+
+      if (!payload) {
+        this.$emit("question-details-change", { loading: false, list: [] });
+        return;
+      }
+
+      this.$emit("question-details-change", { loading: true });
+
+      try {
+        const res = await getSfStatisticsJoyInfo(payload);
+        if (seq !== this.questionRequestSeq) return;
+
+        this.$emit("question-details-change", {
+          loading: false,
+          list: res.data || [],
+        });
+      } catch (error) {
+        if (seq !== this.questionRequestSeq) return;
+        console.error("鑾峰彇闂璇︽儏鍗犳瘮澶辫触:", error);
+        this.$emit("question-details-change", { loading: false, list: [] });
+      }
+    },
+
+    buildQuestionPayload() {
+      const scope = this.buildCompletedScope();
+      if (!scope.all && !scope.depts.length && !scope.wards.length) {
+        return null;
+      }
+
+      const params = {
+        configKey: "joyCount",
+        statisticaltype: this.queryParams.statisticaltype,
+        serviceType: this.queryParams.serviceType,
+        searchscope: scope.searchscope,
+        pageNum: 1,
+        pageSize: 999,
+      };
+
+      const range = this.queryParams.dateRange || [];
+      if (range.length === 2 && range[0] && range[1]) {
+        params.startTime = range[0];
+        params.endTime = range[1];
+      }
+
+      if (this.queryParams.statisticaltype == 2) {
+        if (scope.depts.length) {
+          if (this.isInHospitalSatisfaction) {
+            params.hospitaldeptcodes = scope.depts;
+          } else {
+            params.leaveldeptcodes = scope.depts;
+          }
+        }
+      } else if (scope.wards.length) {
+        if (this.isInHospitalSatisfaction) {
+          params.hospitaldistrictcodes = scope.wards;
+        } else {
+          params.leavehospitaldistrictcodes = scope.wards;
+        }
+      }
+
+      return params;
+    },
+
+    // 鍏煎鎺ュ彛涓嶅悓鐨勮繑鍥炲眰绾�
+    pickCompletedRows(res) {
+      if (!res) return [];
+      const rowsWrap = res.rows || (res.data && res.data.rows);
+      let list = [];
+
+      if (Array.isArray(rowsWrap) && rowsWrap[0]) {
+        list =
+          rowsWrap[0].serviceSubtaskList ||
+          (rowsWrap[0].sendname ? rowsWrap : []);
+      } else if (res.data && Array.isArray(res.data.serviceSubtaskList)) {
+        list = res.data.serviceSubtaskList;
+      } else if (Array.isArray(res.data)) {
+        list = res.data;
+      }
+
+      return (list || [])
+        .filter(Boolean)
+        .map((row) => this.normalizeCompletedRow(row));
+    },
+
+    normalizeCompletedRow(row) {
+      const item = { ...row };
+      if (item.endtime) {
+        item.endDay = this.daysBetween(item.endtime);
+      }
+      return item;
+    },
+
+    emitCompletedGroups(rows, seq) {
+      if (seq !== this.completedRequestSeq) return;
+      this.$emit("completed-rows-change", {
+        ...this.buildCompletedMeta(),
+        loading: false,
+        total: rows.length,
+        rows,
+      });
+    },
+
+    buildCompletedMeta() {
+      return {
+        dimension:
+          this.queryParams.statisticaltype == 2 ? "dept" : "ward",
+        scope: this.satisfactionScope,
+        dateRange: [...(this.queryParams.dateRange || [])],
+      };
+    },
+
+    // 鎸夊綋鍓嶇粺璁$被鍨嬪垎缁勶細鐥呭尯缁熻 -> 鐥呭尯锛岀瀹ょ粺璁� -> 绉戝
+    groupCompletedRows(rows) {
+      const dimension =
+        this.queryParams.statisticaltype == 2 ? "dept" : "ward";
+      const groupMap = new Map();
+
+      (rows || []).forEach((row) => {
+        const name =
+          dimension === "ward" ? this.wardNameOf(row) : this.deptNameOf(row);
+        const code =
+          dimension === "ward"
+            ? this.wardCodeOf(row)
+            : this.deptCodeOf(row);
+
+        const key = String(code || name || "unknown");
+        if (!groupMap.has(key)) {
+          groupMap.set(key, {
+            key,
+            label:
+              name || (dimension === "ward" ? "鏈垎鐥呭尯" : "鏈垎绉戝"),
+            rows: [],
+          });
+        }
+        groupMap.get(key).rows.push(row);
+      });
+
+      const orderMap = this.buildGroupOrder(dimension);
+      return Array.from(groupMap.values()).sort((a, b) => {
+        const aIndex = orderMap.has(a.key) ? orderMap.get(a.key) : 99999;
+        const bIndex = orderMap.has(b.key) ? orderMap.get(b.key) : 99999;
+        if (aIndex !== bIndex) return aIndex - bIndex;
+        return a.label.localeCompare(b.label, "zh-Hans-CN");
+      });
+    },
+
+    // tab 椤哄簭鎸夐〉闈㈠乏渚х瀹�/鐥呭尯鏉冮檺鍒楄〃鐨勯『搴忥紝淇濊瘉銆屼竴鐥呭尯銆佷簩鐥呭尯鈥︺�嶇殑鑷劧椤哄簭
+    buildGroupOrder(dimension) {
+      const list =
+        dimension === "ward"
+          ? this.$store.getters.belongWards
+          : this.$store.getters.belongDepts;
+      const orderMap = new Map();
+
+      (list || []).forEach((item, index) => {
+        const code =
+          dimension === "ward" ? item.districtCode : item.deptCode;
+        if (code) orderMap.set(String(code), index);
+      });
+
+      return orderMap;
+    },
+
+    wardNameOf(row) {
+      if (!row) return "";
+      const name =
+        this.satisfactionScope === "hospital"
+          ? row.hospitaldistrictname || row.leavehospitaldistrictname
+          : row.leavehospitaldistrictname || row.hospitaldistrictname;
+      return name === "-" ? "" : name;
+    },
+
+    wardCodeOf(row) {
+      if (!row) return "";
+      return this.satisfactionScope === "hospital"
+        ? row.hospitaldistrictcode || row.leavehospitaldistrictcode
+        : row.leavehospitaldistrictcode || row.hospitaldistrictcode;
+    },
+
+    deptNameOf(row) {
+      if (!row) return "";
+      const name =
+        this.satisfactionScope === "hospital"
+          ? row.deptname || row.leaveldeptname
+          : row.leaveldeptname || row.deptname;
+      return name === "-" ? "" : name;
+    },
+
+    deptCodeOf(row) {
+      if (!row) return "";
+      return this.satisfactionScope === "hospital"
+        ? row.hospitaldeptcode || row.deptcode
+        : row.deptcode || row.hospitaldeptcode;
+    },
+
+    // 閲嶇疆鏌ヨ锛堟仮澶嶉粯璁わ細绂婚櫌婊℃剰搴� + 鏈嶅姟绫诲瀷 6锛�
     resetQuery() {
-      this.satisfactionScope = "hospital";
+      this.satisfactionScope = "leave";
       this.queryParams = {
         statisticaltype: 1,
         leavehospitaldistrictcodes: [],
@@ -867,6 +1244,8 @@
         pageSize: 20,
       };
       this.getList();
+      this.maybeRefreshCompletedGroups();
+      this.maybeRefreshQuestionDetails();
     },
 
     // 澶勭悊鍒嗛〉澶у皬鍙樺寲
@@ -1087,15 +1466,9 @@
           },
         };
 
-        // 娣诲姞鎬绘爣棰橈紙涓ゅ垪缁村害 + 鍏釜鎸囨爣鍒楋紝鍏� 10 鍒楋級
-        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 = [
           isWardStatistics ? "鍦ㄩ櫌鐥呭尯" : "鍦ㄩ櫌绉戝",
           isWardStatistics ? "绂婚櫌鐥呭尯" : "绂婚櫌绉戝",
@@ -1103,11 +1476,19 @@
           "鏃犻渶闅忚浜烘",
           "搴旈殢璁夸汉娆�",
           "闅忚鐜�",
-          "鍙婃椂鐜�",
-          "婊℃剰搴﹂鐩�婚噺",
-          "婊℃剰搴﹀~鎶ラ噺",
-          "瀹屾垚姣旂巼",
         ];
+        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) => {
@@ -1115,9 +1496,13 @@
         });
         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([
+          const rowData = [
             isWardStatistics
               ? item.hospitaldistrictname || "-"
               : item.hospitaldeptname || "-",
@@ -1127,12 +1512,17 @@
             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;
@@ -1140,19 +1530,10 @@
           dataRow.height = 22;
         });
 
-        // 璁剧疆鍒楀
-        worksheet.columns = [
-          { width: 20 },
-          { 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