فهرست منبع

图层数据查询结果与后台汉化字典配置匹配

lkk 1 سال پیش
والد
کامیت
822f2867bc
2فایلهای تغییر یافته به همراه41 افزوده شده و 11 حذف شده
  1. 2 1
      src/components/Combinations/LayerManage/LayerManage.vue
  2. 39 10
      src/components/Query/clickQuery/clickQuery.vue

+ 2 - 1
src/components/Combinations/LayerManage/LayerManage.vue

@@ -422,7 +422,7 @@ export default {
     },
     // 复选框改变
     handleCheckChange(obj, checked) {
-      console.log(obj, checked);
+      // console.log(obj, checked ,);
       if (typeof checked == "boolean") {
         obj.checked = checked;
       } else {
@@ -564,6 +564,7 @@ export default {
       GetResourceTree().then((res) => {
         if (res.statuscode == 200) {
           this.TreeDatas = res.data;
+          store.state.tempResourceTree = res.data
         } else {
           console.log(e);
         }

+ 39 - 10
src/components/Query/clickQuery/clickQuery.vue

@@ -363,14 +363,49 @@ export default {
             that.layerList.push(store.state.vectorlayerlist[i]);
             let queryData = [];
             let geoms = [];
+            let tempTreeData = store.state.tempResourceTree;
+            //递归查询点击的图层信息
+            function getTreeId(list, id) {
+              //判断list是否是数组
+              if (!list instanceof Array) {
+                return null;
+              }
+              //遍历数组
+              for (let i in list) {
+                let item = list[i];
+                if (item.id === id) {
+                  return item;
+                } else {
+                  //查不到继续遍历
+                  if (item.children) {
+                    let value = getTreeId(item.children, id);
+                    //查询到直接返回
+                    if (value) {
+                      return value;
+                    }
+                  }
+                }
+              }
+            }
+
+            let legendJson = getTreeId(tempTreeData, obj.id);
             for (let u = 0; u < e.features.length; u++) {
               let cur = [];
               e.features[u].fieldNames.forEach((fieldName, i) => {
                 if (fieldName.toLowerCase().indexOf("shape") < 0) {
-                  cur.push({
-                    name: fieldName,
-                    value: e.features[u].fieldValues[i],
-                  });
+                  if (legendJson.legend == "") {
+                    cur.push({
+                      name: fieldName,
+                      value: e.features[u].fieldValues[i],
+                    });
+                  } else {
+                    //如果配置过字典信息
+                    let parseJson = JSON.parse(legendJson.legend);
+                    cur.push({
+                      name: parseJson[i].fieldaliasname,
+                      value: e.features[u].fieldValues[i],
+                    });
+                  }
                 }
               });
               let points = [];
@@ -384,12 +419,6 @@ export default {
               geoms.push(points);
               queryData.push(cur);
             }
-            console.log(
-              that.queryResults,
-              "that.queryResults,",
-              obj.id,
-              that.queryResults[obj.id]
-            );
             that.queryResults[obj.id] = queryData;
             that.queryResultsGeom[obj.id] = geoms;
           }