Browse Source

Merge branch 'historical_route' into 'dev'

Historical route

See merge request new-business/drp-web!124
黄梓星 2 years ago
parent
commit
423abfeb8a
3 changed files with 62 additions and 38 deletions
  1. 1 1
      src/permission.js
  2. 6 1
      src/router/index.js
  3. 55 36
      src/views/WMS/historical-route/index.vue

+ 1 - 1
src/permission.js

@@ -8,7 +8,7 @@ import { isRelogin } from '@/utils/request'
 
 NProgress.configure({ showSpinner: false })
 
-const whiteList = ['/login', '/register', '/test01', '/canteenAddFood', '/canteenAddMenu', '/menuScreen', '/foodScreen']
+const whiteList = ['/login', '/register', '/test01', '/canteenAddFood', '/canteenAddMenu', '/menuScreen', '/foodScreen','/business/wms/historical-route']
 
 router.beforeEach((to, from, next) => {
   NProgress.start()

+ 6 - 1
src/router/index.js

@@ -156,7 +156,12 @@ export const constantRoutes = [
       }
 
     ]
-  }
+  },
+  {
+    path: '/business/wms/historical-route',
+    component: () => import('@/views/WMS/historical-route'),
+    hidden: false
+  },
 
 ]
 

+ 55 - 36
src/views/WMS/historical-route/index.vue

@@ -8,7 +8,7 @@
             :data="tableData"
             height="250"
             border
-            style="width: 95%">
+            style="width: 97%">
             <el-table-column
             prop="billCode"
             label="单据号"
@@ -74,7 +74,13 @@ export default {
             resData:[],
             resX:[],
             resYTemperature:[],
-            resYHumidity:[]
+            resYHumidity:[],
+            carMessage:{
+                billCode: "",
+                plateNumber: "",
+                startTime: "",
+                endTime: ""
+            }
         };
     },
     mounted() {
@@ -130,17 +136,17 @@ export default {
         //查询按钮
         handleQuery() {
             // window.location.href = ''
-            this.handleGeocodeRepo();
+            this.handleGeocodeRepo(this.carMessage);
            
         },
-        handleGeocodeRepo() {
+        handleGeocodeRepo(data) {
 
-            let data = {
-                billCode: "CS01",
-                plateNumber: "湘A79D2R",
-                startTime: "2023-02-06",
-                endTime: "2023-02-08"
-            }
+            // let data = {
+            //     billCode: "CS01",
+            //     plateNumber: "湘A79D2R",
+            //     startTime: "2023-02-01",
+            //     endTime: "2023-02-02"
+            // }
 
             console.log(data, 'data');
             historyApi.queryAddress(data).then(res => {
@@ -155,39 +161,52 @@ export default {
                 let text;
                 let count = 0;
                 if (code == 200) {
-                    this.xData = res.data.temperature;
-                    for (let i = 1; i < data.length; i = i + Math.trunc((data.length / 9))) {
-                        // console.log("i",i)
-                        text += `&via[${count}][lnglat]=${data[i].gpsLongitude},${data[i].gpsLatitude}` ;
-                        this.resData[i] = res.data[i];
-                        this.resX[count] = res.data[i].hisDate;
-                        this.resYTemperature[count] = res.data[i].temperature;
-                        this.resYHumidity[count] = res.data[i].humidity / 100;
-                        count++;
+                    //定义经纬度不为0的数组[i]为起点
+                    for (let i = 0; i < data.length; i++) {
+                        if (data[i].gpsLatitude != 0 && data[i].gpsLongitude != 0) {
+                            //定义经纬度不为0的数组[j]为终点
+                            for	(let j = data.length - 1; j > i; j--) {
+                                if (data[j].gpsLatitude != 0 && data[j].gpsLongitude != 0) {
+                                    for (let z = i; z < j; z = z + Math.trunc((j - i) / 2)) {
+                                        // console.log("i",i)
+                                        text += `&via[${count}][id][${z}]&via[${count}][lnglat]=${data[z].gpsLongitude},${data[z].gpsLatitude}` ;
+                                        this.resData[count] = res.data[z];
+                                        this.resX[count] = res.data[z].hisDate;
+                                        this.resYTemperature[count] = res.data[z].temperature;
+                                        this.resYHumidity[count] = res.data[z].humidity / 100;
+                                        count++;
+                                    }
+                                    // this.position = data;
+                                    // let url = `//uri.amap.com/navigation?from=${data[0].gpsLongitude},${data[0].gpsLatitude},startpoint&to=${data[data.length-1].gpsLongitude},${data[data.length-1].gpsLatitude},endpoint&via=${data[260].gpsLongitude},${data[260].gpsLatitude},midwaypoint&mode=car&policy=0&src=mypage&coordinate=gaode&callnative=0`
+                                    let url = `https://ditu.amap.com/dir?type=car&policy=1&from[lnglat]=${data[i].gpsLongitude},${data[i].gpsLatitude}&from[name]=startpoint&from[id]=${i}-from&to[lnglat]=${data[j].gpsLongitude},${data[j].gpsLatitude}&to[name]=endpoint&to[id]=${i}-to${text}&src=mypage&callnative=0&platform=pc&innersrc=uriapi`
+                                    console.log(url, 'url---------------------');
+                                    this.url = url;
+                                    this.xData = res.data.temperature;
+                                    this.tableData = this.resData;
+                                    // window.location.href = url;
+                                    // window.open(url, "newWindow", "width=1000,height=1000");
+                                    // window.location.reload();
+                                    this.xData = this.resX;
+                                    this.temperatureData = this.resYTemperature;
+                                    this.humidityData = this.resYHumidity;
+                                    // console.log('this.xData',this.xData);
+                                    // console.log('this.temperatureData',this.temperatureData);
+                                    // console.log('this.humidityData',this.humidityData);
+                                    this.initEcharts();
+                                    console.log(text,'text')
+                                    return;
+                                }
+                            }
+                        }
                     }
-                    // this.position = data;
-                    // let url = `//uri.amap.com/navigation?from=${data[0].gpsLongitude},${data[0].gpsLatitude},startpoint&to=${data[data.length-1].gpsLongitude},${data[data.length-1].gpsLatitude},endpoint&via=${data[260].gpsLongitude},${data[260].gpsLatitude},midwaypoint&mode=car&policy=0&src=mypage&coordinate=gaode&callnative=0`
-                    let url = `https://ditu.amap.com/dir?type=car&policy=1&from[lnglat]=${data[1].gpsLongitude},${data[1].gpsLatitude}&from[name]=startpoint&from[id]=0-from&to[lnglat]=${data[data.length-1].gpsLongitude},${data[data.length-1].gpsLatitude}&to[name]=endpoint&to[id]=1-to&${text}&src=mypage&callnative=0&innersrc=uriapi`
-                    console.log(url, 'url---------------------');
-                    this.url = url;
-                    this.tableData = this.resData;
-                    // window.location.href = url;
-                    // window.open(url, "newWindow", "width=1000,height=1000");
-                    // window.location.reload();
-                    this.xData = this.resX;
-                    this.temperatureData = this.resYTemperature;
-                    this.humidityData = this.resYHumidity;
-                    // console.log('this.xData',this.xData);
-                    // console.log('this.temperatureData',this.temperatureData);
-                    // console.log('this.humidityData',this.humidityData);
-                    this.initEcharts();
                 }
             })
-
             // queryAddress({})
         }
     },
     created() {
+        console.log(this.$route.query,'this.$route')
+        this.carMessage = this.$route.query;
         this.handleQuery();
     }
 };