maxiaoxiao 11 сар өмнө
parent
commit
077a83381f

+ 38 - 28
src/components/Query/clickQuery/clickQuery.vue

@@ -395,7 +395,6 @@ export default {
         let artesian3 = viewer.scene.pickPosition(movement.position);
         let xy = that.cartesian3ToWGS84(artesian3);
         //TODO wanger 分图层查询
-
         for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
           let obj = store.state.vectorlayerlist[i];
           if (!obj.source) {
@@ -513,37 +512,46 @@ export default {
             let legendJson = getTreeId(tempTreeData, obj.id);
             for (let u = 0; u < e.features.length; u++) {
               let cur = [];
-              if (legendJson.legend != "") {
-                //将数据转为json
-                let parseJson = JSON.parse(legendJson.legend);
-                //初始化下标
-                let index = -1;
-                var linSAr = JSON.parse(JSON.stringify(e.features[u]));
-                parseJson.forEach((p) => {
-                  //将数据改为大写
-                  p.fieldname = p.fieldname.toUpperCase();
-                  let index1 = linSAr.fieldNames.indexOf(p.fieldname);
-                  if (index1 > -1 && !condition(p)) {
-                    this.$delete(linSAr.fieldNames, index1);
-                    this.$delete(linSAr.fieldValues, index1);
-                  }
-
-                  //判断数据是否存在
-                  index = linSAr.fieldNames.indexOf(p.fieldname);
-                  if (index > -1 && p.fieldaliasname != p.fieldname) {
-                    //如果数据存在数组中并且进行了修改,找到它对应的下标对数据进行替换
-                    linSAr.fieldNames[index] = p.fieldaliasname;
-                  }
-                });
-              } else {
-                var linSAr = JSON.parse(JSON.stringify(e.features[u]));
-              }
+              // if (legendJson.legend != "") {
+              //   //将数据转为json
+              //   let parseJson = JSON.parse(legendJson.legend);
+              //   //初始化下标
+              //   let index = -1;
+              //   var linSAr = JSON.parse(JSON.stringify(e.features[u]));
+              //   parseJson.forEach((p) => {
+              //     //将数据改为大写
+              //     p.fieldname = p.fieldname.toUpperCase();
+              //     let index1 = linSAr.fieldNames.indexOf(p.fieldname);
+              //     if (index1 > -1 && !condition(p)) {
+              //       this.$delete(linSAr.fieldNames, index1);
+              //       this.$delete(linSAr.fieldValues, index1);
+              //     }
+
+              //     //判断数据是否存在
+              //     index = linSAr.fieldNames.indexOf(p.fieldname);
+              //     if (index > -1 && p.fieldaliasname != p.fieldname) {
+              //       //如果数据存在数组中并且进行了修改,找到它对应的下标对数据进行替换
+              //       linSAr.fieldNames[index] = p.fieldaliasname;
+              //     }
+              //   });
+              // } else {
+              //   var linSAr = JSON.parse(JSON.stringify(e.features[u]));
+              // }
+              var linSAr = JSON.parse(JSON.stringify(e.features[u]));
+              let parseJson = legendJson.legend != "" ? JSON.parse(legendJson.legend) : [];
               function condition(ci) {
                 return ci.status != undefined && ci.status;
               }
               if (e.features[u].fieldNames) {
                 linSAr.fieldNames.forEach((fieldName, i) => {
-                  if (linSAr.fieldValues[i] != "") {
+                let perjson =  parseJson.filter(p=> p.fieldname.toUpperCase() == fieldName);
+                  if (perjson.length > 0) {
+                    var show = condition(perjson[0]);
+                    var order = perjson[0].order || linSAr.fieldNames.length;
+                    if(fieldName != perjson[0].fieldaliasname)
+                    fieldName=perjson[0].fieldaliasname
+                  }
+                  if (linSAr.fieldValues[i] != "" && show) {
                     let v = linSAr.fieldValues[i];
                     if (!isNaN(parseFloat(v))) {
                       v = Math.round(parseFloat(v) * 100) / 100;
@@ -551,6 +559,7 @@ export default {
                     cur.push({
                       name: fieldName,
                       value: v,
+                      order,
                     });
                   }
                 });
@@ -578,7 +587,8 @@ export default {
                 });
               }
 
-              //排序  将value值为空串的数据放到列表最后
+              //排序  
+              cur.sort((a, b) => a.order - b.order);
               // cur.sort((a, b) => {
               //   if (a === b) {
               //     return 0;