Sfoglia il codice sorgente

feat:调通线,图片,文字的上传玉读取

YaolongHan 4 anni fa
parent
commit
7b4122d605

+ 34 - 27
src/components/baseEditer.vue

@@ -14,7 +14,7 @@ import { EditScence } from "./mapClass/EditScence";
 import bus from "@/bus";
 import { saveGroup, readGroup } from "@/api/editer.js";
 import { STopologyParser } from "./../lib/parsers/STopologyParser";
-import { uuid } from "@/components/mapClass/until"
+import { uuid } from "@/components/mapClass/until";
 export default {
   props: {
     cmdType: {
@@ -57,7 +57,7 @@ export default {
       this.scene = new EditScence();
       this.fmap = new SFengParser(
         "fengMap",
-        this.mapServerURL + '/1001724_29',
+        this.mapServerURL + "/1001724_29",
         this.key,
         this.appName,
         null
@@ -85,11 +85,17 @@ export default {
         // 多边形
         parserData.zoneLegendList.forEach(t => {
           this.scene.addItem(t);
-          this.scene.Nodes.push(t)
+          this.scene.Nodes.push(t);
         });
-        parserData.zoneLegendList.forEach(t => {
+        // 增加文字
+        parserData.textMarkerList.forEach(t => {
+          this.scene.addItem(t);
+          this.scene.Markers.push(t);
+        });
+        // 增加图片
+        parserData.imageMarkerList.forEach(t => {
           this.scene.addItem(t);
-          this.scene.Nodes.push(t)
+          this.scene.Markers.push(t);
         });
       });
       this.scene.emitChange = this.emitChange;
@@ -169,7 +175,7 @@ export default {
         const Elements = this.scene.saveMsgItem();
         const data = {
           Elements,
-          ID: "a36a8b30423a44bba03be989ddc36737",  // 如果id为空则为地图
+          ID: "a36a8b30423a44bba03be989ddc36737", // 如果id为空则为地图
           Name: "1", // 名称
           CategoryID: "", // 图分类ID
           ProjectID: "1", // 项目ID
@@ -182,30 +188,31 @@ export default {
         });
       });
       bus.$on("exportByKey", val => {
-        const list = this.fParser.spaceList.map(t => {
-          if (t.data.Type == val.key) {
-            return {
-              ID: uuid(),
-              Name: t.name,
-              GraphElementType: 'Zone',
-              GraphElementId: "273d633cc5c54a4882794b34843d1a00",
-              AttachObjectIds:[],
-              Pos: { x: t.x, y: t.y },
-              OutLine: t.pointArr,
-              Properties: {
-                strokeColor: '#3d73c0',
-                fillColor: '#eda986'
-              },
-              Num: 123
-            };
-          }
-        }).filter(item => item);
-        console.log(list)
+        const list = this.fParser.spaceList
+          .map(t => {
+            if (t.data.Type == val.key) {
+              return {
+                ID: uuid(),
+                Name: t.name,
+                GraphElementType: "Zone",
+                GraphElementId: "273d633cc5c54a4882794b34843d1a00",
+                AttachObjectIds: [],
+                Pos: { x: t.x, y: t.y },
+                OutLine: t.pointArr,
+                Properties: {
+                  strokeColor: "#3d73c0",
+                  fillColor: "#eda986"
+                },
+                Num: 123
+              };
+            }
+          })
+          .filter(item => item);
         const parserData = new STopologyParser(null);
         parserData.parseData({ Nodes: list });
         parserData.zoneLegendList.forEach(t => {
           this.scene.addItem(t);
-          this.scene.Nodes.push(t)
+          this.scene.Nodes.push(t);
         });
       });
       // 设备图例样式对象
@@ -214,7 +221,7 @@ export default {
       });
       //  修改图片url
       bus.$on("upadataImageUrl", val => {
-        this.scene.upadataImageUrl(val)
+        this.scene.upadataImageUrl(val);
       });
     },
     // 读取数据

+ 2 - 2
src/components/mapClass/EditScence.ts

@@ -171,7 +171,7 @@ export class EditScence extends SGraphScene {
         Polylines.connect("finishCreated", this, this.finishCreated);
         this.grabItem = Polylines;
         this.focusItem = Polylines;
-        this.Nodes.push(Polylines)
+        this.Nodes.push(Polylines);
     }
 
     /**
@@ -202,7 +202,7 @@ export class EditScence extends SGraphScene {
         this.grabItem == null;
         this.focusItem = item;
         this.cmd = 'choice';
-        // this.Markers.push(item)
+        this.Markers.push(item)
     }
 
     /**

+ 1 - 1
src/lib/parsers/STopologyParser.ts

@@ -88,7 +88,7 @@ export class STopologyParser extends SParser {
      * @param   t       标识对象数据
      * */
     private addMarker(t: Marker): void {
-        if (t.Type == SMarkerType.Image) {
+        if (t.Type == 'Image') {
             let item = new SImageMarkerItem(null, t);
             this.imageMarkerList.push(item);
         } else if (t.Type == SMarkerType.Line) {