Browse Source

管线数据的获取

lkk 11 months ago
parent
commit
6852d76141
1 changed files with 147 additions and 19 deletions
  1. 147 19
      src/components/Query/clickQuery/clickQuery.vue

+ 147 - 19
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,21 +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">
@@ -104,9 +137,7 @@ export default {
       return store.state.toolBar[9];
     },
   },
-  created() {
-
-  },
+  created() {},
   watch: {
     activeLayerId(val) {
       if (val && val != "0") {
@@ -132,9 +163,61 @@ export default {
       this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
       this.dataSourceLayer = new Cesium.CustomDataSource("query");
       this.viewer.dataSources.add(this.dataSourceLayer);
-    })
+    });
   },
   methods: {
+    text() {
+      let buildingLayer = scene.layers.find("ResultNetWork@管线#1");
+      buildingLayer.indexedDBSetting.isAttributesSave = true; //保存属性
+
+      var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
+      handler.setInputAction(function (evt) {
+        var position = scene.pickPosition(evt.position);
+
+        if (buildingLayer.getSelection().length > 0) {
+          const selectedId = Number(buildingLayer.getSelection()[0]);
+          buildingLayer.getAttributesById([selectedId]).then(function (atts) {
+            if (atts) {
+              console.log(atts);
+
+              viewer.entities.removeAll();
+
+              var length = Object.keys(atts).length;
+              var des;
+              for (var i = 0; i < length; i++) {
+                var key = Object.keys(atts)[i];
+                var value = atts[key];
+
+                console.log(key);
+                console.log(value);
+
+                var index = i.toString();
+                if (i == 0) {
+                  des =
+                    '<table class="cesium-infoBox-defaultTable"><tbody>' +
+                    "<tr><th>" +
+                    key +
+                    "</th><td>" +
+                    value +
+                    "</td></tr>";
+                } else if (i == length - 1) {
+                  des +=
+                    "<tr><th>" +
+                    key +
+                    "</th><td>" +
+                    value +
+                    "</td></tr>" +
+                    "</tbody></table>";
+                } else {
+                  des += "<tr><th>" + key + "</th><td>" + value + "</td></tr>";
+                }
+              }
+            }
+          });
+        }
+      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
+    },
+
     toggleVisibility() {
       this.removeMapLayerQuery();
       store.setToolBarAction(9);
@@ -234,14 +317,57 @@ export default {
       that.dataSourceLayer.entities.removeAll();
       //拾取模型
       let pickedFeature = scene.pick(movement.position);
+      console.log("ighui",pickedFeature);
+      let eneityName = pickedFeature.primitive.name
+      let Pid =''
+      // "ResultNetWork@管线#1"///"ResultNetWork_Node@管线#1"
+      if (eneityName.indexOf('管线') > 0) {
+        let buildingLayer = scene.layers.find(eneityName);
+        buildingLayer.indexedDBSetting.isAttributesSave = true; //保存属性
+        if (buildingLayer.getSelection().length > 0) {
+          const selectedId = Number(buildingLayer.getSelection()[0]);
+          console.log(selectedId,'selectedId');
+          buildingLayer.getAttributesById([selectedId]).then(function (atts) {
+            if (atts) {
+              console.log(atts);
+              // var Pid = atts['管线段']
+              console.log(atts["管线段"]);
+              console.log(atts["物探点"]);
+              Pid = atts["管线段"] || atts["物探点"]
+              // viewer.entities.removeAll();
+
+              // var length = Object.keys(atts).length;
+              // var des;
+              // for (var i = 0; i < length; i++) {
+              //   var key = Object.keys(atts)[i];
+              //   var value = atts[key];
+              //   console.log(key);
+              //   console.log(value);
+
+              //   var index = i.toString();
+              //   if (i == 0) {
+              //     des = '<table class="cesium-infoBox-defaultTable"><tbody>' + '<tr><th>' + key + '</th><td>' + value + '</td></tr>';
+              //   } else if (i == length - 1) {
+              //     des += '<tr><th>' + key + '</th><td>' + value + '</td></tr>' + "</tbody></table>";
+              //   } else {
+              //     des += '<tr><th>' + key + '</th><td>' + value + '</td></tr>';
+              //   }
+              // }
+            }
+          });
+        }
+      }
+     
       if (
         scene.pickPositionSupported &&
         Cesium.defined(pickedFeature) &&
         pickedFeature != null &&
         pickedFeature.primitive
       ) {
+
+
         //解构赋值点击对象的id
-        let Pid = pickedFeature.getProperty("id");
+        // let Pid = pickedFeature.getProperty("id");
         let commaIndex = pickedFeature.primitive.url.indexOf("=");
         let substring = "";
         if (commaIndex !== -1) {
@@ -255,7 +381,7 @@ export default {
         if (Pid.indexOf("_") < 0) {
           gwtype = 1;
         } else {
-          Pid = Pid.replace("_", "-");
+          // Pid = Pid.replace("_", "-");
           gwtype = 2;
         }
         GetGDlnfo({ type: gwtype, key: Pid }).then((res) => {
@@ -382,7 +508,8 @@ export default {
               e.features[u].fieldNames.forEach((fieldName, i) => {
                 if (
                   fieldName.toLowerCase().indexOf("shape") < 0 &&
-                  fieldName.toLowerCase().indexOf("sm") && e.features[u].fieldValues[i] != ''
+                  fieldName.toLowerCase().indexOf("sm") &&
+                  e.features[u].fieldValues[i] != ""
                 ) {
                   cur.push({
                     name: fieldName,
@@ -578,6 +705,7 @@ export default {
     changleQueryItem(item) {
       switch (item.index) {
         case 1: {
+          // this.text();
           this.mapQuerys("mapLayerQuery"); //图层点击事件
           break;
         }