liusheng
2 天以前 bbbc478129f72b26e2ec4a2e981ed8698a96880c
src/views/Satisfaction/sfstatistics/components/SatisfactionStatistics.vue
@@ -11,11 +11,25 @@
          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"
              placeholder="请选择统计类型"
              clearable
            @change="handleSearch"
              style="width: 100%"
            >
              <el-option label="问卷类型" :value="2" />
@@ -104,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>
@@ -139,6 +153,8 @@
          <div
            id="satisfactionBarChart"
            v-loading="loading"
            element-loading-text="统计加载中..."
            style="width: 100%; height: 400px"
          ></div>
        </div>
@@ -290,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>
@@ -303,7 +319,7 @@
                    }}</span>
                  </div>
                </div>
              </div>
              </div> -->
              <!-- 分页 -->
              <div
@@ -680,6 +696,10 @@
  dicts: ["dimensionality_type"],
  data() {
    return {
      // 满意度类型:leave=离院满意度(leaveldeptcodes/leavehospitaldistrictcodes),
      // hospital=在院满意度(deptcodes/hospitaldistrictcodes)
      // 默认在院:保持该页原有请求参数不变
      satisfactionScope: "hospital",
      // 查询参数
      queryParams: {
        type: 2,
@@ -856,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() {
@@ -882,6 +913,8 @@
    async initData() {
      await this.getDeptList();
      await this.getWardList();
      // 接口默认按「全部科室 + 全部病区 + 最近7天」查询,这里把实际使用的条件回显到筛选框
      this.echoQueryParams();
      this.initChart();
      await this.loadData();
    },
@@ -910,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 };
    },
    // 把接口实际使用的查询条件回显到筛选框:
    // 科室/病区未选时接口按「全部」查,时间未选时接口按「最近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);
      }
    },
    // 获取图表标题
@@ -953,8 +1013,7 @@
        type: this.queryParams.type,
        startTime: this.startTime,
        endTime: this.endTime,
        deptcodes: this.deptCodes, // 使用计算属性
        hospitaldistrictcodes: this.hospitalDistrictCodes, // 使用计算属性
        ...this.buildScopeParams(),
        templateid: this.templateId,
      };
@@ -973,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);
@@ -1151,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,
        };
      });
@@ -1187,6 +1248,7 @@
          templateid: this.templateId,
          questionType: this.queryParams.type || null,
          serviceTypes: this.defaultServiceTypes,
          dimensionList: this.dimensionList, // 问题维度集合,查维度时必传
        };
        const response = await statisticsByDimension(params);
@@ -1236,14 +1298,14 @@
          dimension: item.dimension || "0", // 维度代码
          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,
        };
      });
@@ -1998,8 +2060,10 @@
    handleReset() {
      this.$refs.queryForm.resetFields();
      this.queryParams.dateRange = [];
        this.queryParams.deptCodes = [];  // 重置为数组
  this.queryParams.wardCodes = [];  // 重置为数组
      this.queryParams.deptCodes = []; // 重置为数组
      this.queryParams.wardCodes = []; // 重置为数组
      // 重置后接口仍按「全部科室/全部病区 + 最近7天」查询,筛选框同步回显,避免框里空空、请求里有值
      this.echoQueryParams();
      this.detailQueryParams.pageNum = 1;
      this.dimensionQueryParams.pageNum = 1;
      this.loadData();
@@ -2067,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)}%`;
    },