YaolongHan 3 years ago
parent
commit
b012096f95
2 changed files with 22 additions and 1 deletions
  1. 16 0
      src/components/editview/baseTopoEditer.vue
  2. 6 1
      src/store/index.ts

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

@@ -25,6 +25,7 @@ import {
   PTopoParser,
   PTopoView,
 } from "@/components/editClass/persagy-edit";
+import { SBaseEquipment } from "@persagy-web/big-edit";
 import topoTooltip from "./topoTooltip.vue";
 import zoom from "./zoom";
 import { mapState, mapMutations } from "vuex";
@@ -120,6 +121,7 @@ export default {
       "EDITEQUIPITEM",
       "SETVERSION",
       "SETVBACKGROUND",
+      "SYNCSCENCEEQUIp",
     ]),
     // 恢复命令状态
     clearCmdStatus() {
@@ -169,11 +171,15 @@ export default {
       bus.$off("topoUndo");
       bus.$on("topoUndo", (val) => {
         this.scene.undo();
+        //撤销后 scence中设备与vuex设备数组做同步
+        this.SyncVuex();
       });
       // 重做
       bus.$off("topoRedo");
       bus.$on("topoRedo", (val) => {
         this.scene.redo();
+        //撤销后 scence中设备与vuex设备数组做同步
+        this.SyncVuex();
       });
       // 删除
       bus.$off("deleteItem");
@@ -252,6 +258,16 @@ export default {
         this.scene.changeBackgroundColor(val);
       });
     },
+    // 同步场景与vuex设备数据
+    SyncVuex() {
+      const arr = [];
+      this.scene.root.children.forEach((item) => {
+        if (item instanceof SBaseEquipment) {
+          arr.push(item);
+        }
+      });
+      this.SYNCSCENCEEQUIp(arr);
+    },
     // 读取拓扑图
     readtopoMsg() {
       const obj = {

+ 6 - 1
src/store/index.ts

@@ -77,7 +77,12 @@ export default new Vuex.Store({
     // 获取完成所有分类后
     SETCATEGORYGRAPH(state, val): void {
       state.categoryGraph = val;
-      
+    },
+
+    // 同步场景设备
+    SYNCSCENCEEQUIp(state, val = []) {
+      state.equipmentItemList = val;
+      state.equipmentItemNum = val.length;
     }
   },
   actions: {