浏览代码

回放时控制飞机的隐藏的显示

Rmengdi 22 小时之前
父节点
当前提交
697472baf5
共有 1 个文件被更改,包括 79 次插入2 次删除
  1. 79 2
      uavps-web/src/views/system/task/index.vue

+ 79 - 2
uavps-web/src/views/system/task/index.vue

@@ -1653,9 +1653,30 @@ export default {
       } else {
         // 每次更新
         const newData = data.targetAircraft[0].aircrafts;
+        let isHide = false,
+          targetDataKeys,
+          flagCount = 0;
+        if (this.title == "回放") {
+          targetDataKeys = Object.keys(this.targetDataR);
+          const count = targetDataKeys.length;
+          // 当存的数据大于返回数据时,证明有数据隐藏
+          if (count > newData.length) {
+            isHide = true;
+          }
+        }
         for (let i = 0; i < newData.length; i++) {
           const id = newData[i].aircraftNumber;
           const targetUav = this.targetDataR[`${id}`];
+          if (this.title == "回放" && isHide) {
+            targetDataKeys.splice(
+              targetDataKeys.findIndex((item) => item === id),
+              1
+            );
+            flagCount++;
+            if (flagCount == newData.length) {
+              this.delHideAir(targetDataKeys);
+            }
+          }
           if (targetUav) {
             targetUav.x = newData[i].coordinateX;
             targetUav.y = newData[i].coordinateY;
@@ -1781,8 +1802,6 @@ export default {
       const targetTexture = new PIXI.Texture.from(uavTarPNG);
       const group = new PIXI.Container();
       group.id = data.aircraftNumber;
-      group.buttonMode = true; // 鼠标悬停时显示手型
-      group.interactive = true;
 
       // 创建无人机
       const dude = new PIXI.Sprite(targetTexture);
@@ -1828,6 +1847,8 @@ export default {
       group.addChild(text);
       if (isZhen) {
         group.typeName = "zhenshi";
+        group.buttonMode = true; // 鼠标悬停时显示手型
+        group.interactive = true;
         this.targetDataR[`${id}`] = dude;
         this.targetUavCircleR[`${id}`] = circle;
         this.targetUavCircleNumR[`${id}`] = text;
@@ -1853,6 +1874,40 @@ export default {
       }
     },
 
+    // 删除回放时隐藏的飞机
+    delHideAir(targetDataKeys) {
+      const hideId = targetDataKeys[0];
+      let group = [];
+      this.pixiApp.stage.children.forEach((child) => {
+        // 检查 child 是否是 Container 类型
+        if (child instanceof PIXI.Container) {
+          if (child.id == hideId) {
+            group.push(child);
+          }
+        }
+      });
+      group.forEach((child) => {
+        if (!(child instanceof PIXI.Graphics)) {
+          if (child.parent) {
+            child.parent.removeChild(child);
+          }
+          child.destroy();
+          if (this.targetDataR[hideId]) {
+            delete this.targetDataR[hideId];
+          }
+          if (this.targetLblAry[hideId]) {
+            delete this.targetLblAry[hideId];
+          }
+          const idx = this.allSpriteInfo.findIndex((info) => {
+            return info.id == hideId;
+          });
+          if (idx > -1) {
+            this.allSpriteInfo.splice(idx, 1);
+          }
+        }
+      });
+    },
+
     // 无人机集群 噪音数据
     showTargetNAircraft(data) {
       const targetData = data.targetAircraft[0];
@@ -1867,9 +1922,31 @@ export default {
       } else {
         // 每次更新
         const newData = data.targetAircraft[0].aircrafts;
+        let isHide = false,
+          targetDataKeys,
+          flagCount = 0;
+        if (this.title == "回放") {
+          targetDataKeys = Object.keys(this.targetDataR);
+          const count = targetDataKeys.length;
+          // 当存的数据大于返回数据时,证明有数据隐藏
+          if (count > newData.length) {
+            isHide = true;
+          }
+        }
         for (let i = 0; i < newData.length; i++) {
           const id = newData[i].aircraftNumber;
           const targetUav = this.targetDataN[`${id}`];
+          // 有隐藏的话要删除飞机
+          if (this.title == "回放" && isHide) {
+            targetDataKeys.splice(
+              targetDataKeys.findIndex((item) => item === id),
+              1
+            );
+            flagCount++;
+            if (flagCount == newData.length) {
+              this.delHideAir(targetDataKeys);
+            }
+          }
           if (targetUav) {
             targetUav.x = newData[i].coordinateX;
             targetUav.y = newData[i].coordinateY;