CzRger il y a 1 an
Parent
commit
75a4452110

+ 1 - 1
src/out/config.js

@@ -1,4 +1,4 @@
 window.cusConfig = {
-  mapInternet: false,
+  mapInternet: true,
   internetAuth: false
 }

+ 4 - 4
src/store/modules/dictionary.ts

@@ -9,12 +9,12 @@ const state = {
 		{dictLabel: '缉私警', dictValue: 'jsj'},
 		{dictLabel: '网格员', dictValue: 'wgy'},
 		{dictLabel: '危险车辆', dictValue: 'wxcl'},
-		{dictLabel: '公安类设备', dictValue: 'galsb'},
-		{dictLabel: '社会类设备', dictValue: 'shlsb'},
-		{dictLabel: '民用类设备', dictValue: 'mylsb'},
+		{dictLabel: '公安类设备', dictValue: 'gal'},
+		{dictLabel: '社会类设备', dictValue: 'shl'},
+		{dictLabel: '民用类设备', dictValue: 'myl'},
 		{dictLabel: '零关税自用进口生产设备', dictValue: 'lgszyjkscsb'},
 		{dictLabel: '加工增值免关税', dictValue: 'jgzzmgs'},
-		{dictLabel: '零关税进口原辅料', dictValue: 'lgsjkyfl'},
+		{dictLabel: '零关税进口原辅料', dictValue: 'lgsjkfzl'},
 		{dictLabel: '景区', dictValue: 'jq'},
 		{dictLabel: '旅馆', dictValue: 'lg'},
 		{dictLabel: '出租屋', dictValue: 'czw'},

+ 126 - 22
src/store/modules/gis.ts

@@ -15,6 +15,8 @@ import store from "@/store";
 import axios from "axios";
 import {formatPosition} from "@/utils/easyMap";
 import * as turf from "@turf/turf";
+// @ts-ignore
+import PointIcon from "@/assets/images/gis-layout/gis-layout-tools_tool-bz_icon.png";
 
 const formatWkt = (wkt) => {
   return wkt.split(',').join('\\\,')
@@ -32,6 +34,7 @@ const state = {
   map: null,
   activeQyId: null,
   gisParams: {
+    autoZoom: 12,
     default: {
       layer: null,
       source: null,
@@ -72,18 +75,18 @@ const state = {
         label: '设备资源',
         active: true,
         children: [
-          {label: '公安类设备', value: 'galsb', geoValue: 'gal', active: true},
-          {label: '社会类设备', value: 'shlsb', geoValue: 'shl', active: true},
-          {label: '民用类设备', value: 'mylsb', geoValue: 'myl', active: true},
+          {label: '公安类设备', value: 'galsb', geoValue: 'gal', active: true, typeName: 'mysqlGeo:stg_view_deviceinfo_df_value1'},
+          {label: '社会类设备', value: 'shlsb', geoValue: 'shl', active: true, typeName: 'mysqlGeo:stg_view_deviceinfo_df_value2'},
+          {label: '民用类设备', value: 'mylsb', geoValue: 'myl', active: true, typeName: 'mysqlGeo:stg_view_deviceinfo_df_value3'},
         ]
       },
       {
         label: '企业',
         active: true,
         children: [
-          {label: '零关税自用进口生产设备', value: 'lgszyjkscsb', geoValue: 'lgszyjkscsb', active: true},
-          {label: '加工增值免关税', value: 'jgzzmgs', geoValue: 'jgzzmgs', active: true},
-          {label: '零关税进口原辅料', value: 'lgsjkyfl', geoValue: 'lgsjkfzl', active: true},
+          {label: '零关税自用进口生产设备', value: 'lgszyjkscsb', geoValue: 'lgszyjkscsb', active: true, typeName: 'mysqlGeo:lgsqy_typeValue1'},
+          {label: '加工增值免关税', value: 'jgzzmgs', geoValue: 'jgzzmgs', active: true, typeName: 'mysqlGeo:lgsqy_typeValue2'},
+          {label: '零关税进口原辅料', value: 'lgsjkyfl', geoValue: 'lgsjkfzl', active: true, typeName: 'mysqlGeo:lgsqy_typeValue3'},
         ]
       },
       // {
@@ -101,11 +104,37 @@ const state = {
     ],
     layer: null,
   },
+  analysis: {
+    source: null,
+    layer: null,
+    wkt: '',
+    deviceLayer: null,
+    power: [],
+    device: [],
+    loading: false
+  },
   l: null,
   s: null
 }
 
 const getters = {
+  elementActiveArr: (state) => {
+    const arr: any = []
+    state.element.list.forEach(p => {
+      if (p.children?.length > 0) {
+        p.children.forEach(s => {
+          if (s.active) {
+            arr.push(s)
+          }
+        })
+      } else {
+        if (p.active) {
+          arr.push(p)
+        }
+      }
+    })
+    return arr
+  }
 }
 
 const mutations = {
@@ -214,6 +243,34 @@ const mutations = {
       zIndex: 30
     })
     state.map.addLayer(state.gisParams.qy.analysisDeviceLayer)
+    // 周边分析
+    state.analysis.source = new source.Vector()
+    state.analysis.layer = new layer.Vector({
+      zIndex: 20,
+      source: state.analysis.source,
+      style: [
+        new style.Style({
+          image: new style.Icon({
+            src: PointIcon,
+            displacement: [0, 24]
+          }),
+          stroke: new style.Stroke({
+            color: '#2860F1',
+            width: 2,
+            lineDash: [10, 10]
+          }),
+          fill: new style.Fill({
+            color: 'rgba(20, 129, 241, 0.1)',
+          }),
+        })
+      ]
+    });
+    state.analysis.layer.set('layerName', 'analysisDrawViewsLayer')
+    state.map.addLayer(state.analysis.layer)
+    state.analysis.deviceLayer = new layer.Tile({
+      zIndex: 30
+    })
+    state.map.addLayer(state.analysis.deviceLayer)
     const clickQy = (e, feat) => {
       if (state.gisParams.qy.overlay.getPosition() === undefined) {
         state.gisParams.qy.overlay.setPosition(state.gisParams.qy.feature.getGeometry().getCoordinates())
@@ -364,6 +421,10 @@ const mutations = {
         state.gisParams.qy.source.addFeature(newFeat)
         state.gisParams.qy.overlay.setPosition(newFeat.getGeometry().getCoordinates())
         state.gisParams.qy.feature = newFeat
+        state.map.getView().animate({
+          center: newFeat.getGeometry().getCoordinates(),
+          zoom: state.gisParams.autoZoom,
+        });
         store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
@@ -466,6 +527,10 @@ const mutations = {
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
         state.gisParams.default.feature = newFeat
+        state.map.getView().animate({
+          center: newFeat.getGeometry().getCoordinates(),
+          zoom: state.gisParams.autoZoom,
+        });
         store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
@@ -502,6 +567,10 @@ const mutations = {
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
         state.gisParams.default.feature = newFeat
+        state.map.getView().animate({
+          center: newFeat.getGeometry().getCoordinates(),
+          zoom: state.gisParams.autoZoom,
+        });
         store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
@@ -538,6 +607,10 @@ const mutations = {
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
         state.gisParams.default.feature = newFeat
+        state.map.getView().animate({
+          center: newFeat.getGeometry().getCoordinates(),
+          zoom: state.gisParams.autoZoom,
+        });
         store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
@@ -574,6 +647,10 @@ const mutations = {
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
         state.gisParams.default.feature = newFeat
+        state.map.getView().animate({
+          center: newFeat.getGeometry().getCoordinates(),
+          zoom: state.gisParams.autoZoom,
+        });
         store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
@@ -610,6 +687,10 @@ const mutations = {
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
         state.gisParams.default.feature = newFeat
+        state.map.getView().animate({
+          center: newFeat.getGeometry().getCoordinates(),
+          zoom: state.gisParams.autoZoom,
+        });
         store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
@@ -626,23 +707,9 @@ const mutations = {
       store.commit('gis/SET_GIS_ELEMENT')
     }
   },
-  SET_GIS_ELEMENT(state) {
-    const arr: any = []
-    state.element.list.forEach(p => {
-      if (p.children?.length > 0) {
-        p.children.forEach(s => {
-          if (s.active) {
-            arr.push(`'${s.geoValue}'`)
-          }
-        })
-      } else {
-        if (p.active) {
-          arr.push(`'${p.geoValue}'`)
-        }
-      }
-    })
+  SET_GIS_ELEMENT(state, activeArr: any = []) {
     const cql: any = ["(geoType = 2)"]
-    cql.push(`(typeValue in (${arr.length > 0 ? arr.join(',') : -1}))`)
+    cql.push(`(typeValue in (${store.getters['gis/elementActiveArr'].length > 0 ? store.getters['gis/elementActiveArr'].map(v => `'${v.geoValue}'`).join(',') : -1}))`)
     const notIds: Array<string> = []
     if (state.gisParams.default.feature) {
       notIds.push(`'${state.gisParams.default.feature.getId()}'`)
@@ -700,6 +767,43 @@ const mutations = {
       })
       state.gisParams.qy.analysisDeviceLayer.setSource(tileWMS)
     }
+  },
+  SET_GIS_ANALYSIS(state, {wkt, center}) {
+    state.analysis.wkt = wkt
+    state.analysis.power = []
+    state.analysis.device = []
+    state.analysis.loading = true
+    axios({
+      url: state.element.layer.getSource().getUrls()[0],
+      method: 'get',
+      params: {
+        service: 'WFS',
+        version: '1.0.0',
+        request: 'GetFeature',
+        typename: 'mysqlGeo:stg_view_deviceinfo_df_value1,mysqlGeo:stg_view_deviceinfo_df_value2,mysqlGeo:stg_view_deviceinfo_df_value3',
+        srsName: 'EPSG:4326',
+        outputFormat: 'application/json',
+        CQL_FILTER: `INTERSECTS(location, ${wkt})`
+      }
+    }).then(res => {
+      const powerArr: any = []
+      const deviceArr: any = []
+      res.data.features.forEach(v => {
+        if (['gal', 'shl', 'myl'].includes(v.properties.typeValue)) {
+          deviceArr.push({
+            name: v.properties.name,
+            status: v.properties.online === '1' ? '在线' : '离线',
+            type: store.getters['dictionary/elementTypeMap'].get(v.properties.typeValue),
+            distanceValue: turf.distance(center, [Number(v.geometry.coordinates[0]), Number(v.geometry.coordinates[1])], {units: 'kilometers'}).toFixed(3),
+            distance: turf.distance(center, [Number(v.geometry.coordinates[0]), Number(v.geometry.coordinates[1])], {units: 'kilometers'}).toFixed(2) + 'km'
+          })
+        }
+      })
+      state.analysis.device = deviceArr.sort((a, b) => a.distanceValue - b.distanceValue)
+      state.analysis.loading = false
+    }).catch(() => {
+      state.analysis.loading = false
+    })
   }
 }
 

+ 6 - 1
src/views/gis/business/common/business-main.vue

@@ -5,7 +5,7 @@
       <div class="business-main-com_content-head">
         {{title}}
         <div class="close __hover">
-          <SvgIcon name="close_2" size="18" @click="$router.push('/gis/index')"/>
+          <SvgIcon name="close_2" size="18" @click="toIndex"/>
         </div>
       </div>
       <slot/>
@@ -44,10 +44,15 @@ export default defineComponent({
     const state = reactive({
       expend: true
     })
+    const toIndex = () => {
+      store.commit('gis/SET_GIS_ELEMENT', ['lgszyjkscsb', 'jgzzmgs', 'lgsjkyfl', 'galsb', 'shlsb', 'mylsb'])
+      router.push('/gis/index')
+    }
     onMounted(() => {
     })
     return {
       ...toRefs(state),
+      toIndex
     }
   },
 })

+ 43 - 17
src/views/gis/business/enterprise/index.vue

@@ -125,7 +125,7 @@ import BusinessMainCom from '../common/business-main.vue'
 import FocusContentCom from '../common/focus-content.vue'
 import PieSimpleChartCom from '../common/pie-simple-chart.vue'
 import StatisticTitleCom from '../common/statistic-title.vue'
-import {enterpriseQuery, staticsQuery} from "@/api/modules/enterprise";
+import axios from "axios";
 
 export default defineComponent({
   name: '',
@@ -226,32 +226,58 @@ export default defineComponent({
       })
     }
     const handleClick = (item) => {
-      const qyLayer = store.state.gis.map.getLayers().getArray().filter(v => v.get('layerName') === 'qy')?.[0]
-      if (qyLayer) {
-        const f = qyLayer.getSource().getFeatureById(item.id)
-        if (f) {
-          if (item.id === store.state.gis.activeQyId) {
-            f.get('reset')()
+      let elementId = ''
+      switch (item.type_value) {
+        case 'lgszyjkscsb': elementId = `1-${item.id}`
+              break
+        case 'jgzzmgs': elementId = `2-${item.id}`
+              break
+        case 'lgsjkfzl': elementId = `3-${item.id}`
+              break
+      }
+      if (elementId === store.state.gis.gisParams.qy.feature?.getId()) {
+        store.state.gis.gisParams.qy.overlay.setPosition(store.state.gis.gisParams.qy.feature.getGeometry().getCoordinates())
+        store.state.gis.map.getView().animate({
+          center: store.state.gis.gisParams.qy.feature.getGeometry().getCoordinates(),
+          zoom: store.state.gis.gisParams.autoZoom,
+        });
+      } else {
+        axios({
+          url: store.state.gis.element.layer.getSource().getUrls()[0],
+          method: 'get',
+          params: {
+            service: 'WFS',
+            version: '1.0.0',
+            request: 'GetFeature',
+            typename: 'mysqlGeo:lgsqy_typeValue1,mysqlGeo:lgsqy_typeValue2,mysqlGeo:lgsqy_typeValue3',
+            srsName: 'EPSG:4326',
+            outputFormat: 'application/json',
+            CQL_FILTER: `elementId = '${elementId}'`
+          }
+        }).then(res => {
+          const item = res.data.features?.[0]
+          if (item) {
+            store.commit('gis/SET_GIS_PARAMS_QY_RESET')
+            store.commit('gis/SET_GIS_PARAMS_QY', {
+              wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
+              id: item.properties.elementId,
+              info: item.properties
+            })
           } else {
-            f.get('mockClick')()
-            store.state.gis.map.getView().animate({
-              center: f.getGeometry().getCoordinates(),
-              zoom: store.state.gis.map.getView().getMaxZoom(),
-            });
+            ElMessage.warning('未找到该企业位置!')
           }
-        } else {
-          ElMessage.warning('未找到该企业位置!')
-        }
+        })
       }
     }
     onMounted(() => {
       state.enterprise.form = JSON.parse(JSON.stringify(state.enterprise.tempForm))
       handleSearch()
       initStatistic()
-      console.log(123)
     })
     onActivated(() => {
-      console.log(456)
+      nextTick(() => {
+        store.commit('gis/SET_GIS_ELEMENT', ['lgszyjkscsb', 'jgzzmgs', 'lgsjkyfl'])
+      })
     })
     return {
       ...toRefs(state),

+ 25 - 89
src/views/gis/layout/tools/analysis.vue

@@ -19,13 +19,13 @@
         <div class="__cus-button-cancel __hover" @click="$emit('cancel')">取消</div>
       </div>
     </div>
-    <div class="content __box-shadow" v-if="cusTransfer.result.isInit">
+    <div class="content __box-shadow" v-if="cusTransfer.result.isInit" v-loading="$store.state.gis.analysis.loading">
       <div class="head-tab">
         <div class="head-tab-item __hover" :class="{active: cusTransfer.switchType === 'power'}" @click="cusTransfer.switchType = 'power'">
-          <SvgIcon name="search"/>处置力量({{ cusTransfer.result.power.data.length }}人)
+          <SvgIcon name="search"/>处置力量({{ $store.state.gis.analysis.power.length }}人)
         </div>
         <div class="head-tab-item __hover" :class="{active: cusTransfer.switchType === 'device'}" @click="cusTransfer.switchType = 'device'">
-          <SvgIcon name="search"/>设备({{ cusTransfer.result.device.data.length }}台)
+          <SvgIcon name="search"/>设备({{ $store.state.gis.analysis.device.length }}台)
         </div>
         <div class="head-tab-close __hover" @click="$emit('cancel')">
           <SvgIcon name="close_2" color="#0069FF" size="14"/>
@@ -54,9 +54,6 @@
                 :pageSize="cusTransfer.result.power.pageSize"
                 @handlePage="handlePagePower"
             >
-              <template #distance-column-value="{ scope }">
-                {{scope.row.distance < 1000 ? `${scope.row.distance}m` : `${(scope.row.distance / 1000).toFixed(1)}km`}}
-              </template>
             </CusTable>
           </div>
         </template>
@@ -82,9 +79,6 @@
                 :pageSize="cusTransfer.result.device.pageSize"
                 @handlePage="handlePageDevice"
             >
-              <template #distance-column-value="{ scope }">
-                {{scope.row.distance < 1000 ? `${scope.row.distance}m` : `${(scope.row.distance / 1000).toFixed(1)}km`}}
-              </template>
             </CusTable>
           </div>
         </template>
@@ -109,19 +103,14 @@ import {
 import {useStore} from 'vuex'
 import {useRouter, useRoute} from 'vue-router'
 import {ElMessage, ElMessageBox} from "element-plus";
-import * as source from "ol/source";
-import * as layer from "ol/layer";
 import * as interaction from "ol/interaction";
 import * as geom from 'ol/geom';
 import * as style from "ol/style";
-import * as proj from "ol/proj";
-import PointIcon from "@/assets/images/gis-layout/gis-layout-tools_tool-bz_icon.png";
 import * as ol from "ol";
-import {fromCircle} from "ol/geom/Polygon";
-import {unByKey} from "ol/Observable";
-import * as sphere from "ol/sphere";
 import SelectChartCom from "@/views/gis/layout/tools/select-chart.vue";
 import * as turf from "@turf/turf";
+import axios from "axios";
+import {formatPosition} from "@/utils/easyMap";
 
 export default defineComponent({
   name: '',
@@ -150,8 +139,6 @@ export default defineComponent({
           wkt: ''
         },
         analysisFeat: <any>null,
-        analysisLayer: <any>null,
-        // analysisModify: <any>null,
         analysisDraw: <any>null,
         switchType: 'power',
         result: {
@@ -174,9 +161,9 @@ export default defineComponent({
           device: {
             head: [
               {value: "name", label: "名称", show: true,},
-              {value: "status", label: "状态", show: true,},
-              {value: "type", label: "类型", show: true,},
-              {value: "distance", label: "距离", show: true,},
+              {value: "status", label: "状态", show: true, width: 60},
+              {value: "type", label: "类型", show: true, width: 90},
+              {value: "distance", label: "距离", show: true, width: 90},
             ],
             data: <any>[],
             pageNum: 1,
@@ -197,51 +184,12 @@ export default defineComponent({
       setCircle()
     }
     const initLayer = () => {
-      if (state.cusTransfer.analysisLayer) {
-        state.cusTransfer.analysisLayer.setVisible(true)
-        // if (state.cusTransfer.analysisModify) {
-        //   props.map.addInteraction(state.cusTransfer.analysisModify);
-        // }
+      store.state.gis.analysis.layer.setVisible(true)
+      if (store.state.gis.analysis.wkt) {
         if (state.cusTransfer.analysisDraw) {
           props.map.addInteraction(state.cusTransfer.analysisDraw);
         }
       } else {
-        const layerFlag = ['layerName', 'analysisDrawViewsLayer']
-        state.cusTransfer.analysisSource = new source.Vector(); //图层数据源
-        state.cusTransfer.analysisLayer = new layer.Vector({
-          zIndex: 10000,
-          source: state.cusTransfer.analysisSource,
-          style: [
-            new style.Style({
-              image: new style.Icon({
-                src: PointIcon,
-                displacement: [0, 24]
-              }),
-              stroke: new style.Stroke({
-                color: '#2860F1',
-                width: 2,
-                lineDash: [10, 10]
-              }),
-              fill: new style.Fill({
-                color: 'rgba(20, 129, 241, 0.1)',
-              }),
-            })
-          ]
-        });
-        state.cusTransfer.analysisLayer.set(layerFlag[0], layerFlag[1])
-        props.map.addLayer(state.cusTransfer.analysisLayer);
-        // state.cusTransfer.analysisModify = new interaction.Modify({
-        //   source: state.cusTransfer.analysisSource,
-        // });
-        // props.map.addInteraction(state.cusTransfer.analysisModify)
-        // state.cusTransfer.analysisModify.on('modifyend', evt => {
-        //   try {
-        //     const feat = evt.features.item(0)
-        //     getCircleParams(feat.getGeometry())
-        //   } catch {
-        //   }
-        // })
-
         let sketch;
         let helpTooltip;
         const createHelpTooltip = () => {
@@ -263,7 +211,7 @@ export default defineComponent({
         createHelpTooltip(); //创建帮助提示框
         //  标绘
         state.cusTransfer.analysisDraw = new interaction.Draw({
-          source: state.cusTransfer.analysisSource,//测量绘制层数据源
+          source: store.state.gis.analysis.source,//测量绘制层数据源
           type: 'Circle',  //几何图形类型
           style: new style.Style({
             stroke: new style.Stroke({
@@ -320,35 +268,21 @@ export default defineComponent({
         props.map.on('pointermove', pointerMoveHandler); //地图容器绑定鼠标移动事件,动态显示帮助提示框内容
       }
     }
-    const  setCircle = () => {
+    const setCircle = () => {
       const circle = turf.circle(state.cusTransfer.draw.center, state.cusTransfer.draw.radius, {steps: 32, units: 'kilometers'})
       state.cusTransfer.analysisFeat.setGeometry(new geom.Polygon(circle.geometry.coordinates))
     }
     const initData = () => {
-      state.cusTransfer.result.power.data = []
+      state.cusTransfer.result.isInit = true
       state.cusTransfer.result.power.pageNum = 1
-      state.cusTransfer.result.device.data = []
       state.cusTransfer.result.device.pageNum = 1
-      for (let i = 0; i <= 10000; i++) {
-        const obj1 = {
-          name: '王宝强' + i,
-          phone: '18976000123',
-          area: '海口市' + i,
-          distance: i
-        }
-        state.cusTransfer.result.power.data.push(obj1)
-        const obj2 = {
-          name: '505县道-新安村路口1-枪机-0110580_'+ i,
-          status: '在线',
-          type: 'galsb',
-          distance: i
-        }
-        state.cusTransfer.result.device.data.push(obj2)
-      }
-      state.cusTransfer.result.isInit = true
+      store.commit('gis/SET_GIS_ANALYSIS', {
+        center: state.cusTransfer.draw.center,
+        wkt: that.$easyMap.formatPosition.cpnTwpn(state.cusTransfer.analysisFeat.getGeometry().getCoordinates())
+      })
     }
     const powerTableFilterCpt = computed(() => {
-      return state.cusTransfer.result.power.data.filter(v => v.name.includes(state.cusTransfer.result.power.tempForm.text))
+      return store.state.gis.analysis.power.filter(v => v.name.includes(state.cusTransfer.result.power.form.text))
     })
     const powerTableDataCpt = computed(() => {
       return powerTableFilterCpt.value.slice((state.cusTransfer.result.power.pageNum - 1) * state.cusTransfer.result.power.pageSize, state.cusTransfer.result.power.pageNum * state.cusTransfer.result.power.pageSize)
@@ -368,7 +302,7 @@ export default defineComponent({
       onSearchPower()
     }
     const deviceTableFilterCpt = computed(() => {
-      return state.cusTransfer.result.device.data.filter(v => v.name.includes(state.cusTransfer.result.device.tempForm.text))
+      return store.state.gis.analysis.device.filter(v => v.name.includes(state.cusTransfer.result.device.form.text))
     })
     const deviceTableDataCpt = computed(() => {
       return deviceTableFilterCpt.value.slice((state.cusTransfer.result.device.pageNum - 1) * state.cusTransfer.result.device.pageSize, state.cusTransfer.result.device.pageNum * state.cusTransfer.result.device.pageSize)
@@ -387,19 +321,21 @@ export default defineComponent({
       }
       onSearchDevice()
     }
+    watch(() => state.cusTransfer, () => {
+      emit('update:transfer', state.cusTransfer)
+    }, { deep: true })
     onMounted(() => {
       if (props.transfer) {
         state.cusTransfer = props.transfer
       } else {
         emit('update:transfer', state.cusTransfer)
       }
+      state.cusTransfer.result.power.form = JSON.parse(JSON.stringify(state.cusTransfer.result.power.tempForm))
+      state.cusTransfer.result.device.form = JSON.parse(JSON.stringify(state.cusTransfer.result.device.tempForm))
       initLayer()
     })
     onUnmounted(() => {
-      state.cusTransfer.analysisLayer.setVisible(false)
-      // if (state.cusTransfer.analysisModify) {
-      //   props.map.removeInteraction(state.cusTransfer.analysisModify);
-      // }
+      store.state.gis.analysis.layer.setVisible(false)
       if (state.cusTransfer.analysisDraw) {
         props.map.removeInteraction(state.cusTransfer.analysisDraw);
       }

+ 305 - 0
src/views/gis/layout/tools/select-draw.ts

@@ -0,0 +1,305 @@
+import * as ol from 'ol'
+import * as style from 'ol/style'
+import * as layer from 'ol/layer'
+import * as source from 'ol/source'
+import * as geom from 'ol/geom'
+import {fromCircle} from 'ol/geom/Polygon';
+import * as proj from 'ol/proj'
+import * as interaction from 'ol/interaction'
+import * as coordinate from 'ol/coordinate'
+import * as control from 'ol/control'
+import * as sphere from 'ol/sphere'
+import { unByKey } from 'ol/Observable'
+import {createBox} from "ol/interaction/Draw";
+import {Circle, LineString, Polygon} from "ol/geom";
+import {formatPosition} from '@/utils/easyMap'
+
+const layerFlag = ['layerName', 'selectDrawLayer']
+let drawTooltipElement;
+let drawHelpTooltipElement;
+const typeMapper = new Map([
+    ['line', 'LineString'],
+    ['rectangle', 'LineString'],
+    ['polygon', 'Polygon'],
+    ['circle', 'Circle'],
+])
+let oldDrawFeature
+/**
+ *
+ * @param map
+ * @param typeSelect    line线,rectangle矩形,polygon多边形,circle圆形
+ */
+export default function SelectDraw (map, typeSelect) {
+    return new Promise((resolve, reject) => {
+        if (!drawTooltipElement) {
+            let _source
+            const realLayer = map.getLayers().getArray().filter(v => v.get(layerFlag[0]) === layerFlag[1])
+            if (realLayer[0]) {
+                _source = realLayer[0].getSource()
+            } else {
+                _source = new source.Vector(); //图层数据源
+                const _vector = new layer.Vector({
+                    zIndex: 6,
+                    source: _source,
+                    style: new style.Style({ //图层样式
+                        fill: new style.Fill({
+                            color: 'rgba(46,129,255,0.15)' //填充颜色
+                        }),
+                        stroke: new style.Stroke({
+                            color: '#2E81FF',  //边框颜色
+                            width: 2,   // 边框宽度
+                            lineDash: [10, 10]
+                        }),
+                        image: new style.Circle({
+                            radius: 7,
+                            fill: new style.Fill({
+                                color: '#ffcc33'
+                            })
+                        })
+                    })
+                });
+                _vector.set(layerFlag[0], layerFlag[1])
+                map.addLayer(_vector);
+            }
+            let sketch;
+            let helpTooltip;
+            // let measureTooltip;
+            let continueMsg = '双击结束标绘';
+            const geodesicCheckbox = true;//测地学方式对象
+            const createMeasureTooltip = () => {
+                const id = 'selectDrawTooltipElementId'
+                if (drawTooltipElement) {
+                    map.removeOverlay(map.getOverlayById(id))
+                    drawTooltipElement.parentNode.removeChild(drawTooltipElement);
+                }
+                drawTooltipElement = document.createElement('div');
+                drawTooltipElement.className = 'tooltip tooltip-measure';
+                // measureTooltip = new ol.Overlay({
+                //     id,
+                //     element: drawTooltipElement,
+                //     offset: [0, -15],
+                //     positioning: 'bottom-center'
+                // });
+                // map.addOverlay(measureTooltip);
+            }
+            const createHelpTooltip = () => {
+                const id = 'selectDrawHelpTooltipElementId'
+                if (drawHelpTooltipElement) {
+                    map.removeOverlay(map.getOverlayById(id))
+                    drawHelpTooltipElement.parentNode.removeChild(drawHelpTooltipElement);
+                }
+                drawHelpTooltipElement = document.createElement('div');
+                drawHelpTooltipElement.className = 'tooltip hidden';
+                helpTooltip = new ol.Overlay({
+                    id,
+                    element: drawHelpTooltipElement,
+                    offset: [15, 0],
+                    positioning: 'center-left'
+                });
+                map.addOverlay(helpTooltip);
+            }
+            const formatLength = (line) => {
+                // 获取投影坐标系
+                const sourceProj = map.getView().getProjection();
+                // ol/sphere里有getLength()和getArea()用来测量距离和区域面积,默认的投影坐标系是EPSG:3857, 其中有个options的参数,可以设置投影坐标系
+                const length = sphere.getLength(line, {projection: sourceProj});
+                // const length = getLength(line);
+                let output;
+                if (length > 100) {
+                    const km = Math.round((length / 1000) * 100) / 100;
+                    output = `${km} 千米 <br>${parseFloat(String(km * 0.53995)).toFixed(2)} 海里`;
+                } else {
+                    output = `${Math.round(length * 100) / 100} m`;
+                }
+                return output;
+            };
+            //获取圆的面积
+            const getCircleArea = (circle, projection) => {
+                const P = 3.14
+                const radius = getCircleRadius(circle, projection)
+                return P * radius * radius
+            }
+//获取圆的半径
+            const getCircleRadius = (circle, projection) => {
+                return circle.getRadius() * projection.getMetersPerUnit()
+            }
+            const formatArea = (polygon, type= 'polygon') => {
+                let area
+                const sourceProj = map.getView().getProjection();
+                // 获取投影坐标系
+                if (type === 'polygon') {
+                    area = sphere.getArea(polygon, {
+                        projection: sourceProj,
+                    });
+                } else if (type === 'circle') {
+                    area = getCircleArea(polygon, sourceProj)
+                }
+                let output;
+                if (area > 10000) {
+                    const km = Math.round((area / 1000000) * 100) / 100;
+                    output = `${km} 平方公里<br>${parseFloat(String(km * 0.38610)).toFixed(
+                      2
+                    )} 平方英里`;
+                } else {
+                    output = `${Math.round(area * 100) / 100} ` + " m<sup>2</sup>";
+                }
+                return output;
+            };
+            const addInteraction = () => {
+                const id = 'selectDrawName'
+                const draw = new interaction.Draw({
+                    source: _source,//测量绘制层数据源
+                    // @ts-ignore
+                    type: typeMapper.get(typeSelect),  //几何图形类型
+                    // @ts-ignore
+                    geometryFunction: typeSelect === 'rectangle' ? createBox() : null,
+                    style: new style.Style({
+                        fill: new style.Fill({
+                            color: "rgba(46,129,255,0.15)",
+                        }),
+                        stroke: new style.Stroke({
+                            color: "#2E81FF",
+                            width: 2,
+                            lineDash: [10, 10]
+                        }),
+                        image: new style.Circle({
+                            radius: 5,
+                            stroke: new style.Stroke({
+                                color: "rgba(0, 0, 0, 0.7)",
+                            }),
+                            fill: new style.Fill({
+                                color: "rgba(255, 255, 255, 0.2)",
+                            }),
+                        }),
+                    }),
+                });
+                draw.set(id, id)
+                createMeasureTooltip(); //创建测量工具提示框
+                createHelpTooltip(); //创建帮助提示框
+                map.addInteraction(draw);
+                let listener;
+                //绑定交互绘制工具开始绘制的事件
+                const drawstartHandle = (evt) => {
+                    sketch = evt.feature; //绘制的要素
+                    let tooltipCoord = evt.coordinate;// 绘制的坐标
+                    //绑定change事件,根据绘制几何类型得到测量长度值或面积值,并将其设置到测量工具提示框中显示
+                    listener = sketch.getGeometry().on('change', function (evt) {
+                        const geom = evt.target
+                        let output;
+                        if (geom.getType() === 'LineString') {
+                            output = formatLength(geom);//长度值
+                            tooltipCoord = geom.getLastCoordinate();//坐标
+                        } else if (geom.getType() === 'Polygon') {
+                            output = formatArea(geom);//面积值
+                            tooltipCoord = geom.getInteriorPoint().getCoordinates();//坐标
+                        } else if (geom.getType() === 'Circle') {
+                            output = formatArea(geom, 'circle');//面积值
+                            tooltipCoord = geom.getCenter()
+                        }
+                        drawTooltipElement.innerHTML = output;//将测量值设置到测量工具提示框中显示
+                        // measureTooltip.setPosition(tooltipCoord);//设置测量工具提示框的显示位置
+                    });
+                }
+                draw.on('drawstart', drawstartHandle);
+                //绑定交互绘制工具结束绘制的事件
+                const copy = (value) => {
+                    const str = document.createElement('input')
+                    str.setAttribute('value', value)
+                    document.body.appendChild(str)
+                    str.select()
+                    document.execCommand('copy')
+                    document.body.removeChild(str)
+                }
+                const drawendHandle = (evt) => {
+                    map.removeInteraction(map.getInteractions().getArray().filter(v => v.get(id) === id)[0]);
+                    // const del = document.createElement("div");
+                    // del.className = "lineDel";
+                    // drawTooltipElement.append(del);
+                    // del.onclick = () => {
+                    //     _source.removeFeature(evt.feature)
+                    //     const b = del.parentElement.parentElement
+                    //     b.parentElement.removeChild(b);
+                    //     const g = evt.feature.getGeometry()
+                    //     if (g.getType() === 'LineString') {
+                    //         const w = `LINESTRING(${g.getCoordinates().map(v => v[0] + ' ' + v[1]).join(',')})`
+                    //         copy(w)
+                    //     } else if (g.getType() === 'Polygon') {
+                    //         const w = `POLYGON(${g.getCoordinates().map(v => '(' + v.map(c => c[0] + ' ' + c[1]) + ')').join(',')})`
+                    //         copy(w)
+                    //     }
+                    // };
+                    // drawTooltipElement.className = 'tooltip tooltip-static'; //设置测量提示框的样式
+                    // measureTooltip.setOffset([0, -7]);
+                    // 标绘的时候不需要最终结果dom
+                    map.removeOverlay(map.getOverlayById('selectDrawHelpTooltipElementId'))
+                    // drawTooltipElement.parentNode.removeChild(drawTooltipElement);
+                    sketch = null; //置空当前绘制的要素对象
+                    drawTooltipElement = null; //置空测量工具提示框对象
+                    drawHelpTooltipElement.parentNode.removeChild(drawHelpTooltipElement);
+                    drawHelpTooltipElement = null; //置空测量工具提示框对象
+                    unByKey(listener);
+                    draw.un('drawstart', drawstartHandle);
+                    draw.un('drawend', drawendHandle);
+                    map.removeInteraction(map.getInteractions().getArray().filter(v => v.get(id) === id)[0]);
+                    map.un('pointermove', pointerMoveHandler)
+                    if (oldDrawFeature) {
+                        _source.removeFeature(oldDrawFeature)
+                    }
+                    oldDrawFeature = evt.feature
+                    const gm = oldDrawFeature.getGeometry()
+                    let wkt = ''
+                    const gType = gm.getType()
+                    if (gType === 'Polygon') {
+                        wkt = formatPosition.cpnTwpn(gm.getCoordinates())
+                    } else if (gType === 'LineString') {
+                        wkt = formatPosition.clTwl(gm.getCoordinates())
+                    } else if (gType === 'Circle') {
+                        const circlePoly = fromCircle(gm, 128)
+                        oldDrawFeature.setGeometry(circlePoly)
+                        wkt = formatPosition.cpnTwpn(circlePoly.getCoordinates())
+                    }
+                    resolve({feature: oldDrawFeature, wkt: wkt})
+                }
+                draw.on('drawend', drawendHandle);
+            }
+            addInteraction(); //调用加载绘制交互控件方法,添加绘图进行测量
+            const pointerMoveHandler = (evt) => {
+                if (evt.dragging) {
+                    return;
+                }
+                let helpMsg = '单击开始标绘';//当前默认提示信息
+                //判断绘制几何类型设置相应的帮助提示信息
+                if (sketch) {
+                    const geom = sketch.getGeometry()
+                    helpMsg = continueMsg;
+                    // if (geom.getType() === 'Polygon') {
+                    //     helpMsg = continueMsg; //绘制多边形时提示相应内容
+                    // } else if (geom.getType() === 'LineString') {
+                    //     helpMsg = continueMsg; //绘制线时提示相应内容
+                    // }
+                }
+                drawHelpTooltipElement.innerHTML = helpMsg; //将提示信息设置到对话框中显示
+                helpTooltip.setPosition(evt.coordinate);//设置帮助提示框的位置
+                drawHelpTooltipElement.classList.remove('hidden');//移除帮助提示框的隐藏样式进行显示
+            };
+            map.on('pointermove', pointerMoveHandler); //地图容器绑定鼠标移动事件,动态显示帮助提示框内容
+            //地图绑定鼠标移出事件,鼠标移出时为帮助提示框设置隐藏样式
+            try {
+                map.getViewport().on('mouseout', () => {
+                    drawHelpTooltipElement.addClass('hidden');
+                });
+            } catch (e) {
+            }
+        } else {
+            reject('正在标绘中,请勿重复操作!')
+        }
+    })
+}
+
+export const SelectDrawClear = (map) => {
+    const realLayer = map.getLayers().getArray().filter(v => v.get(layerFlag[0]) === layerFlag[1])
+    if (realLayer[0]) {
+        realLayer[0].getSource().clear()
+        oldDrawFeature = null
+    }
+}

+ 97 - 60
src/views/gis/layout/tools/select.vue

@@ -4,15 +4,15 @@
       <div class="tools">
         <div class="label">空间选择:</div>
         <div class="right">
-          <div class="item __hover" :class="{active: selectParams.type === 'circle'}" @click="mapDraw('circle')">
+          <div class="item __hover" :class="{active: cusTransfer.selectParams.type === 'circle'}" @click="mapDraw('circle')">
             <img src="@/assets/images/gis-layout/gis-layout-tools_select-circle.png" alt=""/>圆形
           </div>
           <div class="line"/>
-          <div class="item __hover" :class="{active: selectParams.type === 'rectangle'}" @click="mapDraw('rectangle')">
+          <div class="item __hover" :class="{active: cusTransfer.selectParams.type === 'rectangle'}" @click="mapDraw('rectangle')">
             <img src="@/assets/images/gis-layout/gis-layout-tools_select-rectangle.png" alt=""/>矩形
           </div>
           <div class="line"/>
-          <div class="item __hover" :class="{active: selectParams.type === 'polygon'}" @click="mapDraw('polygon')">
+          <div class="item __hover" :class="{active: cusTransfer.selectParams.type === 'polygon'}" @click="mapDraw('polygon')">
             <img src="@/assets/images/gis-layout/gis-layout-tools_select-polygon.png" alt=""/>多边形
           </div>
           <div class="line"/>
@@ -22,7 +22,7 @@
         </div>
       </div>
     </div>
-    <div class="result __box-shadow" v-if="selectParams.wkt">
+    <div class="result __box-shadow" v-if="cusTransfer.selectParams.wkt">
       <div class="head">查询结果</div>
       <div class="chart">
         <SelectChartCom :data="hasTypeCpt"/>
@@ -34,7 +34,7 @@
               :span="24"
               link="select"
               label="类型:"
-              v-model:param="result.tempForm.type"
+              v-model:param="cusTransfer.result.tempForm.type"
               :options="hasTypeCpt"
           />
           <div class="two">
@@ -42,7 +42,7 @@
                 labelWidth="50"
                 :span="24"
                 label="搜索:"
-                v-model:param="result.tempForm.name"
+                v-model:param="cusTransfer.result.tempForm.name"
             />
             <div class="__cus-buttons-2">
               <div class="__cus-button-submit __hover" @click="onSearch">搜索</div>
@@ -50,19 +50,16 @@
             </div>
           </div>
         </div>
-        <div class="table">
+        <div class="table" v-loading="cusTransfer.result.table.loading">
           <CusTable
               ref="ref_cusTable"
               :tableData="resultTableDataCpt"
-              :tableHead="result.table.head"
+              :tableHead="cusTransfer.result.table.head"
               :total="resultTableFilterCpt.length"
-              :page="result.table.pageNum"
-              :pageSize="result.table.pageSize"
+              :page="cusTransfer.result.table.pageNum"
+              :pageSize="cusTransfer.result.table.pageSize"
               @handlePage="handlePage"
           >
-            <template #type-column-value="{ scope }">
-              {{$store.getters['dictionary/elementTypeMap'].get(scope.row.type) ?? scope.row.type}}
-            </template>
           </CusTable>
         </div>
       </div>
@@ -81,12 +78,14 @@ import {
   getCurrentInstance,
   ComponentInternalInstance,
   toRefs,
-  nextTick
+  nextTick, onUnmounted
 } from 'vue'
 import {useStore} from 'vuex'
 import {useRouter, useRoute} from 'vue-router'
 import {ElMessage, ElMessageBox} from "element-plus";
 import SelectChartCom from './select-chart.vue'
+import axios from "axios";
+import SelectDraw, {SelectDrawClear} from "./select-draw";
 
 export default defineComponent({
   name: '',
@@ -99,7 +98,8 @@ export default defineComponent({
     },
     mapFunc: <any>{
       required: true
-    }
+    },
+    transfer: {}
   },
   setup(props, {emit}) {
     const store = useStore();
@@ -107,74 +107,93 @@ export default defineComponent({
     const route = useRoute();
     const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
     const state = reactive({
-      selectParams: {
-        type: '',
-        wkt: ''
-      },
-      result: {
-        form: {},
-        tempForm: {
+      transfer: <any>props.transfer,
+      cusTransfer: <any>{
+        selectParams: {
           type: '',
-          name: ''
+          wkt: ''
         },
-        table: {
-          head: [
-            {value: "type", label: "类型", show: true, align: 'left', width: 100},
-            {value: "name", label: "名称", show: true, align: 'left'},
-          ],
-          data: <any>[],
-          pageNum: 1,
-          pageSize: 10,
+        result: {
+          form: {},
+          tempForm: {
+            type: '',
+            name: ''
+          },
+          table: {
+            head: [
+              {value: "type", label: "类型", show: true, align: 'left', width: 100},
+              {value: "name", label: "名称", show: true, align: 'left'},
+            ],
+            data: <any>[],
+            pageNum: 1,
+            pageSize: 10,
+            loading: false
+          }
         }
       }
     })
     const mapClear = () => {
-      props.mapFunc.drawClear()
-      state.selectParams = {
+      SelectDrawClear(props.map)
+      state.cusTransfer.selectParams = {
         type: '',
         wkt: ''
       }
-      state.result.table.data = []
-      state.result.table.pageNum = 1
-      state.result.form = {
+      state.cusTransfer.result.table.data = []
+      state.cusTransfer.result.table.pageNum = 1
+      state.cusTransfer.result.form = {
         type: '',
         name: ''
       }
     }
     const mapDraw = (type) => {
-      props.mapFunc.draw(type).then(({feature, wkt}) => {
-        state.selectParams.type = type
-        state.selectParams.wkt = wkt
+      SelectDraw(props.map, type).then(({feature, wkt}) => {
+        state.cusTransfer.selectParams.type = type
+        state.cusTransfer.selectParams.wkt = wkt
         initData()
       }).catch(() => {})
     }
     const initData = () => {
-      console.log(state.selectParams.wkt)
-      state.result.table.data = []
-      state.result.table.pageNum = 1
-      for (let i = 0; i <= 10000; i++) {
-        const dict = store.state.dictionary.elementTypeList
-        const p = dict[that.$util.randomNum(0, dict.length - 1)]
-        const obj = {
-          name: p.dictLabel + '_' + i,
-          type: p.dictValue,
-        }
-        state.result.table.data.push(obj)
+      state.cusTransfer.result.table.data = []
+      if (store.getters['gis/elementActiveArr'].length > 0) {
+        state.cusTransfer.result.table.loading = true
+        axios({
+          url: store.state.gis.element.layer.getSource().getUrls()[0],
+          method: 'get',
+          params: {
+            service: 'WFS',
+            version: '1.0.0',
+            request: 'GetFeature',
+            typename: store.getters['gis/elementActiveArr'].map(v => v.typeName).join(','),
+            srsName: 'EPSG:4326',
+            outputFormat: 'application/json',
+            CQL_FILTER: `INTERSECTS(location, ${state.cusTransfer.selectParams.wkt})`
+          }
+        }).then(res => {
+          state.cusTransfer.result.table.data = res.data.features.map(v => {
+            return {
+              name: v.properties.name,
+              type: store.getters['dictionary/elementTypeMap'].get(v.properties.typeValue)
+            }
+          })
+          state.cusTransfer.result.table.loading = false
+        }).catch(() => {
+          state.cusTransfer.result.table.loading = false
+        })
       }
     }
     const resultTableFilterCpt = computed(() => {
-      return state.result.table.data.filter(v => (!state.result.form.type || v.type === state.result.form.type) && v.name.includes(state.result.form.name))
+      return state.cusTransfer.result.table.data.filter(v => (!state.cusTransfer.result.form.type || v.type === state.cusTransfer.result.form.type) && v.name.includes(state.cusTransfer.result.form.name))
     })
     const resultTableDataCpt = computed(() => {
-      return resultTableFilterCpt.value.slice((state.result.table.pageNum - 1) * state.result.table.pageSize, state.result.table.pageNum * state.result.table.pageSize)
+      return resultTableFilterCpt.value.slice((state.cusTransfer.result.table.pageNum - 1) * state.cusTransfer.result.table.pageSize, state.cusTransfer.result.table.pageNum * state.cusTransfer.result.table.pageSize)
     })
     const handlePage = ({page, pageSize}: any) => {
-      state.result.table.pageNum = page
-      state.result.table.pageSize = pageSize
+      state.cusTransfer.result.table.pageNum = page
+      state.cusTransfer.result.table.pageSize = pageSize
     }
     const hasTypeCpt = computed(() => {
       const m = new Map()
-      state.result.table.data.forEach(v => {
+      state.cusTransfer.result.table.data.forEach(v => {
         if (m.has(v.type)) {
           m.set(v.type, m.get(v.type) + 1)
         } else {
@@ -185,25 +204,43 @@ export default defineComponent({
       m.forEach((v, k) => {
         arr.push({
           dictValue: k,
-          dictLabel: store.getters['dictionary/elementTypeMap'].get(k),
+          dictLabel: k,
           num: v
         })
       })
       return arr
     })
     const onSearch = () => {
-      state.result.table.pageNum = 1
-      state.result.form = JSON.parse(JSON.stringify(state.result.tempForm))
+      state.cusTransfer.result.table.pageNum = 1
+      state.cusTransfer.result.form = JSON.parse(JSON.stringify(state.cusTransfer.result.tempForm))
     }
     const onReset = () => {
-      state.result.tempForm = {
+      state.cusTransfer.result.tempForm = {
         name: '',
         type: ''
       }
       onSearch()
     }
+    watch(() => state.cusTransfer, () => {
+      emit('update:transfer', state.cusTransfer)
+    }, { deep: true })
     onMounted(() => {
-      state.result.form = JSON.parse(JSON.stringify(state.result.tempForm))
+      if (props.transfer) {
+        state.cusTransfer = props.transfer
+      } else {
+        emit('update:transfer', state.cusTransfer)
+      }
+      state.cusTransfer.result.form = JSON.parse(JSON.stringify(state.cusTransfer.result.tempForm))
+      const realLayer = props.map?.getLayers().getArray().filter(v => v.get('layerName') === 'selectDrawLayer')?.[0]
+      if (realLayer) {
+        realLayer.setVisible(true)
+      }
+    })
+    onUnmounted(() => {
+      const realLayer = props.map?.getLayers().getArray().filter(v => v.get('layerName') === 'selectDrawLayer')?.[0]
+      if (realLayer) {
+        realLayer.setVisible(false)
+      }
     })
     return {
       ...toRefs(state),