liusheng
2 天以前 bbbc478129f72b26e2ec4a2e981ed8698a96880c
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"
@@ -684,6 +696,10 @@
  dicts: ["dimensionality_type"],
  data() {
    return {
      // 满意度类型:leave=离院满意度(leaveldeptcodes/leavehospitaldistrictcodes),
      // hospital=在院满意度(deptcodes/hospitaldistrictcodes)
      // 默认在院:保持该页原有请求参数不变
      satisfactionScope: "hospital",
      // 查询参数
      queryParams: {
        type: 2,
@@ -866,6 +882,11 @@
      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() {
@@ -892,6 +913,8 @@
    async initData() {
      await this.getDeptList();
      await this.getWardList();
      // 接口默认按「全部科室 + 全部病区 + 最近7天」查询,这里把实际使用的条件回显到筛选框
      this.echoQueryParams();
      this.initChart();
      await this.loadData();
    },
@@ -920,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);
      }
    },
    // 获取图表标题
@@ -963,8 +1013,7 @@
        type: this.queryParams.type,
        startTime: this.startTime,
        endTime: this.endTime,
        deptcodes: this.deptCodes, // 使用计算属性
        hospitaldistrictcodes: this.hospitalDistrictCodes, // 使用计算属性
        ...this.buildScopeParams(),
        templateid: this.templateId,
      };
@@ -983,8 +1032,7 @@
        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,
@@ -2012,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();