Jelajahi Sumber

WMS历史轨迹-修复X轴时间排序混乱。

DongZ 1 tahun lalu
induk
melakukan
b17b3a5970
1 mengubah file dengan 23 tambahan dan 20 penghapusan
  1. 23 20
      src/views/WMS/historical-route/index.vue

+ 23 - 20
src/views/WMS/historical-route/index.vue

@@ -195,7 +195,6 @@
                 path.push([latitudeLongitude[i].gpsLongitude, latitudeLongitude[i].gpsLatitude]);
               }
             }
-            console.log(latitudeLongitude, 'latitudeLongitude')
             //计算各值
             this.calculate(res.data);
             //对订单温湿度列表进行赋值
@@ -207,7 +206,6 @@
               probeSum[i] = latitudeLongitude[i].measuringPointAddr;
             }
             probe = Array.from(new Set(probeSum));
-            console.log(probe, 'probe');
             //车辆温度数组
             let c, d;
             this.initEcharts();
@@ -275,12 +273,8 @@
               }
               this.option.series.push(carForm);
               this.option.legend.data.push(carForm.name);
-              console.log(this.option.series, 'this.option.series');
             }
-            // console.log(path, 'path')
-            console.log(this.temperatureData, 'temperatureData')
             //筛选保温箱的数组
-            console.log(this.carMessage.boxCode, 'this.carMessage.boxCode')
             if (this.carMessage.boxCode != null) {
               let e, f;
               for (let i = 0; i < this.carMessage.boxCode.length; i++) {
@@ -348,7 +342,6 @@
                 this.option.series.push(boxForm);
                 this.option.legend.data.push(boxForm.name);
               }
-              console.log(this.option.series, 'this.option.series');
             }
             //如果车辆温度数组为空,则其它数组前移一位
             for (let i = 1;;) {
@@ -364,13 +357,12 @@
                 break;
               }
             }
-            console.log(this.option, 'this.option');
             this.windowSize();
             //对基础数据进行赋值
             this.basicData.billCode = this.carMessage.billCode;
             this.basicData.plateNumber = this.carMessage.plateNumber;
-            this.basicData.startTime = res.data[0].hisDate;
-            this.basicData.endTime = res.data[res.data.length - 1].hisDate;
+            this.basicData.startTime = this.xData[0];
+            this.basicData.endTime = this.xData[this.xData.length - 1];
             //基本地图加载
             this.loadMap(path);
           }
@@ -428,10 +420,11 @@
             }
           },
           grid: {
-            left: '3%',
-            right: '4%',
-            bottom: '5%',
-            containLabel: true
+            x: 22,
+            y: 30,
+            x2: 20,
+            y2: 18,
+            borderWidth: 1,
           },
           toolbox: {
             //保存图
@@ -454,6 +447,9 @@
             name: '温度',
             // Y轴最大值
             max: 10,
+            // Y轴最大值
+            min: -30,
+            splitNumber: 2,
             // 间隔值
             // interval: 3
           },
@@ -531,9 +527,19 @@
           this.aggT += array[i].temperature;
           this.aggH += array[i].humidity;
         }
-        //x轴时间去重
-        this.xData = Array.from(new Set(x));
-        // console.log(this.xData, 'this.xData')
+        //x数组去重
+        x = Array.from(new Set(x));
+        let xSort = [];
+        for (let i = 0; i < x.length; i++) {
+          xSort[i] = new Date(x[i]);
+        }
+        xSort.sort(function (a, b) {
+          return a - b;
+        })
+        for (let i = 0; i < xSort.length; i++) {
+          x[i] = this.formatDateTime(xSort[i], 'yyyy-MM-dd HH:mm:ss');
+        }
+        this.xData = x;
         //温湿度平均值
         this.avgT = this.aggT / array.length;
         this.avgH = this.aggH / array.length;
@@ -550,7 +556,6 @@
         this.modelData1[0].endTime = array[array.length - 1].hisDate;
         this.tableData1 = this.modelData1;
         let median = (array.length / 2).toFixed(0);
-        console.log(median, 'median');
         let table = []
         for (let i = 0; i < median; i++) {
           table[i] = {
@@ -564,7 +569,6 @@
             hisDate1: ''
           }
         }
-        console.log(table, 'table');
         if (array.length % 2 == 0) {
           for (let i = 0, j = 0, z = 1; i < median; i++, j = j + 2, z = z + 2) {
             table[i].measuringPointName = array[j].measuringPointName;
@@ -590,7 +594,6 @@
             }
           }
         }
-        console.log(table, 'table');
         this.tableData2 = table;
       },
       //获取当前时间