Parcourir la source

余杭一张图,属性识别功能修改

liutao il y a 1 mois
Parent
commit
493271b93b
1 fichiers modifiés avec 56 ajouts et 14 suppressions
  1. 56 14
      YHYZT/client/src/views/DataCenter.vue

+ 56 - 14
YHYZT/client/src/views/DataCenter.vue

@@ -516,13 +516,30 @@
     <div v-show="sxsbData.show" class="oepnLayerFeature">
       <div class="contents">
         <div class="select_box">
-          <Select v-model="layIndex" clearable style="width:200px">
-            <Option v-for="(item,index) in sxsbData.layerData" :value="index" :key="index">{{ item.layerName }}</Option>
+          <Select
+            v-model="layIndex"
+            clearable
+            style="width: 200px"
+            @on-change="selectChange"
+          >
+            <Option
+              v-for="(item, index) in sxsbData.layerData"
+              :value="index"
+              :key="index"
+              >{{ item.layerName }}</Option
+            >
           </Select>
-          <p class="desc">已识别<span>{{ sxsbData.layerData.length }}</span>个图层</p>
+          <p class="desc">
+            已识别<span>{{ sxsbData.layerData.length }}</span
+            >个图层
+          </p>
         </div>
         <table v-if="sxsbData.layerData.length > 0 && layIndex >= 0">
-          <tr v-for="(item, index) in sxsbData.layerData[layIndex].featureOverlayTable" :key="index">
+          <tr
+            v-for="(item, index) in sxsbData.layerData[layIndex]
+              .featureOverlayTable"
+            :key="index"
+          >
             <th>{{ item.name }}</th>
             <td>{{ item.value }}</td>
           </tr>
@@ -666,8 +683,9 @@ export default {
       layIndex: 0,
       sxsbData: {
         show: false,
-        layerData: []
+        layerData: [],
       },
+      layerGeometryMap: {},
       zycxData: {
         show: false,
         tableId: 0,
@@ -959,6 +977,17 @@ export default {
     openCoordinate() {
       this.coordinateDialogShow = true;
     },
+    selectChange(index) {
+      const layer = this.sxsbData.layerData[index];
+      console.log("layer");
+      console.log(layer);
+      console.log(this.layerGeometryMap);
+      if (!layer || !layer.layerName || !this.layerGeometryMap) {
+        return;
+      }
+      console.log("layername:" + layer.layerName);
+      this.feature = this.layerGeometryMap[layer.layerName];
+    },
     //数据详情加定位查询(详情数据绑定)
     sxsbTableSerach(index, item) {
       this.zycxData.tableId = index;
@@ -1227,6 +1256,7 @@ export default {
      * @returns {Promise<void>}
      */
     async pickServerFeature(e, layerId) {
+      this.layerGeometryMap = {};
       // 带上图层显示参数,只拾取显示的图斑
       let where = "1=1";
       const [x, y] = e.coordinate;
@@ -1239,7 +1269,6 @@ export default {
         geometry: JSON.stringify({ x, y }),
         geometryType: "esriGeometryPoint",
       };
-      const feature = null;
       console.log("this.visibleLayerIds:");
       console.log(this.visibleLayerIds);
       this.sxsbData.layerData = [];
@@ -1258,15 +1287,26 @@ export default {
           });
         }
         if (feature != null) {
-          this.feature = feature;
-          this.bindingFeatureValues(item);
+          // this.feature = feature;
+          this.bindingFeatureValues(item, feature);
           // break;
         }
       }
+      if (this.sxsbData.layerData.length) {
+        const layer = this.sxsbData.layerData[0];
+        if (!layer) {
+          return;
+        }
+        const layerName = layer.layerName;
+        if (!layerName) {
+          return;
+        }
+        this.feature = this.layerGeometryMap[layerName];
+      }
     },
-    bindingFeatureValues(id) {
+    bindingFeatureValues(id, feature) {
       let layer = {};
-      if (!this.feature) return;
+      if (!feature) return;
       let layerId = null;
       if (id) {
         layerId = id;
@@ -1275,8 +1315,9 @@ export default {
       }
       const layerConfig = this.$refs.configLayer.getLayerConfigById(layerId);
       layer.layerName = layerConfig.name;
+
       layer.featureOverlayTable = [];
-      const values = this.feature.values_;
+      const values = feature.values_;
       //读取配置文件信息
       let layerData = this.fields.layersData.filter((item) => {
         return layerId == item.serverId;
@@ -1307,6 +1348,7 @@ export default {
       this.layIndex = 0;
       this.sxsbData.show = true;
       this.sxsbData.layerData.push(layer);
+      this.layerGeometryMap[layer.layerName] = feature;
     },
     readVisibleLayer(children) {
       if (children) {
@@ -2424,16 +2466,16 @@ export default {
       height: calc(100% - 38px);
       overflow-y: auto;
       padding: 10px 10px;
-      >.select_box {
+      > .select_box {
         display: flex;
         align-items: center;
         justify-content: space-between;
-        >.desc {
+        > .desc {
           font-family: AlibabaPuHuiTiM;
           font-size: 14px;
           display: flex;
           align-items: center;
-          >span {
+          > span {
             display: inline-block;
             margin: 0px 5px;
             // font-size: 22px;