Răsfoiți Sursa

自定义编队在增加的时候删除问题

Rmengdi 3 luni în urmă
părinte
comite
ef22e0b27a
1 a modificat fișierele cu 32 adăugiri și 27 ștergeri
  1. 32 27
      uavps-web/src/views/system/task/index.vue

+ 32 - 27
uavps-web/src/views/system/task/index.vue

@@ -596,12 +596,8 @@
           </el-form-item>
         </el-form>
         <div class="demo-drawer__footer">
-          <el-button
-            type="danger"
-            :disabled="this.addOrUpdate == 'add'"
-            @click="canvasInfoDel"
-            >删 除</el-button
-          >
+          <el-button type="danger" @click="canvasInfoDel">删 除</el-button>
+          <!-- :disabled="this.addOrUpdate == 'add'" -->
           <el-button type="primary" @click="handleDrawerSubmit"
             >确 定</el-button
           >
@@ -2305,29 +2301,38 @@ export default {
       this.$modal
         .confirm("是否确认删除该无人机")
         .then(() => {
-          this.formationInfoForm = this.ObjectStringToNumber(
-            this.formationInfoForm
-          );
-          let index = this.formationInfoList.findIndex(
-            (item) => item.number == this.formationInfoForm.number
-          );
-          if (index > -1) {
-            this.formationInfoAirDataList =
-              this.formationInfoAirDataList.filter((item) => {
-                return item.id !== this.formationInfoForm.number;
-              });
-            this.formationAirPiXiApp.stage.children.forEach((child, index) => {
-              // 检查 child 是否是 Container 类型
-              if (child instanceof PIXI.Sprite) {
-                if (child.id == this.formationInfoForm.number) {
-                  if (child.parent) {
-                    child.parent.removeChild(child);
+          if (this.addOrUpdate == "add") {
+            // 增加的时候要删除
+            const len = this.formationAirPiXiApp.stage.children.length;
+            this.formationAirPiXiApp.stage.children[len - 1].destroy();
+            return;
+          } else {
+            this.formationInfoForm = this.ObjectStringToNumber(
+              this.formationInfoForm
+            );
+            let index = this.formationInfoList.findIndex(
+              (item) => item.number == this.formationInfoForm.number
+            );
+            if (index > -1) {
+              this.formationInfoAirDataList =
+                this.formationInfoAirDataList.filter((item) => {
+                  return item.id !== this.formationInfoForm.number;
+                });
+              this.formationAirPiXiApp.stage.children.forEach(
+                (child, index) => {
+                  // 检查 child 是否是 Container 类型
+                  if (child instanceof PIXI.Sprite) {
+                    if (child.id == this.formationInfoForm.number) {
+                      if (child.parent) {
+                        child.parent.removeChild(child);
+                      }
+                      child.destroy();
+                    }
                   }
-                  child.destroy();
                 }
-              }
-            });
-            this.formationInfoList.splice(index, 1);
+              );
+              this.formationInfoList.splice(index, 1);
+            }
           }
         })
         .then(() => {