Browse Source

typeidto图例元素映射添加

haojianlong 4 years ago
parent
commit
a86e78f1d7
4 changed files with 31 additions and 5 deletions
  1. 4 0
      src/api/editer.js
  2. 4 2
      src/components/baseEditer.vue
  3. 7 2
      src/components/edit/left_toolbar.vue
  4. 16 1
      src/store/index.ts

+ 4 - 0
src/api/editer.js

@@ -25,4 +25,8 @@ export function uploadImg({
     postParams
 }) {
     return httputils.postJson(`${testApi}/Picture/create`, postParams)
+}
+//查询图元素类型信息
+export function getGraphElementType(params){
+    return httputils.postJson(`${testApi}/graphElement/type/query`, params)
 }

+ 4 - 2
src/components/baseEditer.vue

@@ -15,6 +15,7 @@ import bus from "@/bus";
 import { saveGroup, readGroup } from "@/api/editer.js";
 import { STopologyParser } from "./../lib/parsers/STopologyParser";
 import { uuid } from "@/components/mapClass/until"
+import store from '../store'
 
 let fengmap = null;
 
@@ -51,6 +52,7 @@ export default {
     this.init();
     // 挂在bus
     this.getBus();
+    store.dispatch('getElementType',{PageSize:1000})
   },
   methods: {
     init() {
@@ -218,8 +220,8 @@ export default {
             if (t.data.Type == val.key) {
               return {
                 ID: uuid(),
-                Name: t.name,
-                GraphElementType: "Zone",
+                Name: val.name,
+                GraphElementType: val.properties.Type,
                 GraphElementId: "273d633cc5c54a4882794b34843d1a00",
                 AttachObjectIds: [],
                 Pos: { x: t.x, y: t.y },

+ 7 - 2
src/components/edit/left_toolbar.vue

@@ -250,7 +250,8 @@ export default {
   },
   computed: {
     ...mapState({
-      GraphCategoryIds: "GraphCategoryIds"
+      GraphCategoryIds: "GraphCategoryIds",
+      TypeIdToGraphElement: "TypeIdToGraphElement"
     })
   },
   methods: {
@@ -322,7 +323,11 @@ export default {
     },
     getBus() {
       bus.$on("exportItem", data => {
-        this.data = data;
+        this.data = data.map(t => {
+          t.name = this.TypeIdToGraphElement[t.key].Name,
+          t.properties = this.TypeIdToGraphElement[t.key];
+          return t;
+        });
       });
     },
     pickUp(text, record, index) {

+ 16 - 1
src/store/index.ts

@@ -1,15 +1,30 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
+import { getGraphElementType } from "@/api/editer.js"
 
 Vue.use(Vuex)
 
 export default new Vuex.Store({
   state: {
-    GraphCategoryIds: ['NTXT'] //系统类型
+    GraphCategoryIds: ['NTXT'], //系统类型
+    TypeIdToGraphElement:{}, //typeid到图例元素的映射
   },
   mutations: {
+    TypeIdToGraphElement(state,data){
+      if (data.length) {
+        state.TypeIdToGraphElement = {}
+        data.forEach(t => {
+          state.TypeIdToGraphElement[t.Id] = t;
+        })
+      }
+    }
   },
   actions: {
+    getElementType({ commit }, params) {
+      getGraphElementType(params).then(res => {
+        commit('TypeIdToGraphElement',res.Content)
+      })
+    }
   },
   modules: {
   }