Browse Source

'添加删除item刷新元素'

zhangyu 4 years ago
parent
commit
31a090567f

+ 5 - 0
src/components/baseEditer.vue

@@ -128,6 +128,7 @@ export default {
       // 获取typeid
       this.getTypeId()
       this.scene.emitChange = this.emitChange;
+      this.scene.scenceUpdate = this.scenceUpdate;
     },
     parserData(floor) {
       if (floor == "g80") {
@@ -178,6 +179,10 @@ export default {
       this.$emit("changeFocusItem", itemMsg);
       bus.$emit("FocusItemChanged", itemMsg);
     },
+    // 监听场景元素数据变化
+    scenceUpdate(scence) {
+      bus.$emit("elementDataChange", scence);
+    },
     clearGraphy() {
       if (this.view) {
         this.view.scene = null;

+ 3 - 2
src/components/edit/right_toolbar.vue

@@ -26,7 +26,7 @@
         <div class="element">
           <a-input-search placeholder="搜索" style="margin-bottom: 12px;" v-model="key" @search="onSearch" />
           <ul class="element-list">
-            <li v-for="ele in elementData" :key="ele.id" v-show="ele.name == key">
+            <li v-for="ele in elementData" :key="ele.id" v-show="key?ele.name.search(key) != -1:true">
               <el-image style="width: 45px; height: 26px; margin-top: 6px;" :src="ele.data.Properties.IconUrl" fit="contain"></el-image>
               <span class="element-name">{{ele.name}}</span>
             </li>
@@ -111,6 +111,7 @@ export default {
         if (val.Relations.length) {
           this.elementData = this.elementData.concat(val.Relations);
         }
+        console.log(this.elementData);
       });
     },
     callback(key) {
@@ -118,7 +119,7 @@ export default {
     },
     // 元素检索
     onSearch(key) {
-
+      console.log(key);
     },
     // 改变状态
     changeStatus(item) {

+ 17 - 5
src/components/mapClass/EditScence.ts

@@ -143,7 +143,8 @@ export class EditScence extends SGraphScene {
         this.addItem(item);
         item.connect("finishCreated", this, this.finishCreated);
         this.grabItem = item;
-        this.Markers.push(item)
+        this.Markers.push(item);
+        this.scenceUpdate(this);
         // this.undoStack.push(new SGraphAddCommand(this, item));
         // item.connect("onMove", this, this.onItemMove.bind(this));
         return true
@@ -196,6 +197,7 @@ export class EditScence extends SGraphScene {
         // this.undoStack.push(new SGraphAddCommand(this, item));
         this.grabItem = item;
         this.focusItem = item;
+        this.scenceUpdate(this);
         return true
     }
 
@@ -244,6 +246,7 @@ export class EditScence extends SGraphScene {
         this.grabItem = Polylines;
         this.focusItem = Polylines;
         this.Nodes.push(Polylines);
+        this.scenceUpdate(this);
     }
 
     /**
@@ -268,6 +271,7 @@ export class EditScence extends SGraphScene {
                 OutLine: item.pointArr[0],
                 SubType: SubType,
                 Properties: {
+                    IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
                     StrokeColor: this._legend.Color,
                     FillColor: this._legend.FillColor,
                     LineDash: this._legend.LineDash,
@@ -292,6 +296,7 @@ export class EditScence extends SGraphScene {
             Polylines.connect("finishCreated", this, this.finishCreated);
             this.focusItem = Polylines;
             this.Nodes.push(Polylines);
+            this.scenceUpdate(this);
         }
     }
 
@@ -323,7 +328,8 @@ export class EditScence extends SGraphScene {
         this.grabItem == null;
         this.focusItem = item;
         this.cmd = 'choice';
-        this.Markers.push(item)
+        this.Markers.push(item);
+        this.scenceUpdate(this);
     }
 
     /**
@@ -356,7 +362,8 @@ export class EditScence extends SGraphScene {
         this.addItem(item);
         this.grabItem == null
         this.cmd = 'choice';
-        this.Markers.push(item)
+        this.Markers.push(item);
+        this.scenceUpdate(this);
     }
 
     /**
@@ -393,6 +400,7 @@ export class EditScence extends SGraphScene {
         // item.moveTo(event.x, event.y);
         this.addItem(item);
         this.Nodes.push(item);
+        this.scenceUpdate(this);
     }
 
     /**
@@ -410,6 +418,7 @@ export class EditScence extends SGraphScene {
         if (this.focusItem) {
             const old = this.focusItem.text;
             this.focusItem.text = str;
+            this.scenceUpdate(this);
             // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "text", old, str));
         }
     }
@@ -565,7 +574,8 @@ export class EditScence extends SGraphScene {
      */
     upadataLengedName(val: string): void {
         if (this.focusItem && this.focusItem.data) {
-            this.focusItem.text = val
+            this.focusItem.text = val;
+            this.scenceUpdate(this); 
         }
     }
 
@@ -575,7 +585,7 @@ export class EditScence extends SGraphScene {
      */
     upadatImageNum(num: number): void {
         if (this.focusItem && this.focusItem.num) {
-            this.focusItem.num = num
+            this.focusItem.num = num;
         }
     }
 
@@ -630,7 +640,9 @@ export class EditScence extends SGraphScene {
         if (this.view) {
             this.view.update();
         }
+        this.scenceUpdate(this);
     }
+    scenceUpdate(scence: any) {}
 
     /**
      * 对齐指定item