Forráskód Böngészése

fix: 雷达图显示异常

zhangjie 11 hónapja
szülő
commit
8d9810aeff

+ 9 - 4
src/modules/target/components/requirement-statistics/RequirementStatisticsRadar.vue

@@ -104,12 +104,17 @@ export default {
       const res = await requirementStatisticsRadar({
         cultureProgramId: this.rowData.cultureProgramId,
       });
-      this.dataList = res.obeRequirements || [];
+      this.dataList = res?.obeRequirements || [];
       this.updateChartOption();
     },
     updateChartOption() {
+      if (!this.dataList.length) {
+        this.chartOption = null;
+        return;
+      }
+
       const vals = this.dataList
-        .map((item) => [item.expectValue, item.matrixDegree])
+        .map((item) => [item.expectValue || 0, item.matrixDegree || 0])
         .flat();
       const maxVal = Math.min(maxNum(vals) * 1.2, 1);
       const option = {
@@ -145,11 +150,11 @@ export default {
             type: "radar",
             data: [
               {
-                value: this.dataList.map((item) => item.expectValue),
+                value: this.dataList.map((item) => item.expectValue || 0),
                 name: "预期值",
               },
               {
-                value: this.dataList.map((item) => item.matrixDegree),
+                value: this.dataList.map((item) => item.matrixDegree || 0),
                 name: "实际值",
               },
             ],