Преглед на файлове

修改字典汉化错位问题

lkk преди 11 месеца
родител
ревизия
f03a6955ac
променени са 1 файла, в които са добавени 30 реда и са изтрити 13 реда
  1. 30 13
      src/components/Query/clickQuery/clickQuery.vue

+ 30 - 13
src/components/Query/clickQuery/clickQuery.vue

@@ -391,21 +391,30 @@ export default {
             let legendJson = getTreeId(tempTreeData, obj.id);
             for (let u = 0; u < e.features.length; u++) {
               let cur = [];
+              // console.log(e.features[u], "e.features[u]");
+              if (legendJson.legend != "") {
+                //将数据转为json
+                let parseJson = JSON.parse(legendJson.legend);
+                //初始化下标
+                let index = -1;
+                parseJson.forEach((p) => {
+                  //将数据改为大写
+                  p.fieldname = p.fieldname.toUpperCase();
+                  //判断数据是否存在
+                  index = e.features[u].fieldNames.indexOf(p.fieldname);
+                  if (index > -1 && p.fieldaliasname != p.fieldname) {
+                    //如果数据存在数组中并且进行了修改,找到它对应的下标对数据进行替换
+                    e.features[u].fieldNames[index] = p.fieldaliasname;
+                  }
+                });
+              }
+
               e.features[u].fieldNames.forEach((fieldName, i) => {
                 if (fieldName.toLowerCase().indexOf("shape") < 0) {
-                  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],
-                    });
-                  }
+                  cur.push({
+                    name: fieldName,
+                    value: e.features[u].fieldValues[i],
+                  });
                 }
               });
               let points = [];
@@ -609,13 +618,16 @@ export default {
   text-align: center;
   padding-top: 5px;
 }
+
 .flyBtn2 {
   position: absolute;
   right: 47px;
 }
+
 .el-tabs__item {
   color: white !important;
 }
+
 .sm-function-module-content-tabs {
   height: 45px;
   padding: 1px 5px 0px 5px;
@@ -634,28 +646,33 @@ export default {
   scrollbar-width: none;
   /* firefox */
   -ms-overflow-style: none;
+
   /* IE 10+ */
   @media (max-width: 1000px) {
     margin: 0.8rem 0;
     padding: 0 15px;
   }
+
   @media (max-width: 750px) {
     margin: 0.5rem 0;
     padding: 0 10px;
     max-height: 410px;
   }
+
   @media (max-height: 480px) {
     margin: 0.5rem 0;
     padding: 0 15px;
     max-height: 420px;
     max-width: 280px;
   }
+
   @media (max-height: 300px) {
     margin: 0.5rem 0;
     padding: 0 10px;
     max-height: 280px;
     max-width: 250px;
   }
+
   @media (max-height: 250px) {
     max-height: 240px;
   }