Explorar el Código

提取问题修改

haojianlong hace 4 años
padre
commit
33ce99a2e3
Se han modificado 4 ficheros con 36 adiciones y 23 borrados
  1. 5 1
      src/api/editer.js
  2. 1 1
      src/components/baseEditer.vue
  3. 13 19
      src/components/edit/left_toolbar.vue
  4. 17 2
      src/store/index.ts

+ 5 - 1
src/api/editer.js

@@ -97,7 +97,11 @@ export function queryInfoSystem(params){
 export function graphElementGroup(params){
     return httputils.postJson(`${testApi}/infoSystem/graphElementGroup`, params)
 }
-// 图例搜索(提取用)
+// 图例搜索(提取用) 不用了
 export function graphElementSearch(params){
     return httputils.postJson(`${testApi}/graphElement/search`, params)
+}
+// 图例搜索(提取用)
+export function graphElementQuery(params){
+    return httputils.postJson(`${testApi}/graphElement/query`, params)
 }

+ 1 - 1
src/components/baseEditer.vue

@@ -69,7 +69,7 @@ export default {
     this.init();
     // 挂在bus
     this.getBus();
-    store.dispatch("getElementType", { PageSize: 1000 });
+    store.dispatch("getGraphElement", { PageSize: 1000 });
     window.vm = this;
     const that = this;
     document.onkeydown = function(event) {

+ 13 - 19
src/components/edit/left_toolbar.vue

@@ -144,7 +144,7 @@
 </template>
 <script>
 import itemTree from "./leftbar_components/itemTree";
-import { graphElementGroup, graphElementSearch } from "@/api/editer.js";
+import { graphElementGroup } from "@/api/editer.js";
 import bus from "@/bus";
 import { queryGroup } from "@/api/editer.js";
 import { mapState, mapActions } from "vuex";
@@ -274,7 +274,7 @@ export default {
   computed: {
     ...mapState({
       GraphCategoryIds: "GraphCategoryIds",
-      TypeIdToGraphElement: "TypeIdToGraphElement"
+      GraphElement: "GraphElement"
     })
   },
   methods: {
@@ -389,24 +389,18 @@ export default {
       bus.$on("exportItem", data => {
         this.data = [];
         if (data.length) {
-          data.forEach(t => {
-            const pa = {
-              Deleted: false,
-              InfoTypeIds: [t.key],
-              PageSize: 1000,
-              Type: t.type
-            };
-            this.spinning = true;
-            graphElementSearch(pa).then(res => {
-              this.spinning = false;
-              if (res.Content && res.Content.length) {
-                t.age = res.Content[0];
-                t.name = this.TypeIdToGraphElement[t.key].Name;
-                t.properties = this.TypeIdToGraphElement[t.key];
-                this.data.push(t);
+          this.spinning = true;
+          for(let i = 0; i< this.GraphElement.length; i++) {
+            const it = this.GraphElement[i];
+            for(let j = 0; j < data.length; j++) {
+              if (it.InfoTypeId.indexOf(data[j].key)>-1 && it.Type == data[j].type) {
+                data[j].age = it;
+                data[j].name = it.Name;
+                this.data.push(data[j]);
               }
-            });
-          });
+            }
+          }
+          this.spinning = false;
         }
       });
     },

+ 17 - 2
src/store/index.ts

@@ -1,6 +1,6 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
-import { getGraphElementType } from "@/api/editer.js"
+import { getGraphElementType, graphElementQuery } from "@/api/editer.js"
 
 Vue.use(Vuex)
 
@@ -9,6 +9,7 @@ export default new Vuex.Store({
     GraphCategoryIds: ['NTXT'], //系统类型
     TypeIdToGraphElement: {}, //typeid到图例元素的映射
     token: null,
+    GraphElement:[]
   },
   mutations: {
     TypeIdToGraphElement(state, data) {
@@ -19,6 +20,15 @@ export default new Vuex.Store({
         })
       }
     },
+    GraphElement(state, data) {
+      if (data.length) {
+        state.GraphElement = data.map(t => {
+          if (t.InfoTypeId && t.InfoTypeId.length){
+            return t
+          }
+        }).filter(item => item)
+      }
+    },
     SETSSOTOKEN(state, data) {
       state.token = data
     },
@@ -28,7 +38,12 @@ export default new Vuex.Store({
       getGraphElementType(params).then(res => {
         commit('TypeIdToGraphElement', res.Content)
       })
-    }
+    },
+    getGraphElement({ commit }, params) {
+      graphElementQuery(params).then(res => {
+        commit('GraphElement', res.Content)
+      })
+    },
   },
   getters: {
     token: (state) => state.token,