Browse Source

图片完成

YaolongHan 4 năm trước cách đây
mục cha
commit
be6ab3cb3e

+ 9 - 0
src/components/baseEditer.vue

@@ -82,6 +82,11 @@ export default {
       this.readGroup().then(data => {
         const parserData = new STopologyParser(null);
         parserData.parseData(data.data.Data[0].Elements);
+        // 多边形
+        parserData.zoneLegendList.forEach(t => {
+          this.scene.addItem(t);
+          this.scene.Nodes.push(t)
+        });
         parserData.zoneLegendList.forEach(t => {
           this.scene.addItem(t);
           this.scene.Nodes.push(t)
@@ -207,6 +212,10 @@ export default {
       bus.$on("setLenged", obj => {
         this.scene.setlegend = obj;
       });
+      //  修改图片url
+      bus.$on("upadataImageUrl", val => {
+        this.scene.upadataImageUrl(val)
+      });
     },
     // 读取数据
     readGroup() {

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

@@ -71,7 +71,6 @@
         <div class="grid-content">
           <a-upload-dragger
             name="file"
-            :multiple="true"
             :customRequest="customRequest"
             action="https://jsonplaceholder.typicode.com/posts/"
             @change="changeImage"
@@ -289,12 +288,12 @@ export default {
       bus.$emit("changebackColor", color);
     },
     customRequest(info){
-      let formData = new FormData()
+      const formData = new FormData()
       formData.append('file', info.file)
-      let postParams = formData;
+      const postParams = formData;
       uploadImg({ postParams }).then(res => {
         if (res.Result == 'success') {
-          console.log(res);
+          bus.$emit('upadataImageUrl',res.EntityList[0])
           // this.$set(this.ruleForm, 'Url', res.EntityList[0])
           this.$message.success(`${info.file.name} file uploaded successfully.`);
         }else{

+ 23 - 9
src/components/mapClass/EditScence.ts

@@ -180,16 +180,16 @@ export class EditScence extends SGraphScene {
     addImgItem(event: SMouseEvent) {
         const data = {
             /** ID */
-            ID:'123',
+            ID: '123',
             /** 名称  */
             Name: '嗡嗡嗡',
             /** 图标(Image),线类型(Line) */
             Type: "Image",
             /** 位置  */
-            Pos: {X: event.x, Y: event.y},
+            Pos: { X: event.x, Y: event.y },
             /** 由应用自己定义  */
-            Properties:{
-                Url:require('./../../assets/logo.png'),
+            Properties: {
+                Url: '/serve/topology-wanda/Picture/query/' + '1bcff19d6f3547488673dcba7dd9507f',
                 Name: '嗡嗡嗡',
             }
         }
@@ -211,15 +211,15 @@ export class EditScence extends SGraphScene {
     addTextItem(event: SMouseEvent): void {
         const data = {
             /** ID */
-            ID:'456',
+            ID: '456',
             /** 名称  */
             Name: '文本',
             /** 图标(Image),线类型(Line) */
             Type: "Text",
             /** 位置  */
-            Pos: {X: event.x, Y: event.y},
+            Pos: { X: event.x, Y: event.y },
             /** 由应用自己定义  */
-            Properties:{
+            Properties: {
                 Text: '请在右侧属性栏输入文字!'
             }
         }
@@ -372,6 +372,16 @@ export class EditScence extends SGraphScene {
     }
 
     /**
+     * 更改item Url
+     * @param url string 图片key
+     */
+    upadataImageUrl(url: string): void {
+        if (this.focusItem) {
+            this.focusItem.url = '/serve/topology-wanda/Picture/query/' + url;
+            alert(url)
+        }
+    }
+    /**
      * 删除指定item
      */
     deleiteItem(): void {
@@ -404,12 +414,16 @@ export class EditScence extends SGraphScene {
      * 保存数据
      */
     saveMsgItem(): any {
-        const Nodes: any = []
+        const Nodes: any = [];
+        const Markers: any = [];
         this.Nodes.forEach(e => {
             Nodes.push(e.toData())
         });
+        this.Markers.forEach(e => {
+            Markers.push(e.toData())
+        });
         let element = {
-            Nodes
+            Nodes, Markers
         }
         return element
     }

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

@@ -94,7 +94,7 @@ export class STopologyParser extends SParser {
         } else if (t.Type == SMarkerType.Line) {
             let item = new SLineMarkerItem(null, t);
             this.lineMarkerList.push(item);
-        } else if (t.Type == SMarkerType.Text) {
+        } else if (t.Type == 'Text') {
             let item = new STextMarkerItem(null, t);
             this.textMarkerList.push(item);
         }