YaolongHan 4 年之前
父节点
当前提交
82aa76caa2
共有 2 个文件被更改,包括 28 次插入11 次删除
  1. 18 10
      src/components/editview/baseTopoEditer.vue
  2. 10 1
      src/store/index.ts

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

@@ -35,7 +35,7 @@ export default {
     };
   },
   computed: {
-    ...mapState(["editCmd", "legendObj"]),
+    ...mapState(["editCmd", "legendObj", "graphId", "id"]),
   },
   mounted() {
     this.canvasWidth = this.$refs.baseTopo.offsetWidth;
@@ -61,7 +61,12 @@ export default {
     // this.readMapmsg();
   },
   methods: {
-    ...mapMutations(["SETCHOICELEHEND", "SETLEGENDOBJ"]),
+    ...mapMutations([
+      "SETCHOICELEHEND",
+      "SETLEGENDOBJ",
+      "SETPROJECT",
+      "projectId",
+    ]),
     // 恢复命令状态
     clearCmdStatus() {
       this.SETCHOICELEHEND("");
@@ -120,10 +125,10 @@ export default {
         const obj = {
           elements,
           name: "1", // 名称
-          categoryID: "1", // 图分类ID
-          projectID: "1", // 项目ID
-          buildingID: "1", // 建筑ID
-          floorID: "1", // 楼层id
+          categoryId: "1", // 图分类ID
+          projectId: this.projectId, // 项目ID
+          buildingId: "1", // 建筑ID
+          floorId: "1", // 楼层id
           note: "1", // 图说明
           log: {
             // 图操作日志
@@ -138,8 +143,8 @@ export default {
           },
         };
         Object.assign(obj, {
-          graphId: "cd8ca79c337644d48c58c447cf21b757",
-          id: "f15506fa5dcc4ce79064e459e5497748",
+          graphId: this.graphId,
+          id: this.id,
         });
         console.log(obj);
         saveGroup(obj).then((res) => {
@@ -154,8 +159,8 @@ export default {
     // 读取拓扑图
     readtopoMsg() {
       let obj = {
-        graphId: "cd8ca79c337644d48c58c447cf21b757",
-        id: "f15506fa5dcc4ce79064e459e5497748",
+        graphId: this.graphId,
+        id: this.id,
       };
       readGroup(obj).then((res) => {
         const parse = new PTopoParser();
@@ -195,6 +200,9 @@ export default {
       deep: true,
     },
   },
+  created() {
+    this.SETPROJECT(this.$route.query);
+  },
 };
 </script>
 <style lang="less" scoped>

+ 10 - 1
src/store/index.ts

@@ -6,7 +6,10 @@ Vue.use(Vuex)
 export default new Vuex.Store({
   state: {
     editCmd: '', //编辑器编辑命令
-    legendObj: null //获取的相关图例数据obj
+    legendObj: null, //获取的相关图例数据obj
+    graphId: '',    //图 id 用于读图
+    id: '',        // id  用于读图
+    projectId: ''  // projectId
   },
   mutations: {
     // 修改编辑器命令
@@ -16,6 +19,12 @@ export default new Vuex.Store({
     // 修改编辑器图例
     SETLEGENDOBJ(state, data) {
       state.legendObj = data;
+    },
+    // 设置项目id
+    SETPROJECT(state, data) {
+      state.graphId = data.graphId;   //图 id 用于读图
+      state.id = data.id;       // id  用于读图
+      // projectId: ''  // projectId
     }
   },
   actions: {