Browse Source

editer:fix>完成信息点切换设备得联动

YaolongHan 4 years ago
parent
commit
ebab676a3b

+ 19 - 18
src/components/editClass/big-edit/items/SBaseEquipment.ts

@@ -125,31 +125,32 @@ export class SBaseEquipment extends SBaseIconTextEdit {
     }// Function initData()
 
     /**
-     * 添加信息点
+     * 设置信息点
      *
-     * @params	添加的信息点
+     * @params	obj 设置的信息点
      */
-    addInfoMsg(val: any) {
-        this._infoPointList.push(val);
-        this.addTextItem(val)
-    }
-
-    /**
-     * 删除信息点
-     *
-     * @params	删除索引
-     */
-    removeInfoMsg(index: number) {
-        this._infoPointList.splice(index, 1);
-        // this.removeTextItem()
-    }
+    setMsgPoint(val: any) {
+        // 根据是否勾选来判断是够增加或删除
+        if (val.checked) {
+            this._infoPointList.push(val);
+        } else {
+            let deleteItemIndex: number = -1;
+            this._infoPointList.forEach((item, index) => {
+                if (val.id == item.id) {
+                    deleteItemIndex = index;
+                }
+            });
+            this._infoPointList.splice(deleteItemIndex, 1)
+        }
+        // this.addTextItem(val)
+    } //Function setMsgPoint()
 
     /**
      * 增加 textItem
      *
      * @params obj	textItem文本信息
      */
