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/Satisfaction/sfstatistics/components/FollowupStatistics.vue |  304 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 246 insertions(+), 58 deletions(-)

diff --git a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
index 20938e3..754e244 100644
--- a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
+++ b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
@@ -9,6 +9,19 @@
         label-width="100px"
         class="query-form"
       >
+        <el-form-item label="婊℃剰搴︾被鍨�" prop="satisfactionScope">
+          <el-select
+            v-model="satisfactionScope"
+            placeholder="榛樿鍦ㄩ櫌"
+            clearable
+            style="width: 150px"
+            @change="handleSatisfactionScopeChange"
+          >
+            <el-option label="绂婚櫌婊℃剰搴�" value="leave" />
+            <el-option label="鍦ㄩ櫌婊℃剰搴�" value="hospital" />
+          </el-select>
+        </el-form-item>
+
         <el-form-item label="缁熻绫诲瀷" prop="statisticaltype">
           <el-select
             v-model="queryParams.statisticaltype"
@@ -137,29 +150,67 @@
         @selection-change="handleSelectionChange"
         :row-key="getRowKey"
       >
-        <!-- 鐥呭尯鍒� -->
+        <!-- 鐥呭尯缁熻锛氬湪闄㈢梾鍖� + 绂婚櫌鐥呭尯 -->
         <el-table-column
           v-if="queryParams.statisticaltype == 1"
-          label="鍑洪櫌鐥呭尯"
+          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">
+            {{ 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="鍑洪櫌浜烘"
@@ -323,6 +374,7 @@
         :row-data="currentRow"
         :topicList="topiclist"
         :query-params="queryParams"
+        :topType="2"
         @close="topicVisible = false"
       />
     </el-dialog>
@@ -348,12 +400,17 @@
   },
   data() {
     return {
+      // 婊℃剰搴︾被鍨嬶細leave=绂婚櫌婊℃剰搴︼紙鎸夊嚭闄㈢梾鍖虹粺璁★級锛宧ospital=鍦ㄩ櫌婊℃剰搴︼紙鎸夊湪闄㈢梾鍖虹粺璁★級
+      // 榛樿鍦ㄩ櫌婊℃剰搴�
+      satisfactionScope: "hospital",
+
       // 鏌ヨ鍙傛暟
       queryParams: {
         statisticaltype: 1,
         leavehospitaldistrictcodes: ["all"],
         deptcodes: [],
-        serviceType: [2],
+        // 榛樿鏈嶅姟绫诲瀷锛�6=浣忛櫌婊℃剰搴︼紙鍑哄叆闄㈡弧鎰忓害锛�
+        serviceType: [6],
         dateRange: [],
         pageNum: 1,
         pageSize: 20,
@@ -372,7 +429,25 @@
       flatArraydept: [],
 
       // 鏈嶅姟绫诲瀷閫夐」
-      options: [],
+      options: [
+        {
+          value: 6,
+          label: "浣忛櫌婊℃剰搴�",
+          raw: {
+            cssClass: "",
+            listClass: "",
+          },
+        },
+
+        {
+          value: 14,
+          label: "闂ㄨ瘖婊℃剰搴�",
+          raw: {
+            cssClass: "",
+            listClass: "",
+          },
+        },
+      ],
 
       // 琛ㄦ牸鏁版嵁
       userList: [],
@@ -440,6 +515,15 @@
     };
   },
 
+  computed: {
+    // 鏄惁鎸夈�屽湪闄㈡弧鎰忓害銆嶅彛寰勭粺璁★細鍦ㄩ櫌鐢� hospitaldistrictcodes / hospitaldeptcodes锛�
+    // 绂婚櫌鐢� leavehospitaldistrictcodes / leaveldeptcodes
+    // 榛樿鍦ㄩ櫌锛屾墍浠ユ竻绌轰笅鎷夋椂浠嶆寜鍦ㄩ櫌鍙e緞澶勭悊
+    isInHospitalSatisfaction() {
+      return this.satisfactionScope !== "leave";
+    },
+  },
+
   created() {
     this.orgname = localStorage.getItem("orgname");
 
@@ -502,36 +586,56 @@
           params.endTime = this.queryParams.dateRange[1];
         }
 
-        // 澶勭悊鐥呭尯/绉戝閫夋嫨
+        // 澶勭悊鐥呭尯/绉戝閫夋嫨锛氬彧淇濈暀褰撳墠缁熻绫诲瀷 + 褰撳墠婊℃剰搴︾被鍨嬪搴旂殑瀛楁锛�
+        // 閬垮厤鍦ㄩ櫌/绂婚櫌涓ゅ鏉′欢鍚屾椂鎷艰繘 SQL
         if (params.statisticaltype == 1) {
           // 鐥呭尯缁熻
-          if (params.leavehospitaldistrictcodes.includes("all")) {
-            // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯绉婚櫎"all"鍊�
-            params.leavehospitaldistrictcodes =
-              params.leavehospitaldistrictcodes.filter(
-                (item) => item !== "all"
-              );
-            // 濡傛灉闇�瑕佷紶鎵�鏈夌梾鍖轰唬鐮侊紝鍙互浠巗tore涓幏鍙�
-            params.leavehospitaldistrictcodes = (
-              this.$store.getters.belongWards || []
-            ).map((ward) => ward.districtCode);
+          let wardCodes = params.leavehospitaldistrictcodes || [];
+          if (wardCodes.includes("all")) {
+            // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯浣跨敤褰撳墠鐢ㄦ埛鎵�灞炵殑鍏ㄩ儴鐥呭尯
+            wardCodes = (this.$store.getters.belongWards || []).map(
+              (ward) => ward.districtCode
+            );
+          }
+          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;
           }
         } 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);
@@ -541,9 +645,22 @@
       }
     },
     sortChineseNumber(aRow, bRow) {
-      const a = aRow.leavehospitaldistrictname;
-      const b = bRow.leavehospitaldistrictname;
-
+      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,
@@ -702,14 +819,12 @@
           return -1;
         };
 
