Procházet zdrojové kódy

增加起点终点的取值逻辑

DongZ před 2 roky
rodič
revize
70deaee654
3 změnil soubory, kde provedl 43 přidání a 29 odebrání
  1. 1 1
      src/permission.js
  2. 6 1
      src/router/index.js
  3. 36 27
      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
+  },
 
 ]
 

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

@@ -138,8 +138,8 @@ export default {
             let data = {
                 billCode: "CS01",
                 plateNumber: "湘A79D2R",
-                startTime: "2023-02-06",
-                endTime: "2023-02-08"
+                startTime: "2023-02-01",
+                endTime: "2023-02-02"
             }
 
             console.log(data, 'data');
@@ -155,32 +155,41 @@ 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++;
+                    for (let i = 0; i < data.length; i++) {
+                        if (data[i].gpsLatitude != 0 && data[i].gpsLongitude != 0) {
+                            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 / 10)) {
+                                        // console.log("i",i)
+                                        text += `&via[${count}][lnglat]=${data[z].gpsLongitude},${data[z].gpsLatitude}` ;
+                                        this.resData[z] = 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&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();
+                                    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();
                 }
             })