Jelajahi Sumber

feat:批量删除

YaolongHan 4 tahun lalu
induk
melakukan
ba959814a4

+ 4 - 1
src/components/baseEditer.vue

@@ -311,7 +311,10 @@ export default {
           Message.close()
           this.graphId = res.Data;
         }).catch((err)=>{
-
+         Message({
+          message: '上传失败!',
+          type: 'error'
+        });
         })
       });
       bus.$on("exportByKey", val => {

+ 8 - 9
src/components/edit/top_toolbar.vue

@@ -190,7 +190,7 @@ export default {
       bus.$emit('changeScale', this.scale / oldScale)
     },
     FocusItemChanged(itemMsg) {
-      this.focusItem = null; 
+      this.focusItem = null;
       this.alignmentOptions.forEach(el=>{
             el.disable = true
         })
@@ -217,14 +217,13 @@ export default {
     },
     // 删除item
     deleteItem() {
-      console.log(this.focusItem);
-      if (this.focusItem) {
-        bus.$emit("deleiteItem");
-        // this.focusItem = null;
-        this.$message.success("删除成功", 1);
-      } else {
-        this.$message.error("请选择指定对象!", 1);
-      }
+      bus.$emit("deleiteItem");
+      // if (this.focusItem) {
+      //   bus.$emit("deleiteItem");
+      //   this.$message.success("删除成功", 1);
+      // } else {
+      //   this.$message.error("请选择指定对象!", 1);
+      // }
     },
     // 发布图例
     publishMap(){

+ 92 - 24
src/components/mapClass/EditScence.ts

@@ -60,19 +60,20 @@ export class EditScence extends SGraphScene {
 
     /** 当前选中焦点Item */
     focusItem: SGraphItem | null = null;
-
+    /** 当前选中焦点ItemList */
+    focusItemList:SGraphItem[] | null = null;
     /**图例节点 */
     Nodes: any = [];  // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
     /**图例节点 */  // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
     Markers: any = [];
     /**  管线对象 */
     Relations: any = [];
-    _isEditStatus:Boolean = true; // 是否可编辑
-    set isEditStatus(bol:Boolean):void{
-      this._isEditStatus = bol;
+    _isEditStatus: Boolean = true; // 是否可编辑
+    set isEditStatus(bol: Boolean): void {
+        this._isEditStatus = bol;
     }
-    get isEditStatus():Boolean{
-      return this._isEditStatus
+    get isEditStatus(): Boolean {
+        return this._isEditStatus
     }
     constructor() {
         super();
@@ -103,7 +104,7 @@ export class EditScence extends SGraphScene {
      */
     listChange(obj: any) {
         let itemType: string = 'equipment';
-
+        this.focusItemList = obj.itemList;
         if (obj.itemList[0] instanceof STextMarkerItem) {
             itemType = 'baseText'
         } else if (obj.itemList[0] instanceof SImageMarkerItem) {
@@ -129,6 +130,8 @@ export class EditScence extends SGraphScene {
         if (obj.itemList.length == 1) {
             // 获取聚焦item
             this.focusItem = obj.itemList[0]
+        }else{
+            this.focusItem = null
         }
         let msg = {
             itemList: obj.itemList,
@@ -239,7 +242,7 @@ export class EditScence extends SGraphScene {
         // 起始锚点
         item.startAnchor = anc;
         if (anc) {
-            anc.parent?.connect('changePos', item, item.changePos)
+            anc.parent ?.connect('changePos', item, item.changePos)
             item.anchor1ID = anc.id;
             item.node1Id = anc.parent.id;
         }
@@ -420,7 +423,7 @@ export class EditScence extends SGraphScene {
      * 增加图标lenged图标
      */
     addIconItem(event: SMouseEvent): void {
-           //获取信息工程化相关参数
+        //获取信息工程化相关参数
         const LegendData: Legend = {
             ID: uuid(),
             Name: this._legend.Name,
@@ -440,7 +443,7 @@ export class EditScence extends SGraphScene {
                 sHeight: 24,   //icon 的高
                 font: 12,    //font
                 color: '',  //字体颜色
-                GraphCategoryId:this._legend.GraphCategoryId
+                GraphCategoryId: this._legend.GraphCategoryId
             },
         }
         const item = new SImageLegendItem(null, LegendData);
@@ -660,10 +663,10 @@ export class EditScence extends SGraphScene {
         }
     }
 
-   /**
-    * 更新工程信息化的相关数据
-    * @param AttachObjectIds Array
-    */
+    /**
+     * 更新工程信息化的相关数据
+     * @param AttachObjectIds Array
+     */
     upadatAttachObjectIds(AttachObjectIds: []): void {
         if (this.focusItem) {
             this.focusItem.data.AttachObjectIds = AttachObjectIds;
@@ -717,6 +720,46 @@ export class EditScence extends SGraphScene {
                 }
                 this.scenceUpdate(this);
             }
+        }else{
+            //批量删除
+            if(!this.focusItemList){
+                return
+            }
+            this.focusItemList.forEach((focusItem)=>{
+                this.removeItem(focusItem);
+                let a = -1
+                this.Nodes.forEach((item: any, index: number) => {
+                    if (item.id == focusItem.id) {
+                        a = index
+                    }
+                });
+                if (a > -1) {
+                    this.Nodes.splice(a, 1);
+                }
+                let b = -1;
+                this.Markers.forEach((item: any, index: number) => {
+                    if (item.id == focusItem.id) {
+                        b = index
+                    }
+                });
+                if (b > -1) {
+                    this.Markers.splice(b, 1);
+                }
+                let c = -1;
+                this.Relations.forEach((item: any, index: number) => {
+                    if (item.id == focusItem.id) {
+                        c = index
+                    }
+                });
+                if (c > -1) {
+                    this.Relations.splice(c, 1);
+                }
+            });
+            this.focusItemList = [];
+            if (this.view) {
+                this.view.update();
+            }
+            this.scenceUpdate(this);
         }
     }
     scenceUpdate(scence: any) { }
@@ -787,6 +830,9 @@ export class EditScence extends SGraphScene {
     ////////////////////////
     //  以下为鼠标键盘操作事件
     onMouseDown(event: SMouseEvent): any {
+        if (!this.isEditStatus) {
+            return super.onMouseDown(event);
+        }
         // 判断是否开启吸附,并且有吸附的点
         if (
             this.isAbsorbing &&
@@ -833,6 +879,9 @@ export class EditScence extends SGraphScene {
     }
 
     onMouseMove(event: SMouseEvent): boolean {
+        if (!this.isEditStatus) {
+            return super.onMouseMove(event);
+        }
         if (this.isAbsorbing) {
             if (!this.highLight) {
                 this.highLight = new HighlightItem(null);
@@ -851,16 +900,19 @@ export class EditScence extends SGraphScene {
      * @return	boolean
      */
     onKeyDown(event: KeyboardEvent): any {
+        if (!this.isEditStatus) {
+            return super.onKeyDown(event);
+        }
         if (this.grabItem) {
             this.grabItem.onKeyDown(event);
-            if(event.code == "Escape"){
-               const item = this.grabItem;
-               this.grabItem = null
-               this.removeItem(item);
-               if(this.view){
-                   this.view.update()
-               }
-               this.setCmd = 'choice'
+            if (event.code == "Escape") {
+                const item = this.grabItem;
+                this.grabItem = null
+                this.removeItem(item);
+                if (this.view) {
+                    this.view.update()
+                }
+                this.setCmd = 'choice'
             }
         }
         // if (event.key == "Enter") {
@@ -869,6 +921,22 @@ export class EditScence extends SGraphScene {
         return false
     }
 
+
+    /**
+     * 鼠标双击事件
+     *
+     * @param	event         事件参数
+     * @return	boolean
+     */
+    onDoubleClick(event: SMouseEvent): boolean {
+        if (!this.isEditStatus) {
+            return true
+        }else{
+           return super.onDoubleClick(event);
+        }
+
+    } // Function onDoubleClick()
+
     /**
      * 设置结束锚点
      *
@@ -884,7 +952,7 @@ export class EditScence extends SGraphScene {
                     event.y = p.y;
                     if (this.grabItem.pointList.length) {
                         this.grabItem.endAnchor = anc;
-                        anc.parent?.connect('changePos', this.grabItem, this.grabItem.changePos)
+                        anc.parent ?.connect('changePos', this.grabItem, this.grabItem.changePos)
                     }
                     this.grabItem.anchor2ID = anc.id
                     this.grabItem.node2Id = anc.parent.id
@@ -946,7 +1014,7 @@ export class EditScence extends SGraphScene {
         let itemList = this.Nodes.concat(this.Markers);
         itemList.forEach(item => {
             if (
-                item instanceof STextMarkerItem || 
+                item instanceof STextMarkerItem ||
                 item instanceof SImageMarkerItem ||
                 item instanceof SZoneLegendItem ||
                 item instanceof SFHFQZoneLegendItem ||