-        const indexA = getIndex(a.leavehospitaldistrictname);
-        const indexB = getIndex(b.leavehospitaldistrictname);
+        const indexA = getIndex(this.getWardName(a));
+        const indexB = getIndex(this.getWardName(b));
 
         // 鎺掑簭閫昏緫
         if (indexA === -1 && indexB === -1) {
-          return (a.leavehospitaldistrictname || "").localeCompare(
-            b.leavehospitaldistrictname || ""
-          );
+          return this.getWardName(a).localeCompare(this.getWardName(b));
         }
         if (indexA === -1) return 1;
         if (indexB === -1) return -1;
@@ -733,13 +848,20 @@
       this.getList();
     },
 
-    // 閲嶇疆鏌ヨ
+    // 鍒囨崲婊℃剰搴︾被鍨嬶紙绂婚櫌/鍦ㄩ櫌锛夊悗閲嶆柊鏌ヨ
+    handleSatisfactionScopeChange() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+
+    // 閲嶇疆鏌ヨ锛堟仮澶嶉粯璁わ細鍦ㄩ櫌婊℃剰搴� + 鏈嶅姟绫诲瀷 6锛�
     resetQuery() {
+      this.satisfactionScope = "hospital";
       this.queryParams = {
         statisticaltype: 1,
         leavehospitaldistrictcodes: [],
         deptcodes: [],
-        serviceType: [2],
+        serviceType: [6],
         dateRange: [],
         pageNum: 1,
         pageSize: 20,
@@ -767,11 +889,19 @@
       this.multiple = !selection.length;
     },
 
-    // 鑾峰彇琛宬ey
+    // 鑾峰彇琛宬ey锛堟寜褰撳墠缁熻绫诲瀷鍙栧搴旂淮搴︾紪鐮侊級
     getRowKey(row) {
-      return row.statisticaltype === 1
-        ? row.leavehospitaldistrictcode
-        : row.deptcode;
+      return this.queryParams.statisticaltype == 1
+        ? row.hospitaldistrictcode || row.leavehospitaldistrictcode
+        : row.hospitaldeptcode || row.deptcode;
+    },
+
+    // 褰撳墠婊℃剰搴︾被鍨嬪搴旂殑鐥呭尯鍚嶇О锛堢敤浜庢帓搴�/瀵煎嚭/璇︽儏鏍囬锛�
+    getWardName(row) {
+      if (!row) return "";
+      return this.isInHospitalSatisfaction
+        ? row.hospitaldistrictname || ""
+        : row.leavehospitaldistrictname || "";
     },
 
     // 鏍煎紡鍖栫櫨鍒嗘瘮
@@ -808,12 +938,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 = row.leavehospitaldistrictname;
-          params.leavehospitaldistrictcodes = [row.leavehospitaldistrictcode];
+          if (this.isInHospitalSatisfaction) {
+            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);
@@ -838,23 +989,54 @@
         // 鏋勫缓鏃ユ湡鑼冨洿瀛楃涓�
         let dateRangeString = "";
         let sheetNameSuffix = "";
+        const isLishuiHospital = this.orgname == "涓芥按甯備腑鍖婚櫌";
 
         if (
           this.queryParams.dateRange &&
           this.queryParams.dateRange.length === 2
         ) {
-          const startDateFormatted = this.queryParams.dateRange[0];
-          const endDateFormatted = this.queryParams.dateRange[1];
-          dateRangeString = `${startDateFormatted}鑷�${endDateFormatted}`;
-          sheetNameSuffix = `${startDateFormatted}鑷�${endDateFormatted}`;
+          const startDateStr = this.queryParams.dateRange[0];
+          const endDateStr = this.queryParams.dateRange[1];
+
+          if (isLishuiHospital) {
+            // 涓芥按甯備腑鍖婚櫌锛氬彧鏄剧ず骞存湀
+            const formatMonthOnly = (dateTimeStr) => {
+              const date = new Date(dateTimeStr);
+              const year = date.getFullYear();
+              const month = date.getMonth() + 1;
+              return `${year}骞�${month}鏈坄;
+            };
+            const startDateFormatted = formatMonthOnly(startDateStr);
+            const endDateFormatted = formatMonthOnly(endDateStr);
+            dateRangeString = `${startDateFormatted}鑷�${endDateFormatted}`;
+            sheetNameSuffix = `${startDateFormatted}鑷�${endDateFormatted}`;
+          } else {
+            // 鍏朵粬鍖婚櫌锛氭樉绀哄勾鏈堟棩
+            const formatDateForDisplay = (dateTimeStr) => {
+              return dateTimeStr.split(" ")[0];
+            };
+            const startDateFormatted = formatDateForDisplay(startDateStr);
+            const endDateFormatted = formatDateForDisplay(endDateStr);
+            dateRangeString = `${startDateFormatted}鑷�${endDateFormatted}`;
+            sheetNameSuffix = `${startDateFormatted}鑷�${endDateFormatted}`;
+          }
         } else {
           const now = new Date();
           const currentMonth = now.getMonth() + 1;
-          dateRangeString = `${currentMonth}鏈坄;
-          sheetNameSuffix = `${currentMonth}鏈坄;
+          const currentYear = now.getFullYear();
+
+          if (isLishuiHospital) {
+            // 涓芥按甯備腑鍖婚櫌锛氭樉绀哄勾鏈�
+            dateRangeString = `${currentYear}骞�${currentMonth}鏈坄;
+            sheetNameSuffix = `${currentYear}骞�${currentMonth}鏈坄;
+          } else {
+            // 鍏朵粬鍖婚櫌锛氭樉绀烘湀浠�
+            dateRangeString = `${currentMonth}鏈坄;
+            sheetNameSuffix = `${currentMonth}鏈坄;
+          }
         }
 
-        const excelName = `闅忚缁熻琛╛${dateRangeString}.xlsx`;
+        const excelName = `婊℃剰搴﹂殢璁跨粺璁¤〃_${dateRangeString}.xlsx`;
         const worksheetName = `闅忚缁熻_${sheetNameSuffix}`;
 
         // 鍒涘缓Excel宸ヤ綔绨�
@@ -905,16 +1087,18 @@
           },
         };
 
-        // 娣诲姞鎬绘爣棰�
+        // 娣诲姞鎬绘爣棰橈紙涓ゅ垪缁村害 + 鍏釜鎸囨爣鍒楋紝鍏� 10 鍒楋級
         worksheet.mergeCells(1, 1, 1, 10);
         const titleCell = worksheet.getCell(1, 1);
-        titleCell.value = `闅忚缁熻琛紙${sheetNameSuffix}锛塦;
+        titleCell.value = `婊℃剰搴﹂殢璁跨粺璁¤〃锛�${sheetNameSuffix}锛塦;
         titleCell.style = titleStyle;
         worksheet.getRow(1).height = 35;
 
-        // 娣诲姞琛ㄥご
+        // 娣诲姞琛ㄥご锛堢瀹ょ粺璁″鍑哄湪闄㈢瀹�+绂婚櫌绉戝锛岀梾鍖虹粺璁″鍑哄湪闄㈢梾鍖�+绂婚櫌鐥呭尯锛�
+        const isWardStatistics = this.queryParams.statisticaltype == 1;
         const headers = [
-          this.queryParams.statisticaltype == 1 ? "鍑洪櫌鐥呭尯" : "绉戝",
+          isWardStatistics ? "鍦ㄩ櫌鐥呭尯" : "鍦ㄩ櫌绉戝",
+          isWardStatistics ? "绂婚櫌鐥呭尯" : "绂婚櫌绉戝",
           "鍑洪櫌浜烘",
           "鏃犻渶闅忚浜烘",
           "搴旈殢璁夸汉娆�",
@@ -934,9 +1118,12 @@
         // 娣诲姞鏁版嵁琛�
         this.userList.forEach((item) => {
           const dataRow = worksheet.addRow([
-            this.queryParams.statisticaltype == 1
-              ? item.leavehospitaldistrictname
-              : item.deptname,
+            isWardStatistics
+              ? item.hospitaldistrictname || "-"
+              : item.hospitaldeptname || "-",
+            isWardStatistics
+              ? item.leavehospitaldistrictname || "-"
+              : item.deptname || "-",
             item.dischargeCount || 0,
             item.nonFollowUp || 0,
             item.followUpNeeded || 0,
@@ -956,6 +1143,7 @@
         // 璁剧疆鍒楀
         worksheet.columns = [
           { width: 20 },
+          { width: 20 },
           { width: 12 },
           { width: 12 },
           { width: 12 },

--
Gitblit v1.9.3