From bbbc478129f72b26e2ec4a2e981ed8698a96880c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 22 十月 2026 00:28:18 +0800
Subject: [PATCH] 当service_type=6时,需要根据传入的入院还是离院病区(病区)去后端查询

---
 src/views/Satisfaction/sfstatistics/components/SatisfactionStatistics.vue |  116 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 89 insertions(+), 27 deletions(-)

diff --git a/src/views/Satisfaction/sfstatistics/components/SatisfactionStatistics.vue b/src/views/Satisfaction/sfstatistics/components/SatisfactionStatistics.vue
index 59623b3..eda31ce 100644
--- a/src/views/Satisfaction/sfstatistics/components/SatisfactionStatistics.vue
+++ b/src/views/Satisfaction/sfstatistics/components/SatisfactionStatistics.vue
@@ -11,6 +11,18 @@
           label-width="100px"
           class="query-form"
         >
+          <el-form-item label="婊℃剰搴︾被鍨�" prop="satisfactionScope">
+            <el-select
+              v-model="satisfactionScope"
+              placeholder="榛樿鍦ㄩ櫌"
+              clearable
+              style="width: 140px"
+              @change="handleSearch"
+            >
+              <el-option label="绂婚櫌婊℃剰搴�" value="leave" />
+              <el-option label="鍦ㄩ櫌婊℃剰搴�" value="hospital" />
+            </el-select>
+          </el-form-item>
           <el-form-item label="缁熻绫诲瀷" prop="patientSource">
             <el-select
               v-model="queryParams.type"
@@ -106,13 +118,13 @@
             <h3 class="chart-title">{{ getChartTitle() }}</h3>
             <div class="statistic-info">
               <div class="statistic-item">
-                <span class="statistic-label">鍙戦�侀棶鍗锋�婚噺锛�</span>
+                <span class="statistic-label">鍙戦�侀鐩�婚噺锛�</span>
                 <span class="statistic-value">{{
                   totalSendCount.toLocaleString()
                 }}</span>
               </div>
               <div class="statistic-item">
-                <span class="statistic-label">鍥炴敹闂嵎鎬婚噺锛�</span>
+                <span class="statistic-label">鍥炴敹棰樼洰鎬婚噺锛�</span>
                 <span class="statistic-value">{{
                   totalReceiveCount.toLocaleString()
                 }}</span>
@@ -141,6 +153,8 @@
 
           <div
             id="satisfactionBarChart"
+            v-loading="loading"
+            element-loading-text="缁熻鍔犺浇涓�..."
             style="width: 100%; height: 400px"
           ></div>
         </div>
@@ -292,7 +306,7 @@
               </el-table>
 
               <!-- 缁煎悎寰楀垎琛� -->
-              <div class="summary-row">
+              <!-- <div class="summary-row">
                 <div class="summary-content">
                   <div class="summary-item">
                     <span class="label">鎬荤瓟棰樹汉鏁帮細</span>
@@ -305,7 +319,7 @@
                     }}</span>
                   </div>
                 </div>
-              </div>
+              </div> -->
 
               <!-- 鍒嗛〉 -->
               <div
