CzRger 1 年間 前
コミット
47fa3ce47e

+ 1 - 1
src/components/easyMap/func/measure.ts

@@ -21,7 +21,7 @@ let measureTooltipElement;
 let helpTooltipElement;
 let helpTooltipMap = new Map()
 let measureTooltipMap = new Map()
-let dom = []
+let dom: any = []
 const typeMapper = new Map([
     ['line', 'LineString'],
     ['rectangle', 'LineString'],

+ 64 - 61
src/store/modules/gis.ts

@@ -94,8 +94,6 @@ const state = {
     ],
     layer: null,
   },
-  l: null,
-  s: null
 }
 
 const getters = {
@@ -174,27 +172,6 @@ const mutations = {
     });
     state.gisParams.qy.analysisCircle = new ol.Feature()
     state.map.addLayer(state.gisParams.qy.analysisLayer)
-
-
-    // mock
-    state.s = new source.Vector()
-    state.l = new layer.Vector({
-      zIndex: 9999,
-      source: state.s,
-      style: [
-        new style.Style({
-          stroke: new style.Stroke({
-            color: '#000000',
-            width: 2,
-            lineDash: [10, 10]
-          }),
-          fill: new style.Fill({
-            color: 'rgba(20, 129, 241, 0.1)',
-          }),
-        })
-      ]
-    });
-    state.map.addLayer(state.l)
   },
   SET_GIS_PARAMS_QY(state, {wkt, id, info, config = {}}: any) {
     const {
@@ -242,9 +219,9 @@ const mutations = {
         newFeat.set('isAnalysis', isAnalysis)
         newFeat.set('resetStyle', () => {
           if (newFeat.get('isAnalysis')) {
-            newFeat.setStyle(newFeat.get('analysisStyle'))
+            newFeat.setStyle(newFeat.get('analysisActiveStyle'))
           } else {
-            newFeat.setStyle(newFeat.get('defaultStyle'))
+            newFeat.setStyle(newFeat.get('activeStyle'))
           }
         })
         newFeat.get('resetStyle')()
@@ -254,12 +231,28 @@ const mutations = {
         newFeat.setId(id)
         state.gisParams.qy.source.addFeature(newFeat)
         state.gisParams.qy.overlay.setPosition(newFeat.getGeometry().getCoordinates())
+        state.gisParams.qy.feature = newFeat
+        store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
       }
     }
   },
-  SET_GIS_PARAMS_DEFAULT_SB(state, {wkt, id, info, config}) {
+  SET_GIS_PARAMS_QY_RESET(state) {
+    if (state.gisParams.qy.layer) {
+      state.gisParams.qy.source.clear()
+      state.gisParams.qy.type = ''
+      state.gisParams.qy.info = {}
+      state.gisParams.qy.overlay.setPosition(undefined)
+      state.gisParams.qy.feature = null
+      //  周边设备清除样式
+      state.gisParams.qy.analysisSource.clear()
+      state.gisParams.default.feature.set('isAnalysis', false)
+      state.gisParams.default.feature.get('resetStyle')()
+      store.commit('gis/SET_GIS_ELEMENT')
+    }
+  },
+  SET_GIS_PARAMS_DEFAULT_SB(state, {wkt, id, info, config = {}}: any) {
     const {
       isAnalysis = false
     } = config
@@ -270,11 +263,11 @@ const mutations = {
         state.gisParams.default.info = JSON.parse(JSON.stringify(info))
         const newFeat: any = new format.WKT().readFeature(wkt)
         let type
-        if (info.type === '公安类') {
+        if (info.typeValue === 'gal') {
           type = 'galsb'
-        } else if (info.type === '社会类') {
+        } else if (info.typeValue === 'shl') {
           type = 'shlsb'
-        } else if (info.type === '民用类') {
+        } else if (info.typeValue === 'myl') {
           type = 'mylsb'
         }
         newFeat.set('defaultStyle', SbStyle.sbStyle(type))
@@ -284,9 +277,9 @@ const mutations = {
         newFeat.set('isAnalysis', isAnalysis)
         newFeat.set('resetStyle', () => {
           if (newFeat.get('isAnalysis')) {
-            newFeat.setStyle(newFeat.get('analysisStyle'))
+            newFeat.setStyle(newFeat.get('analysisActiveStyle'))
           } else {
-            newFeat.setStyle(newFeat.get('defaultStyle'))
+            newFeat.setStyle(newFeat.get('activeStyle'))
           }
         })
         newFeat.get('resetStyle')()
@@ -296,12 +289,14 @@ const mutations = {
         newFeat.setId(id)
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
+        state.gisParams.default.feature = newFeat
+        store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
       }
     }
   },
-  SET_GIS_PARAMS_DEFAULT_JQ(state, {wkt, id, info, config}) {
+  SET_GIS_PARAMS_DEFAULT_JQ(state, {wkt, id, info, config = {}}: any) {
     const {
       isAnalysis = false
     } = config
@@ -330,12 +325,14 @@ const mutations = {
         newFeat.setId(id)
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
+        state.gisParams.default.feature = newFeat
+        store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
       }
     }
   },
-  SET_GIS_PARAMS_DEFAULT_LG(state, {wkt, id, info, config}) {
+  SET_GIS_PARAMS_DEFAULT_LG(state, {wkt, id, info, config = {}}: any) {
     const {
       isAnalysis = false
     } = config
@@ -364,12 +361,14 @@ const mutations = {
         newFeat.setId(id)
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
+        state.gisParams.default.feature = newFeat
+        store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
       }
     }
   },
-  SET_GIS_PARAMS_DEFAULT_CZW(state, {wkt, id, info, config}) {
+  SET_GIS_PARAMS_DEFAULT_CZW(state, {wkt, id, info, config = {}}: any) {
     const {
       isAnalysis = false
     } = config
@@ -398,12 +397,14 @@ const mutations = {
         newFeat.setId(id)
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
+        state.gisParams.default.feature = newFeat
+        store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
       }
     }
   },
-  SET_GIS_PARAMS_DEFAULT_HCZ(state, {wkt, id, info, config}) {
+  SET_GIS_PARAMS_DEFAULT_HCZ(state, {wkt, id, info, config = {}}: any) {
     const {
       isAnalysis = false
     } = config
@@ -432,6 +433,8 @@ const mutations = {
         newFeat.setId(id)
         state.gisParams.default.source.addFeature(newFeat)
         state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
+        state.gisParams.default.feature = newFeat
+        store.commit('gis/SET_GIS_ELEMENT')
       } catch (e) {
         console.log('异常数据:', wkt, info, e)
       }
@@ -443,6 +446,8 @@ const mutations = {
       state.gisParams.default.type = ''
       state.gisParams.default.info = {}
       state.gisParams.default.overlay.setPosition(undefined)
+      state.gisParams.default.feature = null
+      store.commit('gis/SET_GIS_ELEMENT')
     }
   },
   SET_GIS_ELEMENT(state) {
@@ -460,7 +465,18 @@ const mutations = {
         }
       }
     })
-    const cql = `typeValue in (${arr.length > 0 ? arr.join(',') : -1})`
+    const cql: any = []
+    cql.push(`(typeValue in (${arr.length > 0 ? arr.join(',') : -1}))`)
+    const notIds: Array<string> = []
+    if (state.gisParams.default.feature) {
+      notIds.push(`'${state.gisParams.default.feature.getId()}'`)
+    }
+    if (state.gisParams.qy.feature) {
+      notIds.push(`'${state.gisParams.qy.feature.getId()}'`)
+    }
+    if (notIds.length > 0) {
+      cql.push(`(elementId not in (${notIds.join(',')}))`)
+    }
     const tileWMS = new source.TileWMS({
       url: `/${store.state.app.apiProxy.geoserverApi}/geoserver/mysqlGeo/wms`,
       params: {
@@ -469,7 +485,7 @@ const mutations = {
         "exceptions": 'application/vnd.ogc.se_inimage',
         refresh: new Date().getTime(),
         LAYERS: 'mysqlGeo:socialManagementElement',
-        CQL_FILTER: cql
+        CQL_FILTER: `(${cql.join(' and ')})`
       }
     })
     if (!state.element.layer) {
@@ -481,35 +497,17 @@ const mutations = {
       state.map.on('singleclick', e => {
         if (state.element.list.some(v => v.active)) {
           let isFeature = false
-          // e.map.forEachFeatureAtPixel(e.pixel, (feature) => {
-          //   console.log(feature)
-          //   isFeature = true
-          // }, {
-          //   hitTolerance: 0,
-          // });
+          e.map.forEachFeatureAtPixel(e.pixel, (feature) => {
+            isFeature = true
+          }, {
+            hitTolerance: 0,
+          });
           if (!isFeature) {
             const viewResolution = e.map.getView().getResolution()
-            console.log(viewResolution)
             const url = state.element.layer.getSource().getFeatureInfoUrl(e.coordinate, viewResolution, 'EPSG:4326', {
               'INFO_FORMAT': 'application/json',
               'FEATURE_COUNT': 10000
             })
-            console.log(url)
-            const BBOX = decodeURIComponent(url.split('?')[1].split('&').filter(v => v.includes('BBOX'))[0].split('=')[1]).split(',')
-            const wkt = [
-                [BBOX[0], BBOX[3]],
-                [BBOX[2], BBOX[3]],
-                [BBOX[2], BBOX[1]],
-                [BBOX[0], BBOX[1]],
-                [BBOX[0], BBOX[3]],
-            ]
-
-            const f = new format.WKT().readFeature(formatPosition.cpnTwpn([wkt]))
-
-            state.s.clear()
-            state.s.addFeature(f)
-
-            console.log(BBOX)
             if (url) {
               axios.get(url).then(res => {
                 if (res.status === 200) {
@@ -520,11 +518,16 @@ const mutations = {
                       console.log('企业')
                       store.commit('gis/SET_GIS_PARAMS_QY', {
                         wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
-                        id: item.properties.id,
+                        id: item.properties.elementId,
                         info: item.properties
                       })
                     } else if (['gal', 'shl', 'myl'].includes(item.properties.typeValue)) {
                       console.log('设备')
+                      store.commit('gis/SET_GIS_PARAMS_DEFAULT_SB', {
+                        wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
+                        id: item.properties.elementId,
+                        info: item.properties
+                      })
                     }
                   }
                 }

+ 0 - 1
src/style/index.scss

@@ -9,7 +9,6 @@
   line-height: 1;
   box-sizing: border-box;
   touch-action: none;
-
 }
 
 html, body {

+ 1 - 1
src/views/gis/map-info/overlay/default/sb.vue

@@ -13,7 +13,7 @@
       </div>
       <div class="sb-item">
         <div class="sb-item-label">状态:</div>
-        <div class="sb-item-value">{{$store.state.gis.gisParams.default.info?.online === '0' ? '在线' : '离线'}}</div>
+        <div class="sb-item-value">{{$store.state.gis.gisParams.default.info?.ONLINE === '0' ? '在线' : '离线'}}</div>
       </div>
       <div class="play-button __hover" @click="$store.commit('gis/SET_VIDEO_PARAMS', {
         show: true,

+ 1 - 5
src/views/gis/map-info/overlay/qy/index.vue

@@ -8,7 +8,7 @@
       <div class="qy-main-head">
         <div class="qy-main-head-tips">【企业】</div>
         <div class="qy-main-head-name">{{ qyInfoCpt.name }}</div>
-        <SvgIcon class="__hover" name="close_4" size="14" color="#8FFFFF" @click="onCloseQy"/>
+        <SvgIcon class="__hover" name="close_4" size="14" color="#8FFFFF" @click="$store.commit('gis/SET_GIS_PARAMS_QY_RESET')"/>
       </div>
       <div class="qy-main-tab">
         <template v-for="item in [
@@ -181,15 +181,11 @@ export default defineComponent({
       qyInfoCpt.value['5'].radiusTips = false
       onRadiusSubmit()
     }
-    const onCloseQy = () => {
-
-    }
     onMounted(() => {
     })
     return {
       ...toRefs(state),
       ref_dom,
-      onCloseQy,
       handleRangeInput,
       onRadiusSubmit,
       onRadiusReset,