浏览代码

Merge branch 'develop' of http://39.106.8.246:3003/web/wanda-editer into develop

haojianlong 5 年之前
父节点
当前提交
62f24ac988

二进制
public/favicon.ico


+ 4 - 1
src/components/baseEditer.vue

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

+ 5 - 3
src/components/edit/attr_select.vue

@@ -243,7 +243,7 @@
 
 
     <div
     <div
       class="attr-select attr-select-bottom"
       class="attr-select attr-select-bottom"
-      v-if="type =='Zone' || type =='Image' ||type == 'fire-Zone' ||type == 'Line'"
+      v-if="type =='Zone' || type =='Image'||type == 'Line'"
     >
     >
       <a-spin :spinning="spinning">
       <a-spin :spinning="spinning">
       <div class="row">
       <div class="row">
@@ -475,11 +475,13 @@ export default {
   },
   },
   watch: {
   watch: {
     focusItemList: function(newval) {
     focusItemList: function(newval) {
-      console.log(newval);
       const Item = newval.itemList[0];
       const Item = newval.itemList[0];
       if (Item.data && Item.data.SubType) {
       if (Item.data && Item.data.SubType) {
         this.SubType = Item.data.SubType;
         this.SubType = Item.data.SubType;
+      }else{
+         this.SubType = '';
       }
       }
+       console.log('this.SubType',this.SubType);
       if (newval.itemList.length == 1) {
       if (newval.itemList.length == 1) {
         if (newval.itemType == "baseText") {
         if (newval.itemType == "baseText") {
           this.textMsg = Item.text;
           this.textMsg = Item.text;
@@ -512,7 +514,7 @@ export default {
           }
           }
         }
         }
       }
       }
-      let  location =[];
+      const  location =[];
       Item.data.AttachObjectIds.map(item=>{
       Item.data.AttachObjectIds.map(item=>{
         location.push(item.id)
         location.push(item.id)
       })
       })

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

@@ -190,7 +190,7 @@ export default {
       bus.$emit('changeScale', this.scale / oldScale)
       bus.$emit('changeScale', this.scale / oldScale)
     },
     },
     FocusItemChanged(itemMsg) {
     FocusItemChanged(itemMsg) {
-      this.focusItem = null; 
+      this.focusItem = null;
       this.alignmentOptions.forEach(el=>{
       this.alignmentOptions.forEach(el=>{
             el.disable = true
             el.disable = true
         })
         })
@@ -217,14 +217,13 @@ export default {
     },
     },
     // 删除item
     // 删除item
     deleteItem() {
     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(){
     publishMap(){

+ 147 - 16
src/components/mapClass/EditScence.ts

@@ -60,13 +60,21 @@ export class EditScence extends SGraphScene {
 
 
     /** 当前选中焦点Item */
     /** 当前选中焦点Item */
     focusItem: SGraphItem | null = null;
     focusItem: SGraphItem | null = null;
-
+    /** 当前选中焦点ItemList */
+    focusItemList:SGraphItem[] | null = null;
     /**图例节点 */
     /**图例节点 */
     Nodes: any = [];  // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
     Nodes: any = [];  // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
     /**图例节点 */  // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
     /**图例节点 */  // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
     Markers: any = [];
     Markers: any = [];
     /**  管线对象 */
     /**  管线对象 */
     Relations: any = [];
     Relations: any = [];
+    _isEditStatus: Boolean = true; // 是否可编辑
+    set isEditStatus(bol: Boolean): void {
+        this._isEditStatus = bol;
+    }
+    get isEditStatus(): Boolean {
+        return this._isEditStatus
+    }
     constructor() {
     constructor() {
         super();
         super();
         // // 选择绑定选额item事件
         // // 选择绑定选额item事件
@@ -96,7 +104,7 @@ export class EditScence extends SGraphScene {
      */
      */
     listChange(obj: any) {
     listChange(obj: any) {
         let itemType: string = 'equipment';
         let itemType: string = 'equipment';
-
+        this.focusItemList = obj.itemList;
         if (obj.itemList[0] instanceof STextMarkerItem) {
         if (obj.itemList[0] instanceof STextMarkerItem) {
             itemType = 'baseText'
             itemType = 'baseText'
         } else if (obj.itemList[0] instanceof SImageMarkerItem) {
         } else if (obj.itemList[0] instanceof SImageMarkerItem) {
@@ -122,6 +130,8 @@ export class EditScence extends SGraphScene {
         if (obj.itemList.length == 1) {
         if (obj.itemList.length == 1) {
             // 获取聚焦item
             // 获取聚焦item
             this.focusItem = obj.itemList[0]
             this.focusItem = obj.itemList[0]
+        }else{
+            this.focusItem = null
         }
         }
         let msg = {
         let msg = {
             itemList: obj.itemList,
             itemList: obj.itemList,
@@ -137,6 +147,13 @@ export class EditScence extends SGraphScene {
      * 增加线段item
      * 增加线段item
      */
      */
     addLine(event: SMouseEvent): boolean {
     addLine(event: SMouseEvent): boolean {
+        const clickItem = this.clickIsItem(event);
+        if (clickItem) {
+            let centerPoint = clickItem.boundingRect().center();
+            const p = clickItem.mapToScene(centerPoint.x, centerPoint.y);
+            event.x = p.x;
+            event.y = p.y;
+        }
         const data = {
         const data = {
             /** ID */
             /** ID */
             ID: uuid(),
             ID: uuid(),
@@ -225,7 +242,7 @@ export class EditScence extends SGraphScene {
         // 起始锚点
         // 起始锚点
         item.startAnchor = anc;
         item.startAnchor = anc;
         if (anc) {
         if (anc) {
-            anc.parent?.connect('changePos', item, item.changePos)
+            anc.parent ?.connect('changePos', item, item.changePos)
             item.anchor1ID = anc.id;
             item.anchor1ID = anc.id;
             item.node1Id = anc.parent.id;
             item.node1Id = anc.parent.id;
         }
         }
@@ -238,15 +255,13 @@ export class EditScence extends SGraphScene {
      */
      */
     addPolygonItem(event: SMouseEvent): void {
     addPolygonItem(event: SMouseEvent): void {
         const SubType = this._legend.SubType ? this._legend.SubType : '';
         const SubType = this._legend.SubType ? this._legend.SubType : '';
-        //获取信息工程化相关参数
-        const AttachObjectIds = this._legend.InfoLocal ? this._legend.InfoLocal : [];
         const LegendData: Legend = {
         const LegendData: Legend = {
             ID: uuid(),
             ID: uuid(),
             Name: this._legend.Name,
             Name: this._legend.Name,
             GraphElementType: this._legend.Type,
             GraphElementType: this._legend.Type,
             Num: 1,
             Num: 1,
             GraphElementId: this._legend.Id,
             GraphElementId: this._legend.Id,
-            AttachObjectIds: AttachObjectIds,
+            AttachObjectIds: [],
             Type: "Zone",
             Type: "Zone",
             Pos: { X: event.x, Y: event.y },
             Pos: { X: event.x, Y: event.y },
             OutLine: [{ X: event.x, Y: event.y }],
             OutLine: [{ X: event.x, Y: event.y }],
@@ -294,14 +309,13 @@ export class EditScence extends SGraphScene {
             //@ts-ignore
             //@ts-ignore
             item.isExtracted = true
             item.isExtracted = true
             const SubType = this._legend.SubType ? this._legend.SubType : '';
             const SubType = this._legend.SubType ? this._legend.SubType : '';
-            const AttachObjectIds = this._legend.InfoLocal ? this._legend.InfoLocal : [];
             const LegendData: Legend = {
             const LegendData: Legend = {
                 ID: uuid(),
                 ID: uuid(),
                 Name: this._legend.Name,
                 Name: this._legend.Name,
                 GraphElementType: this._legend.Type,
                 GraphElementType: this._legend.Type,
                 Num: 1,
                 Num: 1,
                 GraphElementId: this._legend.Id,
                 GraphElementId: this._legend.Id,
-                AttachObjectIds: AttachObjectIds,
+                AttachObjectIds: [],
                 Type: "Zone",
                 Type: "Zone",
                 Pos: { X: item.x, Y: item.y },
                 Pos: { X: item.x, Y: item.y },
                 OutLine: item.pointArr[0],
                 OutLine: item.pointArr[0],
@@ -409,15 +423,14 @@ export class EditScence extends SGraphScene {
      * 增加图标lenged图标
      * 增加图标lenged图标
      */
      */
     addIconItem(event: SMouseEvent): void {
     addIconItem(event: SMouseEvent): void {
-           //获取信息工程化相关参数
-        const AttachObjectIds = this._legend.InfoLocal ? this._legend.InfoLocal : [];
+        //获取信息工程化相关参数
         const LegendData: Legend = {
         const LegendData: Legend = {
             ID: uuid(),
             ID: uuid(),
             Name: this._legend.Name,
             Name: this._legend.Name,
             GraphElementType: this._legend.Type,
             GraphElementType: this._legend.Type,
             Num: 1,
             Num: 1,
             GraphElementId: this._legend.Id,
             GraphElementId: this._legend.Id,
-            AttachObjectIds: AttachObjectIds,
+            AttachObjectIds: [],
             Pos: { X: event.x, Y: event.y },
             Pos: { X: event.x, Y: event.y },
             Scale: { X: 1, Y: 1, Z: 1 },          // 缩放
             Scale: { X: 1, Y: 1, Z: 1 },          // 缩放
             Rolate: { X: 0, Y: 0, Z: 0 },
             Rolate: { X: 0, Y: 0, Z: 0 },
@@ -430,6 +443,7 @@ export class EditScence extends SGraphScene {
                 sHeight: 24,   //icon 的高
                 sHeight: 24,   //icon 的高
                 font: 12,    //font
                 font: 12,    //font
                 color: '',  //字体颜色
                 color: '',  //字体颜色
+                GraphCategoryId: this._legend.GraphCategoryId
             },
             },
         }
         }
         const item = new SImageLegendItem(null, LegendData);
         const item = new SImageLegendItem(null, LegendData);
@@ -649,10 +663,10 @@ export class EditScence extends SGraphScene {
         }
         }
     }
     }
 
 
-   /**
-    * 更新工程信息化的相关数据
-    * @param AttachObjectIds Array
-    */
+    /**
+     * 更新工程信息化的相关数据
+     * @param AttachObjectIds Array
+     */
     upadatAttachObjectIds(AttachObjectIds: []): void {
     upadatAttachObjectIds(AttachObjectIds: []): void {
         if (this.focusItem) {
         if (this.focusItem) {
             this.focusItem.data.AttachObjectIds = AttachObjectIds;
             this.focusItem.data.AttachObjectIds = AttachObjectIds;
@@ -706,6 +720,46 @@ export class EditScence extends SGraphScene {
                 }
                 }
                 this.scenceUpdate(this);
                 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) { }
     scenceUpdate(scence: any) { }
@@ -776,6 +830,9 @@ export class EditScence extends SGraphScene {
     ////////////////////////
     ////////////////////////
     //  以下为鼠标键盘操作事件
     //  以下为鼠标键盘操作事件
     onMouseDown(event: SMouseEvent): any {
     onMouseDown(event: SMouseEvent): any {
+        if (!this.isEditStatus) {
+            return super.onMouseDown(event);
+        }
         // 判断是否开启吸附,并且有吸附的点
         // 判断是否开启吸附,并且有吸附的点
         if (
         if (
             this.isAbsorbing &&
             this.isAbsorbing &&
@@ -822,6 +879,9 @@ export class EditScence extends SGraphScene {
     }
     }
 
 
     onMouseMove(event: SMouseEvent): boolean {
     onMouseMove(event: SMouseEvent): boolean {
+        if (!this.isEditStatus) {
+            return super.onMouseMove(event);
+        }
         if (this.isAbsorbing) {
         if (this.isAbsorbing) {
             if (!this.highLight) {
             if (!this.highLight) {
                 this.highLight = new HighlightItem(null);
                 this.highLight = new HighlightItem(null);
@@ -840,8 +900,20 @@ export class EditScence extends SGraphScene {
      * @return	boolean
      * @return	boolean
      */
      */
     onKeyDown(event: KeyboardEvent): any {
     onKeyDown(event: KeyboardEvent): any {
+        if (!this.isEditStatus) {
+            return super.onKeyDown(event);
+        }
         if (this.grabItem) {
         if (this.grabItem) {
             this.grabItem.onKeyDown(event);
             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.key == "Enter") {
         // if (event.key == "Enter") {
         //     this.cmd = 0
         //     this.cmd = 0
@@ -849,6 +921,22 @@ export class EditScence extends SGraphScene {
         return false
         return false
     }
     }
 
 
+
+    /**
+     * 鼠标双击事件
+     *
+     * @param	event         事件参数
+     * @return	boolean
+     */
+    onDoubleClick(event: SMouseEvent): boolean {
+        if (!this.isEditStatus) {
+            return true
+        }else{
+           return super.onDoubleClick(event);
+        }
+
+    } // Function onDoubleClick()
+
     /**
     /**
      * 设置结束锚点
      * 设置结束锚点
      *
      *
@@ -864,7 +952,7 @@ export class EditScence extends SGraphScene {
                     event.y = p.y;
                     event.y = p.y;
                     if (this.grabItem.pointList.length) {
                     if (this.grabItem.pointList.length) {
                         this.grabItem.endAnchor = anc;
                         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.anchor2ID = anc.id
                     this.grabItem.node2Id = anc.parent.id
                     this.grabItem.node2Id = anc.parent.id
@@ -915,6 +1003,49 @@ export class EditScence extends SGraphScene {
     }
     }
 
 
     /**
     /**
+     *  划线时点击位置是在文本,图片,,区域内
+     *
+     *  @param  event   事件
+     *  @return 点击的item
+     * */
+    clickIsItem(event: SMouseEvent): SGraphItem | null {
+        let minIten = null;
+        let len: number = -1;
+        let itemList = this.Nodes.concat(this.Markers);
+        itemList.forEach(item => {
+            if (
+                item instanceof STextMarkerItem ||
+                item instanceof SImageMarkerItem ||
+                item instanceof SZoneLegendItem ||
+                item instanceof SFHFQZoneLegendItem ||
+                item instanceof SSCPZZoneLegendItem
+            ) {
+                let scenePoint = item.mapFromScene(event.x, event.y);
+                if (item.contains(scenePoint.x, scenePoint.y)) {
+                    let dis = SMathUtil.pointDistance(
+                        scenePoint.x,
+                        scenePoint.y,
+                        item.boundingRect().center().x,
+                        item.boundingRect().center().y
+                    );
+                    if (len < 0) {
+                        minIten = item;
+                        len = dis;
+                    }
+                    if (dis < len) {
+                        minIten = item;
+                        len = dis;
+                    }
+                }
+            }
+        })
+        console.log('-----------------------')
+        console.log(minIten)
+        console.log('-----------------------')
+        return minIten;
+    }
+
+    /**
       *  点是否在吸附区域内
       *  点是否在吸附区域内
       *
       *
       *  @param  p       要判断的点
       *  @param  p       要判断的点

+ 27 - 0
src/lib/items/SLineMarkerItem.ts

@@ -10,6 +10,11 @@ import { Marker } from '../types/Marker';
  * * @author  张宇(taohuzy@163.com)
  * * @author  张宇(taohuzy@163.com)
  */
  */
 export class SLineMarkerItem extends SLineItem {
 export class SLineMarkerItem extends SLineItem {
+     /** 起始锚点  */
+    startItem: SGraphItem | null = null;
+    /** 结束锚点  */
+    endItem: SGraphItem | null = null;
+
     /** 标识对象数据 */
     /** 标识对象数据 */
     data: Marker;
     data: Marker;
 
 
@@ -57,6 +62,22 @@ export class SLineMarkerItem extends SLineItem {
         }
         }
     } // Constructor
     } // Constructor
 
 
+    /** 接收事件作出修改  */
+    changePos() {
+        if (this.startItem) {
+            // 判断删除equip后,不移动
+            if (this.startItem.parent) {
+                this.line[0] = this.startItem.mapToScene(0, 0);
+            }
+        }
+        if (this.endItem) {
+            // 删除equip后
+            if (this.endItem.parent) {
+                this.line[1] = this.endItem.mapToScene(0, 0);
+            }
+        }
+    }
+
     toData(): Marker {
     toData(): Marker {
         this.data.Pos = { X: this.x, Y: this.y };
         this.data.Pos = { X: this.x, Y: this.y };
         this.data.Properties.Line = this.line.map(pos => {
         this.data.Properties.Line = this.line.map(pos => {
@@ -68,6 +89,12 @@ export class SLineMarkerItem extends SLineItem {
         this.data.Properties.LineWidth = this.lineWidth;
         this.data.Properties.LineWidth = this.lineWidth;
         this.data.Properties.StrokeColor = this.strokeColor.value;
         this.data.Properties.StrokeColor = this.strokeColor.value;
         this.data.Properties.LineStyle = this.lineStyle;
         this.data.Properties.LineStyle = this.lineStyle;
+        if (this.startItem && this.startItem.parent) {
+            this.data.Properties.StartItemId = this.startItem.id;
+        }
+        if (this.endItem && this.endItem.parent) {
+            this.data.Properties.EndItemId = this.endItem.id;
+        }
         return this.data;
         return this.data;
     }
     }