Ver código fonte

viewer 获取bug测试

zpf 1 ano atrás
pai
commit
01081d23b8
1 arquivos alterados com 21 adições e 50 exclusões
  1. 21 50
      src/components/Query/clickQuery/clickQuery.vue

+ 21 - 50
src/components/Query/clickQuery/clickQuery.vue

@@ -6,19 +6,9 @@
     </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
@@ -29,44 +19,21 @@
     </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">
@@ -108,7 +75,7 @@ export default {
       activeLayerId: "",
       queryResults: {},
       queryResultsGeom: {},
-      viewer: window.viewer,
+      viewer: null,
       dataSourceLayer: null,
       actionOptions: [
         {
@@ -138,10 +105,7 @@ export default {
     },
   },
   created() {
-    this.viewer.entities.removeAll();
-    this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
-    this.dataSourceLayer = new Cesium.CustomDataSource("query");
-    this.viewer.dataSources.add(this.dataSourceLayer);
+
   },
   watch: {
     activeLayerId(val) {
@@ -162,6 +126,13 @@ export default {
   },
   mounted() {
     //this.mapLayerQuery();
+    this.$nextTick((res) => {
+      this.viewer = viewer;
+      this.viewer.entities.removeAll();
+      this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
+      this.dataSourceLayer = new Cesium.CustomDataSource("query");
+      this.viewer.dataSources.add(this.dataSourceLayer);
+    })
   },
   methods: {
     toggleVisibility() {