Selaa lähdekoodia

全局搜索、视频收藏

Hwf 1 kuukausi sitten
vanhempi
commit
319d45b46c

+ 4 - 4
package-lock.json

@@ -39,7 +39,7 @@
         "proj4": "^2.11.0",
         "qrcodejs2": "^0.0.2",
         "screenfull": "6.0.2",
-        "uuid": "^11.0.3",
+        "uuid": "^11.1.0",
         "vue": "^3.5.13",
         "vue-pdf-embed": "^2.1.2",
         "vue-router": "^4.5.0",
@@ -14411,9 +14411,9 @@
       }
     },
     "node_modules/uuid": {
-      "version": "11.0.3",
-      "resolved": "https://registry.npmmirror.com/uuid/-/uuid-11.0.3.tgz",
-      "integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==",
+      "version": "11.1.0",
+      "resolved": "https://registry.npmmirror.com/uuid/-/uuid-11.1.0.tgz",
+      "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
       "funding": [
         "https://github.com/sponsors/broofa",
         "https://github.com/sponsors/ctavan"

+ 1 - 1
package.json

@@ -47,7 +47,7 @@
     "proj4": "^2.11.0",
     "qrcodejs2": "^0.0.2",
     "screenfull": "6.0.2",
-    "uuid": "^11.0.3",
+    "uuid": "^11.1.0",
     "vue": "^3.5.13",
     "vue-pdf-embed": "^2.1.2",
     "vue-router": "^4.5.0",

+ 2 - 2
src/api/emergencyCommandMap/communication.ts

@@ -50,8 +50,8 @@ export function getAvconDeviceTree(params) {
 // 视频会商-设备列表
 export function getAvconDeviceList(id, params) {
   return request({
-    url: '/api/videoResource/avcon/get_device_list/'+id,
+    url: '/api/videoResource/avcon/get_device_list/' + id,
     method: 'get',
     params: params
   });
-}
+}

+ 0 - 0
src/assets/images/dotIcon/48_samll2_hover_reservoir.png → src/assets/images/dotIcon/48_samll2_reservoir_hover.png


BIN
src/assets/images/dotIcon/common2.png


+ 1 - 1
src/components/FileUpload/index.vue

@@ -51,7 +51,7 @@
 <script setup lang="ts" name="FileUpload">
 import { propTypes } from '@/utils/propTypes';
 import { download2, globalHeaders } from '@/utils/request';
-import { v1 as uuidV1 } from 'uuid';
+import { v1 as uuidv1 } from 'uuid';
 import axios from 'axios';
 
 const props = defineProps({

+ 5 - 4
src/components/HKVideo/index2.vue

@@ -22,7 +22,7 @@
       <div class="video-header">
         <div class="label" :title="dot_data.name">{{ dot_data.name }}</div>
         <div class="video-header-right">
-          <i v-if="hiddenCollect" :class="dot_data.isTag ? 'collectFill' : 'collect'" @click.stop="handleCollect" />
+          <i v-if="!hiddenCollect" :class="dot_data.tag && dot_data.tag.length > 0 ? 'collectFill' : 'collect'" @click.stop="handleCollect" />
           <img class="video-enlarge" src="@/assets/images/video/enlarge.png" alt="" @click.stop="handleFullScreen" />
         </div>
       </div>
@@ -45,7 +45,7 @@
       </div>
     </div>
     <!--收藏弹窗-->
-    <VideoTagEdit v-if="showCollectDialog" :id="dot_data.id" v-model="showCollectDialog" :tags="tags" @update-video-tag="getData2" />
+    <VideoTagEdit v-if="showCollectDialog" :id="dot_data.video_code" v-model="showCollectDialog" :tags="tags" @update-video-tag="getData2" />
     <!--点击全屏弹窗-->
     <video-dialog
       v-if="showFullScreenDialog"
@@ -74,7 +74,6 @@ interface DotData {
   status?: string;
   poster?: string;
   collect?: boolean;
-  isTag?: boolean;
   tagLabels?: string;
 }
 interface Props {
@@ -182,6 +181,7 @@ const handleScreenshot = (name) => {
 let showCollectDialog = ref(false);
 // 展示收藏弹窗
 const handleCollect = () => {
+  tags.value = props.dot_data.tag;
   showCollectDialog.value = true;
 };
 // 更新标签
@@ -189,9 +189,10 @@ const getData = (data) => {
   emits('change', data);
 };
 const getData2 = () => {
-  getVideoTagInfo({ video_code: props.dot_data.id }).then((res) => {
+  getVideoTagInfo({ video_code: props.dot_data.video_code }).then((res) => {
     emits('change', res.data);
   });
+  showCollectDialog.value = false;
 };
 const getPlayer = (name) => {
   return videoPlayer.value.getPlayer(name);

+ 4 - 1
src/components/Map/YztMap/index.vue

@@ -338,6 +338,9 @@ const getMapUtils = () => {
 const getDrawTool = () => {
   return mapUtils.getDrawTool();
 };
+const addSearchMarker = (item) => {
+  return mapUtils.addSearchMarker(item);
+};
 // 加载事件
 onMounted(() => {
   init();
@@ -347,7 +350,7 @@ onMounted(() => {
 onUnmounted(() => {
   window.removeEventListener('resize', handleResize);
 });
-defineExpose({ getMap, getMapUtils, getDrawTool, addMarker, clearMarker });
+defineExpose({ getMap, getMapUtils, addSearchMarker, getDrawTool, addMarker, clearMarker });
 </script>
 
 <style scoped>

+ 1 - 11
src/components/Map/index.vue

@@ -36,7 +36,7 @@ const emits = defineEmits(['handleShowVideo', 'handleShowWarehouse', 'handleShow
 const containerRef = ref();
 const width = ref('100%');
 const height = ref('100%');
-let map, AMap, placeSearch;
+let map, AMap;
 
 // 鼠标绘制工具
 const drawTool = useDrawTool();
@@ -62,12 +62,6 @@ const mapUtils = useAMap({
     if (!['logical', 'vectorgraph'].includes(mapStore.activeMap)) {
       switchMap(mapStore.activeMap);
     }
-    placeSearch = new AMap.PlaceSearch({
-      pageSize: 30,
-      pageIndex: 1,
-      city: '0668',
-      extensions: 'base'
-    });
     map.on('zoomchange', zoomChangeHandler);
     // 添加遮罩
     if (mapStore.showMask) {
@@ -298,9 +292,6 @@ const setCenter = (item) => {
 const getMapUtils = () => {
   return mapUtils;
 };
-const getPlaceSearch = () => {
-  return placeSearch;
-};
 
 let inverseScale = ref({
   inverseScaleX: 1,
@@ -360,7 +351,6 @@ defineExpose({
   drawTool,
   handleHover,
   trackPlayback,
-  getPlaceSearch,
   getMapDomSize
 });
 </script>

+ 1 - 1
src/components/VideoTagEdit/index.vue

@@ -70,7 +70,7 @@ const handleAdd = () => {
     tagsId.push(item.value);
   });
   setVideoTag({ video_code: props.id, dict_value_list: tagsId }).then(() => {
-    showSuccessMsg('新增成功');
+    showSuccessMsg('修改成功');
     emits('updateVideoTag');
   });
 };

+ 40 - 10
src/utils/olMap/olMap.ts

@@ -102,8 +102,9 @@ export class olMap {
   private anyLine;
   private scale;
   // 标绘图层
-  private plotLayers = [];
+  private plotLayers = {};
   private addressMarker;
+  private addPoints = [];
 
   constructor(options) {
     this.options = options;
@@ -150,8 +151,8 @@ export class olMap {
       condition: click,
       style: null,
       filter: (feature, layer) => {
-        // 只有vectorLayer图层可选择
-        return layer === this.vectorLayer;
+        // 检查当前图层是否在 plotLayers 中
+        return Object.values(this.plotLayers).includes(layer);
       }
     });
     this.map.addInteraction(this.select);
@@ -161,7 +162,7 @@ export class olMap {
       const extData = feature.get('extData');
       if (!!feature) {
         this.clickMarker = feature;
-       if (['1', '2'].includes(extData.type)) {
+        if (['1', '2'].includes(extData.type)) {
           // 多点位 单点
           if (this.selectedFeature !== feature) {
             if (this.selectedFeature) {
@@ -665,6 +666,32 @@ export class olMap {
     }
     return style;
   }
+  // 添加搜索的标记的
+  addSearchMarker(item) {
+    const view = this.map.getView();
+    view.setZoom(18);
+    view.setCenter([Number(item.longitude), Number(item.latitude)]);
+    // 获取到上一次的搜索标记并移除
+    const index = this.markers.findIndex((m) => {
+      return m.dataType === 'search';
+    });
+    if (index > -1) {
+      this.markers.splice(index, 1);
+    }
+    if (!this.plotLayers['search']) {
+      this.plotLayers['search'] = new VectorLayer({
+        source: new VectorSource({
+          features: []
+        })
+      });
+      this.map.addLayer(this.plotLayers['search']);
+    } else {
+      this.plotLayers['search'].getSource().clear();
+    }
+    this.addMarker2({'search': item});
+    this.clickMarker = item;
+    this.options.onMarkerClick(item);
+  }
   addMarker(points) {
     this.clearMarker();
     const vectorSource = new VectorSource({
@@ -706,13 +733,16 @@ export class olMap {
     this.vectorLayer.setSource(clusterSource);
   }
   addMarker2(obj) {
-    this.clearMarker2('point2');
+    this.clearMarker2('point');
+    if (!!this.plotLayers['point']) {
+      this.markers = [];
+    }
     let hideInfoFlag = true;
     Object.keys(obj).forEach((key: string) => {
       const data = obj[key];
+      const name = key === 'search' ? 'search' : 'point';
       if (this.clickMarker) {
         const extData = this.clickMarker.get('extData');
-        console.log(extData.id, data.id);
         if (data.id === extData.id) {
           hideInfoFlag = false;
           data.isHover = true;
@@ -749,11 +779,11 @@ export class olMap {
             })
           })
         );
-        this.vectorLayer.getSource().addFeature(feature);
+        this.plotLayers[name].getSource().addFeature(feature);
         this.markers.push(data);
       } else {
         // 单个点
-        const iconConfig = iconList[data.dataType] || iconList.common;
+        const iconConfig = iconList[data.dataType] || (name === 'search' ? iconList.common2 : iconList.common);
         data.image = iconConfig.image;
         data.imageHover = iconConfig.imageHover;
         data.size = iconConfig.size;
@@ -792,7 +822,7 @@ export class olMap {
               })
             })
           );
-          this.vectorLayer.getSource().addFeature(feature);
+          this.plotLayers[name].getSource().addFeature(feature);
         };
         img.src = data.image; // 设置图片的 URL,触发加载
         this.markers.push(data);
@@ -821,7 +851,7 @@ export class olMap {
       });
       this.map.addLayer(this.plotLayers[name]);
     } else {
-      this.vectorLayer.getSource().clear();
+      this.plotLayers[name].getSource().clear();
       this.clickMarker = null;
       this.hideInfo();
     }

+ 6 - 15
src/utils/request.ts

@@ -28,12 +28,9 @@ const service = axios.create({
   baseURL: import.meta.env.VITE_APP_BASE_API,
   timeout: 50000
 });
-let hideMsg = false;
 // 请求拦截器
 service.interceptors.request.use(
   (config: InternalAxiosRequestConfig) => {
-
-    hideMsg = !!config.hideMsg;
     const isToken = config.headers?.isToken === false;
     // 是否需要防止数据重复提交
     // const isRepeatSubmit = config.headers?.repeatSubmit === false;
@@ -140,20 +137,14 @@ service.interceptors.response.use(
       }
       return Promise.reject('无效的会话,或者会话已过期,请重新登录。');
     } else if (code === HttpStatus.SERVER_ERROR) {
-      if (!hideMsg) {
-        showErrorMsg(msg);
-        return Promise.reject(new Error(msg));
-      }
+      showErrorMsg(msg);
+      return Promise.reject(new Error(msg));
     } else if (code === HttpStatus.WARN) {
-      if (!hideMsg) {
-        showWarningMsg(msg);
-        return Promise.reject(new Error(msg));
-      }
+      showWarningMsg(msg);
+      return Promise.reject(new Error(msg));
     } else if (code !== HttpStatus.SUCCESS) {
-      if (!hideMsg) {
-        showErrorMsg(msg);
-        return Promise.reject('error');
-      }
+      showErrorMsg(msg);
+      return Promise.reject('error');
     } else {
       return Promise.resolve(res.data);
     }

+ 1 - 1
src/views/emergencyCommandMap/LeftSection/Communication.vue

@@ -142,7 +142,7 @@
       </el-form>
     </Dialog>
   </div>
-  <CommunicationDialog v-model="communicationDialogState.showListDialog" :flag="flag" />
+  <CommunicationDialog v-if="communicationDialogState.showListDialog" v-model="communicationDialogState.showListDialog" :flag="flag" />
 </template>
 
 <script lang="ts" setup>

+ 0 - 2
src/views/emergencyCommandMap/RightSection/RenWuDengJi.vue

@@ -181,8 +181,6 @@ const fetchUsers = async (deptId) => {
     console.error('请求用户列表失败:', error);
   }
 };
-
-
 const handleUnitChange = async (newUnitName) => {
   const selectedUnit = filteredUnits.value.find((unit) => unit.unit_name === newUnitName);
   if (selectedUnit) {

+ 18 - 17
src/views/globalMap/LeftMenu.vue

@@ -121,8 +121,8 @@ import gcoord from 'gcoord';
 import useMapStore from '@/store/modules/map';
 
 const emits = defineEmits(['switchMap', 'clickMenu', 'selectSearchMarker', 'clearAllMenu']);
-const getPlaceSearch = inject('getPlaceSearch');
 const getMapUtils = inject('getMapUtils');
+const amapKey = 'e45d4caa2bef3c84714a2ed9b1e27d98';
 let mapUtils;
 const mapStore = useMapStore();
 // 左侧菜单
@@ -152,7 +152,7 @@ watch(
     immediate: true
   }
 );
-const changeSearchText = () => {
+const changeSearchText = async () => {
   if (!searchState.searchText) {
     searchState.showList = false;
     return;
@@ -165,22 +165,22 @@ const changeSearchText = () => {
       searchState.layerList = res.data.point_data;
       searchState.videoList = res.data.video_data;
     });
-    getPlaceSearch().search(searchState.searchText, (status, result) => {
-      if (!!result.poiList && result.poiList.pois && result.poiList.pois.length > 0) {
-        let arr = [];
-        const pois = result.poiList.pois;
-        arr = pois.map((item) => {
-          return {
-            dataType: 'search',
-            name: item.name,
-            address: item.address,
-            longitude: item.location.lng,
-            latitude: item.location.lat
-          };
-        });
-        searchState.resultList = arr;
-      }
+    const url = `https://restapi.amap.com/v5/place/text?key=${amapKey}&keywords=${searchState.searchText}`;
+    const response = await fetch(url);
+    const data = await response.json();
+    let arr = [];
+    arr = data.pois.map((item) => {
+      const location = item.location.split(',');
+      return {
+        dataType: 'search',
+        name: item.name,
+        address: item.address,
+        longitude: location[0],
+        latitude: location[1],
+        lnglat: location
+      };
     });
+    searchState.resultList = arr;
   }
 };
 
@@ -192,6 +192,7 @@ const selectSearchMarker = (item, type) => {
     data.longitude = lnglat[0];
     data.latitude = lnglat[1];
   }
+  data.type = '2';
   searchState.showList = false;
   emits('selectSearchMarker', data);
 };

+ 8 - 3
src/views/globalMap/data/mapData.ts

@@ -228,9 +228,9 @@ export const iconList = {
     size: [40, 44]
   },
   '48': {
-    image: getImageUrl('48_samll2_hover_reservoir.png'),
-    imageHover: getImageUrl('48_samll2_hover_reservoir_hover.png'),
-    size: [42, 44]
+    image: getImageUrl('48_samll2_reservoir.png'),
+    imageHover: getImageUrl('48_samll2_reservoir_hover.png'),
+    size: [40, 44]
   },
   '49': {
     image: getImageUrl('49_roof_pond.png'),
@@ -291,6 +291,11 @@ export const iconList = {
     image: getImageUrl('common.png'),
     imageHover: getImageUrl('common_hover.png'),
     size: [40, 44]
+  },
+  'common2': {
+    image: getImageUrl('common2.png'),
+    imageHover: getImageUrl('common2.png'),
+    size: [19, 31]
   }
 };
 

+ 0 - 5
src/views/globalMap/index.vue

@@ -343,10 +343,6 @@ const showDetail = (data, dataType) => {
 const getDrawTool = () => {
   return mapStore.isAMap ? mapRef.value.drawTool : mapUtils;
 };
-const getPlaceSearch = () => {
-  const domRef = mapStore.isAMap ? mapRef.value : map2Ref.value;
-  return !!domRef ? domRef.getPlaceSearch() : {};
-};
 const trackPlayback = (data) => {
   const domRef = mapStore.isAMap ? mapRef.value : mapUtils;
   if (!!domRef) {
@@ -580,7 +576,6 @@ provide('getMap', getMap);
 provide('trackPlayback', trackPlayback);
 provide('showDetail', showDetail);
 provide('getDrawTool', getDrawTool);
-provide('getPlaceSearch', getPlaceSearch);
 provide('initDataToPlay', initDataToPlay);
 provide('handleShowVideo2', handleShowVideo2);
 </script>