xyh 1 rok temu
rodzic
commit
455651ee30
1 zmienionych plików z 24 dodań i 13 usunięć
  1. 24 13
      src/views/simulation/index.vue

+ 24 - 13
src/views/simulation/index.vue

@@ -204,15 +204,15 @@ export default {
           this.save = true
           this.jsonData = {
             id: row.id,
-            xdname: row.xdname,
-            type: row.type,
+            xdname: response.data.xdname,
+            type: response.data.type,
             // creator: row.creator,
-            createtime: row.createtime,
-            bluecnt: row.bluecnt,
-            target: row.target,
-            starttime: row.starttime,
-            steptime: row.steptime,
-            endtime: row.endtime,
+            createtime: response.data.createtime,
+            bluecnt: response.data.bluecnt,
+            target: response.data.target,
+            starttime: response.data.starttime,
+            steptime: response.data.steptime,
+            endtime: response.data.endtime,
             blueunit: blueunit,
             redunit: redunit,
             satellite: satellite,
@@ -751,7 +751,7 @@ export default {
           currentTime,
           this.viewer2D.clock.startTime
         ); // 获取从起始时间到当前时间的秒数
-        if (parseInt(elapsedTime) % stepTime === 0) {
+        if (parseInt(elapsedTime) % stepTime === 0 && elapsedTime!=0) {
           console.log('elapsedTime :>> ', elapsedTime);
           // 当从起始时间到当前时间的秒数是 stepTime 的倍数时,发送请求
           this.requestDataAndUpdateModel2D(startTime, elapsedTime);
@@ -763,7 +763,7 @@ export default {
           currentTime,
           this.viewer2D.clock.startTime
         ); // 获取从起始时间到当前时间的秒数
-        if (parseInt(elapsedTime) % stepTime === 0) {
+        if (parseInt(elapsedTime) % stepTime === 0 && elapsedTime!=0) {
           console.log('elapsedTime :>> ', elapsedTime);
           // 当从起始时间到当前时间的秒数是 stepTime 的倍数时,发送请求
           this.requestDataAndUpdateModel3D(startTime, elapsedTime);
@@ -773,17 +773,28 @@ export default {
     },
     // 初始化stk方法,生成轨迹文件
     async initSTK() {
-    
+      console.log('this.jsonData :>> ', this.jsonData);
+      // await axios
+      //   .get("/api", this.jsonData).then(res=>{
+      //     console.log('res :>> ', res);
+      //   })
+      await axios
+        .post("/api/traj", this.jsonData).then(res=>{
+          console.log('res :>> ', res);
+        })
 
     },
     // 根据时间参数请求模型位置并更新 2D
-    requestDataAndUpdateModel2D(startTime, elapsedTime) {
+    async requestDataAndUpdateModel2D(startTime, elapsedTime) {
       const jsDate = new Date(startTime);
       // 增加 elapsedTime 秒
       jsDate.setSeconds(jsDate.getSeconds() + elapsedTime);
       // 转换为需求字符串格式
       const newTimeString = `${jsDate.getFullYear()}-${(jsDate.getMonth() + 1).toString().padStart(2, '0')}-${jsDate.getDate().toString().padStart(2, '0')} ${jsDate.getHours().toString().padStart(2, '0')}:${jsDate.getMinutes().toString().padStart(2, '0')}:${jsDate.getSeconds().toString().padStart(2, '0')}`;
-   
+      await axios
+        .post("/api/pos", {simulation_time: newTimeString+'.000'}).then(res=>{
+          console.log('res :>> ', res);
+        })
     },
      // 根据时间参数请求模型位置并更新 3D
      requestDataAndUpdateModel3D(startTime, elapsedTime) {