@@ -682,6 +696,10 @@
   dicts: ["dimensionality_type"],
   data() {
     return {
+      // 婊℃剰搴︾被鍨嬶細leave=绂婚櫌婊℃剰搴︼紙leaveldeptcodes/leavehospitaldistrictcodes锛夛紝
+      // hospital=鍦ㄩ櫌婊℃剰搴︼紙deptcodes/hospitaldistrictcodes锛�
+      // 榛樿鍦ㄩ櫌锛氫繚鎸佽椤靛師鏈夎姹傚弬鏁颁笉鍙�
+      satisfactionScope: "hospital",
       // 鏌ヨ鍙傛暟
       queryParams: {
         type: 2,
@@ -858,6 +876,17 @@
       }
       return this.wardList.map((ward) => ward.value);
     },
+
+    // 闂缁村害闆嗗悎锛氫粠 dimensionality_type 瀛楀吀鍙栫淮搴︾紪鐮侊紝鏌ョ淮搴︽椂蹇呬紶
+    dimensionList() {
+      const dict = this.dict && this.dict.type && this.dict.type.dimensionality_type;
+      return dict ? dict.map((d) => String(d.value)) : [];
+    },
+
+    // 鏄惁鎸夈�屽湪闄㈡弧鎰忓害銆嶅彛寰勬煡璇紙鏈〉榛樿鍦ㄩ櫌锛屾墍浠ユ竻绌轰笅鎷夋椂浠嶆寜鍦ㄩ櫌澶勭悊锛�
+    isInHospitalSatisfaction() {
+      return this.satisfactionScope !== "leave";
+    },
   },
 
   mounted() {
@@ -884,6 +913,8 @@
     async initData() {
       await this.getDeptList();
       await this.getWardList();
+      // 鎺ュ彛榛樿鎸夈�屽叏閮ㄧ瀹� + 鍏ㄩ儴鐥呭尯 + 鏈�杩�7澶┿�嶆煡璇紝杩欓噷鎶婂疄闄呬娇鐢ㄧ殑鏉′欢鍥炴樉鍒扮瓫閫夋
+      this.echoQueryParams();
       this.initChart();
       await this.loadData();
     },
@@ -912,6 +943,33 @@
         });
         resolve();
       });
+    },
+
+    // 绉戝/鐥呭尯鏉′欢锛�
+    // 鍦ㄩ櫌婊℃剰搴� => deptcodes / hospitaldistrictcodes锛涚闄㈡弧鎰忓害 => leaveldeptcodes / leavehospitaldistrictcodes
+    buildScopeParams() {
+      const deptCodes = this.deptCodes;
+      const wardCodes = this.hospitalDistrictCodes;
+      return this.isInHospitalSatisfaction
+        ? { deptcodes: deptCodes, hospitaldistrictcodes: wardCodes }
+        : { leaveldeptcodes: deptCodes, leavehospitaldistrictcodes: wardCodes };
+    },
+
+    // 鎶婃帴鍙e疄闄呬娇鐢ㄧ殑鏌ヨ鏉′欢鍥炴樉鍒扮瓫閫夋锛�
+    // 绉戝/鐥呭尯鏈�夋椂鎺ュ彛鎸夈�屽叏閮ㄣ�嶆煡锛屾椂闂存湭閫夋椂鎺ュ彛鎸夈�屾渶杩�7澶┿�嶆煡锛岃繖閲屾妸鍚屾牱鐨勫�煎啓鍥炵瓫閫夋
+    echoQueryParams() {
+      if (
+        !this.queryParams.dateRange ||
+        this.queryParams.dateRange.length !== 2
+      ) {
+        this.queryParams.dateRange = [this.startTime, this.endTime];
+      }
+      if (!(this.queryParams.deptCodes || []).length) {
+        this.queryParams.deptCodes = this.deptList.map((dept) => dept.value);
+      }
+      if (!(this.queryParams.wardCodes || []).length) {
+        this.queryParams.wardCodes = this.wardList.map((ward) => ward.value);
+      }
     },
 
     // 鑾峰彇鍥捐〃鏍囬
@@ -955,8 +1013,7 @@
         type: this.queryParams.type,
         startTime: this.startTime,
         endTime: this.endTime,
-        deptcodes: this.deptCodes, // 浣跨敤璁$畻灞炴��
-        hospitaldistrictcodes: this.hospitalDistrictCodes, // 浣跨敤璁$畻灞炴��
+        ...this.buildScopeParams(),
         templateid: this.templateId,
       };
 
@@ -975,9 +1032,11 @@
         type: this.queryParams.type,
         startTime: this.startTime,
         endTime: this.endTime,
-        deptcodes: this.deptCodes, // 浣跨敤璁$畻灞炴��
-        hospitaldistrictcodes: this.hospitalDistrictCodes, // 浣跨敤璁$畻灞炴��
+        ...this.buildScopeParams(),
         templateid: this.templateId,
+        questionType: this.queryParams.type || null,
+        serviceTypes: this.defaultServiceTypes,
+        dimensionList: this.dimensionList, // 闂缁村害闆嗗悎锛屾煡缁村害鏃跺繀浼�
       };
 
       const response = await satisfactionGraphDimension(params);
