WXL (wul)
4 天以前 bc9538a9e071259ca8bbb6de52c60c9d7a55a03b
src/views/Satisfaction/sfstatistics/components/ChartsPanel.vue
@@ -371,6 +371,11 @@
      if (!den) return '0.00';
      return (num / den).toFixed(2);
    },
    // 综合得分展示:直接使用后端 avgScore,格式化为两位小数
    formatScore(val) {
      const n = Number(val);
      return isNaN(n) ? '0.00' : n.toFixed(2);
    },
    // 解析比例字符串:"14.29%"、"0"、"0.5" → 数值(百分比);无效返回 null
    parsePercent(value) {
      if (value == null || value === '') return null;
@@ -382,7 +387,13 @@
      const arr = Array.isArray(list) ? list : (list && (list.list || list.rows)) || [];
      const options = [];
      let total = 0;
      let avgScore = null;
      arr.forEach((item) => {
        // 综合得分:后端返回的题目级 avgScore(与题目同级)
        if (avgScore == null) {
          const rawAvg = Number(item && item.avgScore);
          if (!isNaN(rawAvg)) avgScore = rawAvg;
        }
        const details = Array.isArray(item && item.subtaskDetailRatioExportList)
          ? item.subtaskDetailRatioExportList
          : [];
@@ -395,7 +406,7 @@
          total += count;
        });
      });
      return { options, total };
      return { options, total, avgScore };
    },
    // 单题选项统计(真实接口 /smartor/serviceSubtaskDetail/sltdMydTotalByScore)
    async fetchSingleQuestion() {
@@ -425,7 +436,7 @@
        const res = await sltdMydTotalByScore(payload);
        console.log('[sltdMydTotalByScore 单题] code=', res && res.code, 'data=', JSON.stringify(res && res.data).slice(0, 1500));
        const list = res && res.code === 200 ? res.data : [];
        const { options, total } = this.normalizeSingleQuestion(list);
        const { options, total, avgScore } = this.normalizeSingleQuestion(list);
        this.singleQuestionData = options.map((o) => ({
          option: o.option,
          count: o.count,
@@ -435,7 +446,7 @@
        }));
        this.singleQuestionMeta = {
          total: total.toLocaleString(),
          score: this.scoreOfOptions(options),
          score: this.formatScore(avgScore),
        };
        if (!options.length) this.notify('当前条件下暂无该题的选项统计数据', 'warning');
      } catch (e) {