-    addTextItem(val:any) {
+    addTextItem(val: any) {
         // do something
     }
 
@@ -158,7 +159,7 @@ export class SBaseEquipment extends SBaseIconTextEdit {
      *
      * @params obj	textItem文本信息
      */
-    removeTextItem(val:any) {
+    removeTextItem(val: any) {
         // do something
     }
     /**

+ 12 - 2
src/components/editClass/persagy-edit/PTopoScene.ts

@@ -1,4 +1,4 @@
-import { SBaseEditScene, SBasePipe, } from "./../big-edit";
+import { SBaseEditScene, SBasePipe,SBaseEquipment } from "./../big-edit";
 import { SGraphEdit, } from "./../edit";
 import { SMouseEvent } from "@persagy-web/base/lib";
 import { SGraphSelectContainer, SLineStyle } from "@persagy-web/graph";
@@ -24,7 +24,6 @@ export class PTopoScene extends SBaseEditScene {
      */
     listChange(list: any): void {
         const itemList: any = []
-        console.log('list', list)
         list.itemList.forEach((item: any) => {
             if ((item instanceof SGraphEdit) && !(item instanceof SGraphSelectContainer)) {
                 itemList.push(item)
@@ -156,6 +155,17 @@ export class PTopoScene extends SBaseEditScene {
     } // Function updateStyle()
 
     /**
+     * 修改指定设备得信息点
+     * @param obj Object 信息点
+     */
+    changeEquipMsgPoint(obj:any):void{
+       const List = this.selectContainer.itemList.length ? this.selectContainer.itemList[0]:null;
+       if(List && List instanceof SBaseEquipment){
+           List.setMsgPoint(obj);
+       }
+    }
+
+    /**
      * item 创建完成后回调
      *
      * @param   event   鼠标事件参数

+ 5 - 0
src/components/editview/baseTopoEditer.vue

@@ -183,6 +183,11 @@ export default {
       bus.$on("addEquipment", (val) => {
         this.addEquipmentList(val);
       });
+      // 更改设备信息点
+      bus.$off('changeEquipMsgPoint');
+      bus.$on("changeEquipMsgPoint", (val) => {
+          this.scene.changeEquipMsgPoint(val)
+      });
     },
     // 读取拓扑图
     readtopoMsg() {

+ 86 - 64
src/components/editview/rightPropertyBar/BaseEquipment.vue

@@ -71,7 +71,11 @@
             @pressEnter="pressEnter"
             @clear="pressEnter"
           />
-          <div class="msgPoint-list" v-show="!pressMsgData.length">
+          <div
+            class="msgPoint-list"
+            ref="localDom"
+            v-show="!pressMsgData.length"
+          >
             <div class="type-list" v-for="(item, key) in msgData" :key="key">
               <div class="type-title" @click="clips(item)">
                 <i
@@ -111,6 +115,7 @@
 </template>
 <script>
 import { queryEquipMsg, queryDict } from "@/api/editer";
+import bus from "@/bus/bus";
 export default {
   props: ["InfoPointList", "EquipData", "equipHeight"],
   data() {
@@ -118,10 +123,10 @@ export default {
       activeName: "first",
       width: "",
       height: "",
-      checked1: "checked",
-      msgData: [],
+      msgData: [], //存储二级树
       pressMsgData: [], // 搜索后得信息点数组
       getPressMsg: "", //输入信息
+      local: "", //局部加载
     };
   },
   methods: {
@@ -144,6 +149,7 @@ export default {
     // 切换选中选项
     changeCheck(item) {
       item.checked = !item.checked;
+      bus.$emit("changeEquipMsgPoint", item);
     },
     // 搜索回车操作
     pressEnter() {
@@ -165,49 +171,80 @@ export default {
   },
   watch: {
     EquipData(val) {
+      this.msgData = []; //存储二级树
+      this.pressMsgData = []; // 搜索后得信息点数组
+      this.getPressMsg = ""; //输入信息
+      // 启动局部 loading
+
+      this.local = this.$loading({
+        el: this.$refs.localDom,
+        type: "local",
+        size: "min",
+      });
+
       const data = {
         Type: val.properties.classCode,
       };
-      queryDict(data).then((res) => {
-        let arr = [];
-        // 勾选设备中选中的对象
-        const msgData = res.content;
-        // 设置已经勾选数据
-        if (this.InfoPointList && this.InfoPointList.length) {
-          msgData.map((item) => {
-            item.checked = false;
-            this.InfoPointList.forEach((a) => {
-              if (a.id == item.id) {
-                item.checked = true;
-              }
+      queryDict(data)
+        .then((res) => {
+          let arr = [];
+          // 勾选设备中选中的对象
+          const msgData = res.content;
+          // 设置已经勾选数据
+          if (this.InfoPointList && this.InfoPointList.length) {
+            msgData.map((item) => {
+              item.checked = false;
+              this.InfoPointList.forEach((a) => {
+                if (a.id == item.id) {
+                  item.checked = true;
+                }
+              });
+              return item;
             });
-            return item;
-          });
-        } else {
-          msgData.map((item) => {
-            item.checked = false;
-            return item;
-          });
-        }
-        this.msgData = msgData;
-        //  生成二级树
-        msgData.forEach((item) => {
-          const itemTag = item.secondTag
-            ? item.secondTag
-            : item.firstTag
-            ? item.firstTag
-            : "--";
-          if (arr.length) {
-            let index = -1;
-            arr.forEach((aItem) => {
-              if (aItem.tag == itemTag) {
-                index = 1;
-                aItem.children.push(item);
-                aItem.number++;
-              }
+          } else {
+            msgData.map((item) => {
+              item.checked = false;
+              return item;
             });
+          }
+          //  生成二级树
+          msgData.forEach((item) => {
+            const itemTag = item.secondTag
+              ? item.secondTag
+              : item.firstTag
+              ? item.firstTag
+              : "--";
+            if (arr.length) {
+              let index = -1;
+              arr.forEach((aItem) => {
+                if (aItem.tag == itemTag) {
+                  index = 1;
+                  aItem.children.push(item);
+                  aItem.number++;
+                }
+              });
 
-            if (index == -1) {
+              if (index == -1) {
+                const tag = item.secondTag
+                  ? item.secondTag
+                  : item.firstTag
+                  ? item.firstTag
+                  : "--";
+                const tagName = item.secondName
+                  ? item.secondName
+                  : item.firstName
+                  ? item.firstName
+                  : "--";
+                let obj = {
+                  tagName: tagName,
+                  tag: tag,
+                  children: [item],
+                  number: 1,
+                  showChildren: true,
+                };
+                arr.push(obj);
+              }
+            } else {
               const tag = item.secondTag
                 ? item.secondTag
                 : item.firstTag
@@ -221,36 +258,21 @@ export default {
               let obj = {
                 tagName: tagName,
                 tag: tag,
-                children: [item],
+                children: [],
                 number: 1,
                 showChildren: true,
               };
+              obj.children.push(item);
               arr.push(obj);
             }
-          } else {
-            const tag = item.secondTag
-              ? item.secondTag
-              : item.firstTag
-              ? item.firstTag
-              : "--";
-            const tagName = item.secondName
-              ? item.secondName
-              : item.firstName
-              ? item.firstName
-              : "--";
-            let obj = {
-              tagName: tagName,
-              tag: tag,
-              children: [],
-              number: 1,
-              showChildren: true,
-            };
-            obj.children.push(item);
-            arr.push(obj);
-          }
+          });
+          this.msgData = arr;
+          this.$loading.close(this.local);
+        })
+        .catch((err) => {
+          console.log("接口报错", err);
+          this.$loading.close(this.local);
         });
-        this.msgData = arr;
-      });
     },
   },
   mounted() {},

+ 3 - 3
src/components/editview/rightPropertyBar/property.vue

@@ -166,10 +166,10 @@ export default {
         // 填充色
       } else if (this.itemType == "BaseEquipment") {
         if (
-          item.legendData.properties &&
-          item.legendData.properties.infoPointList
+          item.infoPointList &&
+          item.infoPointList.length
         ) {
-          this.infoPointList = item.legendData.properties.infoPointList;
+          this.infoPointList = item.infoPointList;
         } else {
           this.infoPointList = [];
         }