浏览代码

完善绩效榜报错逻辑

baiyanting 1 年之前
父节点
当前提交
3cdbaf2cc2
共有 1 个文件被更改,包括 66 次插入59 次删除
  1. 66 59
      src/views/economicsOperation/benchmarkingManagement/performanceRankingList/index.vue

+ 66 - 59
src/views/economicsOperation/benchmarkingManagement/performanceRankingList/index.vue

@@ -467,72 +467,79 @@ export default {
         lineids: this.lineObj,
         target: this.target,
         sort: this.sort,
-      }).then(({ data: res }) => {
-        this.initFlag = false;
-        if (res.data.length) {
-          let name = [],
-            data = [],
-            llfdl = [],
-            legend = [
-              "实际电量",
-              "检修损失电量",
-              "故障损失电量",
-              "限电损失电量",
-              "受累损失电量",
-              "性能损失电量",
-            ]; //项目列表
-          res.data.forEach((item, index) => {
-            name.push(item.name);
-            data.push([
-              item.sjfdl,
-              item.jhjx,
-              item.fjhjx,
-              item.xd,
-              item.sl,
-              item.xn,
-            ]);
-            llfdl.push(item.llfdl);
-          });
-          name.pop();
-          data.pop();
-          llfdl.pop();
-          if (data.length > 0) {
-            let arr1 = [];
-            const length = data[0].length;
-            for (let i = 0; i < length; i++) {
-              let arr2 = [];
-              data.forEach((ele) => {
-                arr2.push(ele[i]);
-              });
-              arr1.push(arr2);
+      })
+        .then((res) => {
+          this.initFlag = false;
+          if (res.data.data && res.data.data.length) {
+            let name = [],
+              data = [],
+              llfdl = [],
+              legend = [
+                "实际电量",
+                "检修损失电量",
+                "故障损失电量",
+                "限电损失电量",
+                "受累损失电量",
+                "性能损失电量",
+              ]; //项目列表
+            res.data.data.forEach((item, index) => {
+              name.push(item.name);
+              data.push([
+                item.sjfdl,
+                item.jhjx,
+                item.fjhjx,
+                item.xd,
+                item.sl,
+                item.xn,
+              ]);
+              llfdl.push(item.llfdl);
+            });
+            name.pop();
+            data.pop();
+            llfdl.pop();
+            if (data.length > 0) {
+              let arr1 = [];
+              const length = data[0].length;
+              for (let i = 0; i < length; i++) {
+                let arr2 = [];
+                data.forEach((ele) => {
+                  arr2.push(ele[i]);
+                });
+                arr1.push(arr2);
+              }
+              this.lineData = llfdl;
+              this.bardata = {
+                area: name,
+                legend: legend,
+                data: arr1,
+              };
+            } else {
+              (this.bardata = []), (this.lineData = []);
             }
-            this.lineData = llfdl;
-            this.bardata = {
-              area: name,
-              legend: legend,
-              data: arr1,
-            };
-          } else {
-            (this.bardata = []), (this.lineData = []);
-          }
-          if (this.lineData.length > 22) {
-            this.height = this.lineData.length * 37 + 53 + "px";
+            if (this.lineData.length > 22) {
+              this.height = this.lineData.length * 37 + 53 + "px";
+            } else {
+              this.height = 23 * 38 + 80 + "px";
+            }
+            this.showDisplay = false;
+            setTimeout(() => {
+              this.showDisplay = true;
+            }, 10);
+            this.tableData = res.data.data;
+            this.BASE.closeLoading();
           } else {
-            this.height = 23 * 38 + 80 + "px";
+            this.tableData = [];
+            this.bardata = [];
+            this.lineData = [];
+            this.BASE.closeLoading();
           }
-          this.showDisplay = false;
-          setTimeout(() => {
-            this.showDisplay = true;
-          }, 10);
-          this.tableData = res.data;
-          this.BASE.closeLoading();
-        } else {
+        })
+        .catch((err) => {
           this.tableData = [];
           this.bardata = [];
           this.lineData = [];
           this.BASE.closeLoading();
-        }
-      });
+        });
     },
     mxClick() {
       this.$router.push({