@@ -1153,14 +1212,14 @@
         return {
           scriptContent: item.scriptContent || "",
           scriptType: 1,
-          answerPerson: item.answerPerson || 0,
-          noAnswerPerson: item.noAnswerPerson || 0,
-          answerCount: item.answerPerson || 0,
-          averageScore: item.averageScore || 0,
-          maxScore: item.maxScore || 0,
-          minScore: item.minScore || 0,
-          answerRate: item.answerRate || 0,
-          totalCount: (item.answerPerson || 0) + (item.noAnswerPerson || 0),
+          answerPerson: Number(item.answerPerson) || 0,
+          noAnswerPerson: Number(item.noAnswerPerson) || 0,
+          answerCount: Number(item.answerPerson) || 0,
+          averageScore: Number(item.averageScore) || 0,
+          maxScore: Number(item.maxScore) || 0,
+          minScore: Number(item.minScore) || 0,
+          answerRate: Number(item.answerRate) || 0,
+          totalCount: (Number(item.answerPerson) || 0) + (Number(item.noAnswerPerson) || 0),
           options: options,
         };
       });
@@ -1189,6 +1248,7 @@
           templateid: this.templateId,
           questionType: this.queryParams.type || null,
           serviceTypes: this.defaultServiceTypes,
+          dimensionList: this.dimensionList, // 闂缁村害闆嗗悎锛屾煡缁村害鏃跺繀浼�
         };
 
         const response = await statisticsByDimension(params);
@@ -1238,14 +1298,14 @@
           dimension: item.dimension || "0", // 缁村害浠g爜
           dimensionName: this.getDimensionLabel(item.dimension || "0"), // 缁村害鍚嶇О
           scriptType: 1,
-          answerPerson: item.answerPerson || 0,
-          noAnswerPerson: item.noAnswerPerson || 0,
-          answerCount: item.answerPerson || 0,
-          averageScore: item.averageScore || 0,
-          maxScore: item.maxScore || 0,
-          minScore: item.minScore || 0,
-          answerRate: item.answerRate || 0,
-          totalCount: (item.answerPerson || 0) + (item.noAnswerPerson || 0),
+          answerPerson: Number(item.answerPerson) || 0,
+          noAnswerPerson: Number(item.noAnswerPerson) || 0,
+          answerCount: Number(item.answerPerson) || 0,
+          averageScore: Number(item.averageScore) || 0,
+          maxScore: Number(item.maxScore) || 0,
+          minScore: Number(item.minScore) || 0,
+          answerRate: Number(item.answerRate) || 0,
+          totalCount: (Number(item.answerPerson) || 0) + (Number(item.noAnswerPerson) || 0),
           options: options,
         };
       });
@@ -2000,8 +2060,10 @@
     handleReset() {
       this.$refs.queryForm.resetFields();
       this.queryParams.dateRange = [];
-        this.queryParams.deptCodes = [];  // 閲嶇疆涓烘暟缁�
-  this.queryParams.wardCodes = [];  // 閲嶇疆涓烘暟缁�
+      this.queryParams.deptCodes = []; // 閲嶇疆涓烘暟缁�
+      this.queryParams.wardCodes = []; // 閲嶇疆涓烘暟缁�
+      // 閲嶇疆鍚庢帴鍙d粛鎸夈�屽叏閮ㄧ瀹�/鍏ㄩ儴鐥呭尯 + 鏈�杩�7澶┿�嶆煡璇紝绛涢�夋鍚屾鍥炴樉锛岄伩鍏嶆閲岀┖绌恒�佽姹傞噷鏈夊��
+      this.echoQueryParams();
       this.detailQueryParams.pageNum = 1;
       this.dimensionQueryParams.pageNum = 1;
       this.loadData();
@@ -2069,7 +2131,7 @@
       const num = parseFloat(value);
       if (isNaN(num)) return "-";
       // 濡傛灉鍊煎皬浜�1锛岃涓烘槸灏忔暟姣斾緥锛岄渶瑕佷箻浠�100
-      const percentValue = num < 1 ? num * 100 : num;
+      const percentValue = num <= 1 ? num * 100 : num;
       return `${percentValue.toFixed(2)}%`;
     },
 

--
Gitblit v1.9.3