Kaynağa Gözat

数据查询数据处理,展示字典配置结果

lkk 11 ay önce
ebeveyn
işleme
06f6b4b4d6
1 değiştirilmiş dosya ile 75 ekleme ve 27 silme
  1. 75 27
      src/components/Query/clickQuery/clickQuery.vue

+ 75 - 27
src/components/Query/clickQuery/clickQuery.vue

@@ -6,9 +6,19 @@
     </div>
     <!-- <div class="sm-function-module-content-btn"> -->
     <div class="btnList">
-      <span v-for="(item, index) in actionOptions" :key="index" class="icon-span" :title="item.lable"
-        :class="item.isSelect ? 'selected-icon' : ''" @click="changleQueryItem(item)">
-        <i class="iconfont iconSize" :class="item.iconName" style="margin-top: 0px"></i>
+      <span
+        v-for="(item, index) in actionOptions"
+        :key="index"
+        class="icon-span"
+        :title="item.lable"
+        :class="item.isSelect ? 'selected-icon' : ''"
+        @click="changleQueryItem(item)"
+      >
+        <i
+          class="iconfont iconSize"
+          :class="item.iconName"
+          style="margin-top: 0px"
+        ></i>
       </span>
       <!-- <el-button type="primary" size="small" @click.stop="mapLayerQuery"
         >点击</el-button
@@ -19,22 +29,44 @@
     </div>
     <div class="sm-function-module-content-tabs">
       <el-tabs @tab-click="handleTabClick" v-model="activeLayerId">
-        <el-tab-pane :label="item.label" :name="item.id" v-for="(item, index) in layerList" :key="index"></el-tab-pane>
+        <el-tab-pane
+          :label="item.label"
+          :name="item.id"
+          v-for="(item, index) in layerList"
+          :key="index"
+        ></el-tab-pane>
       </el-tabs>
     </div>
     <div class="sm-function-module-content-table">
-      <el-collapse :value="activeNames" @change="handleCollapseChange" v-if="
-        activeLayerId &&
-        queryResults[activeLayerId] &&
-        queryResults[activeLayerId].length > 0
-      ">
-        <el-collapse-item :title="'查询结果' + (index + 1)" :name="'查询结果' + (index + 1)"
-          v-for="(item, index) in queryResults[activeLayerId]" :key="index">
+      <el-collapse
+        :value="activeNames"
+        @change="handleCollapseChange"
+        v-if="
+          activeLayerId &&
+          queryResults[activeLayerId] &&
+          queryResults[activeLayerId].length > 0
+        "
+      >
+        <el-collapse-item
+          :title="'查询结果' + (index + 1)"
+          :name="'查询结果' + (index + 1)"
+          v-for="(item, index) in queryResults[activeLayerId]"
+          :key="index"
+        >
           <template slot="title">
             查询结果{{ index + 1
-            }}<i title="定位" class="header-icon el-icon-s-promotion flyBtn2" @click.stop="flyTo(index)"></i>
+            }}<i
+              title="定位"
+              class="header-icon el-icon-s-promotion flyBtn2"
+              @click.stop="flyTo(index)"
+            ></i>
           </template>
-          <el-table :data="item" :show-header="false" border style="width: 100%">
+          <el-table
+            :data="item"
+            :show-header="false"
+            border
+            style="width: 100%"
+          >
             <el-table-column prop="name" label="字段" width="100">
             </el-table-column>
             <el-table-column prop="value" label="值" width="208">
@@ -106,7 +138,7 @@ export default {
       return store.state.toolBar[9];
     },
   },
-  created() { },
+  created() {},
   watch: {
     activeLayerId(val) {
       if (val && val != "0") {
@@ -275,7 +307,6 @@ export default {
             const selectedId = Number(buildingLayer.getSelection()[0]);
             buildingLayer.getAttributesById([selectedId]).then(function (atts) {
               if (atts) {
-                // console.log(atts);
                 Pid = atts["管线段"] || atts["物探点"];
                 var length = Object.keys(atts).length;
                 var des;
@@ -368,7 +399,7 @@ export default {
               queryByIDParameters
             );
           }
-          console.log(e)
+          console.log(e);
           if (e && e.totalCount > 0) {
             that.layerList.push(store.state.vectorlayerlist[i]);
             let queryData = [];
@@ -401,12 +432,12 @@ 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;
+                var linSAr = JSON.parse(JSON.stringify(e.features[u]));
                 parseJson.forEach((p) => {
                   //将数据改为大写
                   p.fieldname = p.fieldname.toUpperCase();
@@ -416,16 +447,19 @@ export default {
                     //如果数据存在数组中并且进行了修改,找到它对应的下标对数据进行替换
                     e.features[u].fieldNames[index] = p.fieldaliasname;
                   }
+                  let index1 = linSAr.fieldNames.indexOf(p.fieldname);
+                  if (index1 > -1 && !condition(p)) {
+                    this.$delete(linSAr.fieldNames, index1);
+                    this.$delete(linSAr.fieldValues, index1);
+                  }
                 });
               }
+              function condition(ci) {
+                return ci.status != undefined && ci.status;
+              }
               if (e.features[u].fieldNames) {
-                e.features[u].fieldNames.forEach((fieldName, i) => {
-                  if (
-                    fieldName.toLowerCase().indexOf("shape") < 0 &&
-                    fieldName.toLowerCase().indexOf("sm") &&
-                    e.features[u].fieldValues[i] != ""
-                  ) {
-                    let v = e.features[u].fieldValues[i];
+                linSAr.fieldNames.forEach((fieldName, i) => {
+                    let v = linSAr.fieldValues[i];
                     if (!isNaN(parseFloat(v))) {
                       v = Math.round(parseFloat(v) * 100) / 100;
                     }
@@ -433,8 +467,23 @@ export default {
                       name: fieldName,
                       value: v,
                     });
-                  }
                 });
+                // e.features[u].fieldNames.forEach((fieldName, i) => {
+                //   if (
+                //     fieldName.toLowerCase().indexOf("shape") < 0 &&
+                //     fieldName.toLowerCase().indexOf("sm") &&
+                //     e.features[u].fieldValues[i] != ""
+                //   ) {
+                //     let v = e.features[u].fieldValues[i];
+                //     if (!isNaN(parseFloat(v))) {
+                //       v = Math.round(parseFloat(v) * 100) / 100;
+                //     }
+                //     cur.push({
+                //       name: fieldName,
+                //       value: v,
+                //     });
+                //   }
+                // });
               } else {
                 that.$message({
                   message: "查询结果为空!",
@@ -465,7 +514,7 @@ export default {
                 );
                 points.push([c.x, c.y]);
               }
-              parts.push(e.features[u].geometry.parts)
+              parts.push(e.features[u].geometry.parts);
               geoms.push(points);
               queryData.push(cur);
             }
@@ -477,7 +526,6 @@ export default {
         }
         if (that.layerList.length > 0) {
           that.activeLayerId = that.layerList[0].id;
-          console.log(that.activeLayerId, "that.activeLayerId");
         } else {
           that.$message({
             message: "查询结果为空!",