瀏覽代碼

[Fix 0000] 公司端报表数据显示异常

houzekong 2 月之前
父節點
當前提交
58497807ef

+ 8 - 9
src/views/vent/home/clique/components/echart-scene.vue

@@ -57,7 +57,6 @@
           opacity: 0.1,
         },
       };
-      console.log(scene.value, 'scene');
       const myChart = echarts.init(scene.value);
       let option = {
         color: ['#4edaff', '#53ffde', '#a696ed'],
@@ -246,14 +245,14 @@
 
   watch(
     () => props.echartData,
-    (newV, oldV) => {
-      console.log(newV, 'newV-----------');
-      percent.jf = newV.jfq;
-      percent.yf = newV.yfq;
-      percent.hf = newV.hfq;
-      percent.jfEcharts = Math.ceil(newV.zf - percent.jf);
-      percent.yfEcharts = Math.ceil(newV.zf - percent.yf);
-      percent.hfEcharts = Math.ceil(newV.zf - percent.hf);
+    ({ jfq, yfq, hfq, zf }) => {
+      const getEchartsNumber = (v: number) => Math.ceil(isNaN(v) ? 0 : v);
+      percent.jf = isNaN(jfq) ? '-' : jfq;
+      percent.yf = isNaN(yfq) ? '-' : yfq;
+      percent.hf = isNaN(hfq) ? '-' : hfq;
+      percent.jfEcharts = getEchartsNumber(zf - percent.jf);
+      percent.yfEcharts = getEchartsNumber(zf - percent.yf);
+      percent.hfEcharts = getEchartsNumber(zf - percent.hf);
       getOption();
     },
     {

+ 17 - 8
src/views/vent/home/clique/components/scene-key.vue

@@ -49,7 +49,7 @@
 
   let sceneTitle = ref('回风系统通风状态监测');
 
-  let sceneList = reactive([
+  let sceneList = reactive<{ label: string; value: number | string }[]>([
     { label: '总阻力', value: 0 },
     // { label: '总进风', value: 0 },
     { label: '总风量', value: 0 },
@@ -79,14 +79,23 @@
       }
       return false;
     });
-    echartData.jfq = data.majorpath.drag_1;
-    echartData.yfq = data.majorpath.drag_2;
-    echartData.hfq = data.majorpath.drag_3;
-    echartData.zf = data.majorpath.drag_total;
+    // 下面的每一个变量可能是:正常的 number、NaN
+    const { drag_1, drag_2, drag_3, drag_total, m3_total } = data.majorpath;
+    echartData.jfq = drag_1;
+    echartData.yfq = drag_2;
+    echartData.hfq = drag_3;
+    echartData.zf = drag_total;
 
-    sceneList[0].value = data.majorpath.drag_total;
-    sceneList[1].value = data.majorpath.m3_total;
-    sceneList[2].value = Math.round(((1.19 * sceneList[1].value) / 60 / Math.sqrt(sceneList[0].value)) * 100) / 100;
+    if (isNaN(drag_total) || isNaN(m3_total)) {
+      // 如果数据是0,也会展示 '-'
+      sceneList[0].value = drag_total || '-';
+      sceneList[1].value = m3_total || '-';
+      sceneList[2].value = '-';
+    } else {
+      sceneList[0].value = drag_total;
+      sceneList[1].value = m3_total;
+      sceneList[2].value = Math.round(((1.19 * m3_total) / 60 / Math.sqrt(drag_total)) * 100) / 100;
+    }
   }
 
   watch(

+ 22 - 17
src/views/vent/home/clique/index.vue

@@ -156,36 +156,41 @@
       warningList.value = warningListTemp;
       compositeData.value = res.reduce((arr, e) => {
         if (isDataRealTime.value) {
-          return [...arr, ...e.majorpath_data];
+          arr.push(...e.majorpath_data);
         } else {
-          return [
-            ...arr,
-            ...e.majorpath_data.map(({ majorpath, readData }) => {
+          arr.push(
+            ...e.majorpath_data.map((ele) => {
+              const { majorpath, readData } = ele;
+              const { drag_1, drag_2, drag_3, drag_total } = majorpath;
+              const { retM3_merge, fy_merge } = readData;
               // 报表数据只有总数据,按实时数据计算比例然后乘以报表数据
-              if (readData.fy_merge && readData.retM3_merge) {
+              if (fy_merge && retM3_merge) {
                 return {
+                  ...ele,
                   majorpath: {
-                    drag_1: Math.round((majorpath.drag_1 / majorpath.drag_total) * parseInt(readData.fy_merge.value)),
-                    drag_2: Math.round((majorpath.drag_2 / majorpath.drag_total) * parseInt(readData.fy_merge.value)),
-                    drag_3: Math.round((majorpath.drag_3 / majorpath.drag_total) * parseInt(readData.fy_merge.value)),
-                    drag_total: readData.fy_merge.value,
-                    m3_total: readData.retM3_merge.value,
+                    drag_1: Math.round((drag_1 / drag_total) * parseInt(fy_merge.value)),
+                    drag_2: Math.round((drag_2 / drag_total) * parseInt(fy_merge.value)),
+                    drag_3: Math.round((drag_3 / drag_total) * parseInt(fy_merge.value)),
+                    drag_total: parseInt(fy_merge.value),
+                    m3_total: parseInt(retM3_merge.value),
                   },
                 };
               } else {
                 return {
+                  ...ele,
                   majorpath: {
-                    drag_1: '-',
-                    drag_2: '-',
-                    drag_3: '-',
-                    drag_total: '-',
-                    m3_total: '-',
+                    drag_1: NaN,
+                    drag_2: NaN,
+                    drag_3: NaN,
+                    drag_total: NaN,
+                    m3_total: NaN,
                   },
                 };
               }
-            }),
-          ];
+            })
+          );
         }
+        return arr;
       }, []);
       centerDetail.value = res.filter((v) => v.orgcode == orgcode.value)[0];
     }