Ver código fonte

Merge branch 'develop' of http://39.106.8.246:3003/web/persagy_topo_editer into develop

YaolongHan 4 anos atrás
pai
commit
408a022242

+ 39 - 10
src/components/editview/baseTopoEditer.vue

@@ -16,13 +16,13 @@
   </div>
 </template>
 <script>
-import { PTopoScene, PTopoParser } from "@/components/editClass/persagy-edit";
+import { PTopoScene, PTopoParser, } from "@/components/editClass/persagy-edit";
 import { SGraphView } from "@persagy-web/graph";
 import { SFloorParser } from "@persagy-web/big/lib";
 import topoTooltip from "./topoTooltip.vue";
 import { mapState, mapMutations } from "vuex";
 import bus from "@/bus/bus";
-import { saveGroup, readGroup, uploadGroup, getImageGroup } from "@/api/editer";
+import { saveGroup, readGroup, uploadGroup, getImageGroup, readPubGroup } from "@/api/editer";
 export default {
   components: { topoTooltip },
   data() {
@@ -33,10 +33,11 @@ export default {
       canvasHeight: 700, //画布高
       havItem: false, //右击是否选中item
       showTooltip: false, //是否显示tooltip
+      topoName: '',  //拓扑图名称
     };
   },
   computed: {
-    ...mapState(["editCmd", "legendObj", "graphId", "id", "categoryId","projectId"]),
+    ...mapState(["editCmd", "legendObj", "graphId", "id", "isPub", "categoryId","projectId"]),
   },
   mounted() {
     this.canvasWidth = this.$refs.baseTopo.offsetWidth;
@@ -67,6 +68,7 @@ export default {
       "SETLEGENDOBJ",
       "SETPROJECT",
       "SETCATEGROY",
+      "SETISPUB",
     ]),
     // 恢复命令状态
     clearCmdStatus() {
@@ -125,7 +127,7 @@ export default {
         const elements = this.scene.save();
         const obj = {
           elements,
-          name: "1", // 名称
+          name: this.topoName, // 名称
           categoryId: this.categoryId, // 图分类ID
           projectId: this.projectId, // 项目ID
           buildingId: "1", // 建筑ID
@@ -149,7 +151,22 @@ export default {
         });
         console.log(obj);
         saveGroup(obj).then((res) => {
-          console.log("res", res);
+          // 设置发布状态为 未发布
+          this.SETISPUB(0);
+          const gid = res.entityList[0].graphId;
+          const id = res.entityList[0].id
+          // 重设图id 与 id
+          this.SETPROJECT({graphId: gid, id: id});
+          // 修改url参数
+          this.$router.push({
+            name: 'Editer',
+            query: {
+              graphId: gid,
+              id: id,
+              categoryName: encodeURI(this.categoryName),
+              isPub: 0
+            }
+          })
         });
       });
       // 设置实例置顶置底
@@ -163,12 +180,24 @@ export default {
     },
     // 读取拓扑图
     readtopoMsg() {
-      let obj = {
+      const obj = {
         graphId: this.graphId,
-        id: this.id,
+        id: this.id
       };
-      readGroup(obj).then((res) => {
+      if (this.isPub == 1) { // 已发布
+        readPubGroup(obj).then(res => {
+          this.getDataSuc(res);
+        })
+      } else {
+        readGroup(obj).then((res) => {
+          this.getDataSuc(res)
+        });
+      }
+    },
+    // 读图成功回调
+    getDataSuc(res) {
         this.SETCATEGROY(res.content.categoryId);
+        this.topoName = res.content.name;
         const parse = new PTopoParser();
         parse.parseData(res.content.elements);
         parse.markers.forEach((item) => {
@@ -178,7 +207,6 @@ export default {
           item.connect("onContextMenu", this, this.scene.getItem);
           this.scene.addItem(item);
         });
-      });
     },
     readMapmsg() {
       let parser = new SFloorParser();
@@ -209,8 +237,9 @@ export default {
     },
   },
   created() {
-    console.log(this.$route.query)
     this.SETPROJECT(this.$route.query);
+    this.SETISPUB(this.$route.query.isPub);
+    this.categoryName = decodeURI(this.$route.query.categoryName)
   },
 };
 </script>

+ 4 - 2
src/components/homeView/createGraphDialog.vue

@@ -120,10 +120,12 @@ export default {
           this.outerVisible = false;
           this.$message.success('创建成功');
           this.$router.push({
-            name: 'Editer', query: {
+            name: 'Editer',
+            query: {
               graphId: res.entityList[0].graphId,
               id: res.entityList[0].id,
-              categoryName: encodeURI(this.buttonStr)
+              categoryName: encodeURI(this.buttonStr),
+              isPub: 0
             }
           })
         } else {

+ 5 - 0
src/store/index.ts

@@ -9,6 +9,7 @@ export default new Vuex.Store({
     legendObj: null, //获取的相关图例数据obj
     graphId: '',    //图 id 用于读图
     id: '',        // id  用于读图
+    isPub: 0,     // 用于读图 区分读取 已发布 or 未发布
     projectId: 'Pj1101050029',  // projectId
     categoryId: '',   //类型id 用于读图
     equipmentList: []  //设备数组
@@ -28,6 +29,10 @@ export default new Vuex.Store({
       state.id = data.id;       // id  用于读图
       // projectId: ''  // projectId
     },
+    // 设置项目id
+    SETISPUB(state, val) {
+      state.isPub = val;   // 是否发布 用于读图
+    },
     // 设置类型id
     SETCATEGROY(state, val) {
       state.categoryId = val

+ 2 - 1
src/views/home.vue

@@ -235,7 +235,8 @@ export default {
         query: {
           graphId: data.graphId,
           id: data.id,
-          categoryName: encodeURI(this.categoryName)
+          categoryName: encodeURI(this.categoryName),
+          isPub: this.isPub
         }
       })
     },