Explorar el Código

Merge remote-tracking branch 'origin/develop' into develop

xiebeibei hace 4 años
padre
commit
dfc7a49946

+ 3 - 3
src/components/baseEditer.vue

@@ -87,9 +87,9 @@ export default {
       }
     };
     // 自动保存(时间差为一分钟)
-    this.autoSave = setInterval(() => {
-      this.saveMsgNoMessage();
-    }, 60000);
+    // this.autoSave = setInterval(() => {
+    //   this.saveMsgNoMessage();
+    // }, 60000);
   },
   methods: {
     init() {

+ 140 - 0
src/components/mapClass/EditScence.ts

@@ -24,6 +24,7 @@ import { SMathUtil } from '@saga-web/big/lib/utils/SMathUtil';
 import { MinDis } from '@saga-web/big/lib/types/MinDis';
 import { HighlightItem } from '@/lib/items/HighlightItem';
 import { TimeSelect } from 'element-ui';
+import { STopologyParser } from '@/lib/parsers/STopologyParser';
 /**
  * 在线绘图
  *
@@ -80,6 +81,14 @@ export class EditScence extends SGraphScene {
     get isEditStatus(): Boolean {
         return this._isEditStatus
     }
+
+    //复制粘贴
+    copyString = {
+        Nodes: [],
+        Markers: [],
+        Relations: []
+    };
+
     constructor() {
         super();
         // // 选择绑定选额item事件
@@ -454,6 +463,7 @@ export class EditScence extends SGraphScene {
                 InfoLocal: this._legend.InfoLocal.length ? this._legend.InfoLocal : []
             },
         }
+        const cmd = this.cmd;
         const item = new SImageLegendItem(null, LegendData);
         this.cmd = 'choice';
         item.selectable = true;
@@ -464,6 +474,9 @@ export class EditScence extends SGraphScene {
         this.focusItem = item;
         this.finishCreated(item);
         this.scenceUpdate(this);
+        if (event.ctrlKey) {
+            this.cmd = cmd;
+        }
     }
 
     /**
@@ -1068,9 +1081,136 @@ export class EditScence extends SGraphScene {
         if (event.code == 'Delete') {
             this.deleiteItem()
         }
+        // 复制粘贴
+        if (event.ctrlKey && !event.repeat) { 
+            if (event.code == 'KeyC') {
+                console.log('ctrl c')
+                this.copy()
+            } else if (event.code == 'KeyV') {
+                console.log('ctrl v')
+                this.paste()
+            }
+        }
         return false
     }
 
+    /**
+     * 复制
+     *
+     */
+    copy(){
+        // const input = document.createElement('input');
+        // console.log(1111111111111111111)
+        // input.value = 'sfsfsfsf'
+        // document.body.appendChild(input);
+        // input.select()
+        // document.execCommand('copy');
+        // input.style.display='none';
+        if (this.selectContainer.itemList.length) {
+            this.copyString = {
+                Nodes: [],
+                Markers: [],
+                Relations: []
+            };
+            this.selectContainer.itemList.forEach(t => {
+                const type = this.itemToType(t);
+                if (type) {
+                    const data = JSON.parse(JSON.stringify(t.toData()))
+                    data.ID = ''
+                    if (data.Type == 'Image') {
+                        data.AnchorList = []
+                    }
+                    this.copyString[type].push(data)
+                }
+            })
+            console.log(this.copyString)
+        }
+    }
+    
+    /**
+     * 粘贴
+     *
+     */
+    paste(){
+        const parserData = new STopologyParser(null);
+        // 需要深拷贝
+        parserData.parseData(JSON.parse(JSON.stringify(this.copyString)))
+        // 不需要复制区域
+        // parserData.zoneLegendList.forEach(t => {
+        //     if (this.view) {
+        //         t.pos.x += 10 / this.view.scale
+        //         t.pos.y += 10 / this.view.scale
+        //     }
+        //     this.addItem(t)
+        // // 加到node
+        // // 加命令
+        // })
+        parserData.imageLegendList.forEach(t => {
+            if (this.view) {
+                t.pos.x += 10 / this.view.scale
+                t.pos.y += 10 / this.view.scale
+            }
+            this.addItem(t)
+            this.Nodes.push(t);
+        })
+        parserData.imageMarkerList.forEach(t => {
+            if (this.view) {
+                t.pos.x += 10 / this.view.scale
+                t.pos.y += 10 / this.view.scale
+            }
+            this.addItem(t)
+            this.Markers.push(t);
+        })
+        parserData.lineMarkerList.forEach(t => {
+            if (this.view) {
+                t.pos.x += 10 / this.view.scale
+                t.pos.y += 10 / this.view.scale
+            }
+            this.addItem(t)
+            this.Markers.push(t);
+        })
+        parserData.textMarkerList.forEach(t => {
+            if (this.view) {
+                t.pos.x += 10 / this.view.scale
+                t.pos.y += 10 / this.view.scale
+            }
+            this.addItem(t)
+            this.Markers.push(t);
+        })
+        parserData.relationList.forEach(t => {
+            if (this.view) {
+                t.pos.x += 10 / this.view.scale
+                t.pos.y += 10 / this.view.scale
+                t.moveToOrigin(t.pos.x, t.pos.y)
+            }
+            this.addItem(t)
+            this.Relations.push(t);
+        })
+        this.scenceUpdate(this);
+    }
+
+    /** 类型转换    */
+    itemToType(obj:SGraphItem):String{
+        if (obj instanceof STextMarkerItem) {
+            return 'Markers'
+        } else if (obj instanceof SImageMarkerItem) {
+            return 'Markers'
+        } else if (obj instanceof SLineMarkerItem) {
+            return 'Markers'
+        } else if (obj instanceof SZoneLegendItem) {
+            return 'Nodes'
+        } else if (obj instanceof SFHFQZoneLegendItem) {
+            return 'Nodes'
+        } else if (obj instanceof SSCPZZoneLegendItem) {
+            return 'Nodes'
+        } else if (obj instanceof SImageLegendItem) {
+            return 'Nodes'
+        } else if (obj instanceof TipelineItem) {
+            return 'Relations'
+        }
+        return '';
+    }
+
 
     /**
      * 鼠标双击事件

+ 4 - 1
src/lib/items/SFHFQZoneLegendItem.ts

@@ -3,7 +3,7 @@ import { SGraphItem, SLineStyle, STextOrigin } from "@saga-web/graph/lib";
 import { Legend } from '../types/Legend';
 import { SPainter, SColor, SFont, SPoint, SLineCapStyle } from "@saga-web/draw";
 import { STextItem } from '@saga-web/graph/lib';
-import { hexify } from "@/components/mapClass/until"
+import { hexify, uuid } from "@/components/mapClass/until"
 import { SItemStatus, ItemOrder, SPolygonItem } from '@saga-web/big/lib';
 /**
  * 图例节点Item(区域类型 --防火分区)
@@ -124,6 +124,9 @@ export class SFHFQZoneLegendItem extends SPolygonItem {
         this.textItem.isTransform = false;
         this.zOrder = ItemOrder.polygonOrder - 0.00005;
         this.data = data;
+        if (!data.ID) {
+            data.ID = uuid()
+        }
         this.id = data.ID;
         this.name = data.Name;
         this.text = data.Name;

+ 4 - 0
src/lib/items/SImageLegendItem.ts

@@ -4,6 +4,7 @@ import { SIconTextItem } from '@saga-web/big/lib/items/SIconTextItem';
 import { Legend } from '../types/Legend';
 import { ItemOrder, SItemStatus } from '@saga-web/big/lib';
 import { SFont, SColor, SPainter, SRect } from '@saga-web/draw/lib';
+import { uuid } from '@/components/mapClass/until';
 /**
  * 图例节点Item(图标类型)
  *
@@ -69,6 +70,9 @@ export class SImageLegendItem extends SIconTextItem {
         this.isTransform = false;
         this.zOrder = ItemOrder.markOrder;
         this.data = data;
+        if (!data.ID) {
+            data.ID = uuid()
+        }
         this.id = data.ID;
         this.name = data.Name;
         this.text = data.Name;

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4 - 1
src/lib/items/SImageMarkerItem.ts


+ 1 - 0
src/lib/items/SLineLegendItem.ts

@@ -3,6 +3,7 @@ import { SGraphItem } from "@saga-web/graph/lib";
 import { SPoint } from "@saga-web/draw/lib";
 import { SPolylineItem } from '@saga-web/big/lib';
 import { Legend } from '../types/Legend';
+import { uuid } from '@/components/mapClass/until';
 
 /**
  * 图例节点Item(线类型)

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

@@ -3,6 +3,7 @@ import { SGraphItem, SLineStyle } from "@saga-web/graph/lib";
 import { SPoint, SPainter, SColor, SLineCapStyle } from "@saga-web/draw/lib";
 import { ItemOrder, SLineItem, SItemStatus } from '@saga-web/big/lib';
 import { Marker } from '../types/Marker';
+import { uuid } from '@/components/mapClass/until';
 
 /**
  * 标识对象Item(线类型)
@@ -55,6 +56,9 @@ export class SLineMarkerItem extends SLineItem {
         super(parent);
         this.zOrder = ItemOrder.lineOrder;
         this.data = data;
+        if (!data.ID) {
+            data.ID = uuid()
+        }
         this.id = data.ID;
         this.name = data.Name;
         this.moveTo(data.Pos.X, data.Pos.Y);

+ 4 - 1
src/lib/items/SSCPZZoneLegendItem.ts

@@ -3,7 +3,7 @@ import { SGraphItem, SLineStyle, STextOrigin } from "@saga-web/graph/lib";
 import { Legend } from '../types/Legend';
 import { SPainter, SColor, SFont, SPoint, SLineCapStyle } from "@saga-web/draw";
 import { STextItem } from '@saga-web/graph/lib';
-import { hexify } from "@/components/mapClass/until"
+import { hexify, uuid } from "@/components/mapClass/until"
 import { SItemStatus, ItemOrder, SPolygonItem } from '@saga-web/big/lib';
 /**
  * 图例节点Item(区域类型 --石材铺装)
@@ -132,6 +132,9 @@ export class SSCPZZoneLegendItem extends SPolygonItem {
         this.textItem.isTransform = false;
         this.zOrder = ItemOrder.polygonOrder - 0.0005;
         this.data = data;
+        if (!data.ID) {
+            data.ID = uuid()
+        }
         this.id = data.ID;
         this.name = data.Name;
         this.text = data.Name;

+ 4 - 0
src/lib/items/STextMarkerItem.ts

@@ -2,6 +2,7 @@ import { SGraphItem, STextItem, SLineStyle } from "@saga-web/graph/lib";
 import { SPainter, SColor,SFont, SPoint } from "@saga-web/draw";
 import { Marker } from '../types/Marker';
 import { ItemOrder } from '@saga-web/big/lib';
+import { uuid } from '@/components/mapClass/until';
 
 /**
  * 标识对象Item(文本类型)
@@ -23,6 +24,9 @@ export class STextMarkerItem extends STextItem {
         this.zOrder = ItemOrder.textOrder;
         this.isTransform = false;
         this.data = data;
+        if (!data.ID) {
+            data.ID = uuid()
+        }
         this.id = data.ID;
         this.name = data.Name;
         this.moveTo(data.Pos.X, data.Pos.Y);

+ 4 - 1
src/lib/items/SZoneLegendItem.ts

@@ -3,7 +3,7 @@ import { SGraphItem, SLineStyle, STextOrigin } from "@saga-web/graph/lib";
 import { Legend } from '../types/Legend';
 import { SPainter, SColor, SFont, SPoint, SLineCapStyle } from "@saga-web/draw";
 import { STextItem } from '@saga-web/graph/lib';
-import { hexify } from "@/components/mapClass/until"
+import { hexify, uuid } from "@/components/mapClass/until"
 import { SItemStatus, ItemOrder, SPolygonItem } from '@saga-web/big/lib';
 /**
  * 图例节点Item(区域类型)
@@ -124,6 +124,9 @@ export class SZoneLegendItem extends SPolygonItem {
         this.textItem.isTransform = false;
         this.zOrder = ItemOrder.polygonOrder;
         this.data = data;
+        if (!data.ID) {
+            data.ID = uuid()
+        }
         this.id = data.ID;
         this.name = data.Name;
         this.text = data.Name;

+ 4 - 0
src/lib/items/TipelineItem.ts

@@ -4,6 +4,7 @@ import { SAnchorItem, SGraphItem } from '@saga-web/graph/lib';
 import { Relation } from '../types/Relation';
 import { SPoint } from "@saga-web/draw/lib";
 import { Point } from "@saga-web/big/lib/types/Point";
+import { uuid } from '@/components/mapClass/until';
 
 /**
  * 管道item
@@ -111,6 +112,9 @@ export class TipelineItem extends SPolylineItem {
     });
     this.data = data;
     this.name = data.Name;
+    if (!data.ID) {
+      data.ID = uuid()
+    }
     this.id = data.ID;
     if (data.GraphElementId) {
       this._graphElementId = data.GraphElementId