c:import 标记传值

前几天写xtree树结构,在最后使用了<c:import url="...do">去请求一个树结构,想传值,但是url参数中不能写变量,真是太郁闷了,最后找到方法,就是在<c:import>中,使用 <c:param >标记,可以解决,看示例

  <c:import url="/holiday.do?method=tree" >
   <c:param name="key" value="<%=cid%>"/>
  </c:import>

在action中拿key就获得了,这么简单的问题,想了好几天,哎~知识系统不健全..

<template> <div class="map-content"> <mapConfigs></mapConfigs> <myModal :modalVisible.sync="showModal" :isWarning="isWarning" :isArea="isArea" :resouceInfo="resouceInfo" @cancel="cancel" :hostDetailList="hostDetailList" :systemDetailList="systemDetailList"></myModal> <realPlayer :isShow="showVideoModal" :resouceInfo="resouceInfo" @cancel="cancel" :hostDetailList="hostDetailList"></realPlayer> <btnComponent :curBitmapMakerList="curBitmapMakerList" :map="map" :markerResourceFlooterIcon="markerResourceFlooterIcon" :fireControlLayerArr="fireControlLayerArr" :selectNode="selectNode" :mapState="mapStatePreparation"></btnComponent> </div> </template> <script> import mapConfigs from "@/components/scfComponents/emapComponentsV1_4_0/mapConfigBase"; // import factory from "./factory"; import layers from './layers'; import {mapApi} from "EvoEmap" import {nofifyClient} from '@/common/js/client' // 点位悬浮点击 import popup from "./mixin/popup"; // 添加点位到地图 import indexAddMakeToMap from "./mixin/indexAddMakeToMap"; // 报警点位循环变换 类 import keyMakerLoopClass from "./classFunction/keyMakerLoopClass"; // 创建报警队列中心 类 import evenQueueFunctionClass from "./classFunction/evenQueueFunctionClass"; // 热区 设备点位 数据组装 类 import waitAllMakeInfoDoneHandleClass from "./classFunction/waitAllMakeInfoDoneHandleClass"; // 添加 图层方法 import addNewLayerFunction from "./classFunction/addNewLayerFunction"; // 清除feature 方法 import clearAllLayersFunction from "./classFunction/clearAllLayersFunction"; // diff 对比点位信息 import diffMakerInfo from "./classFunction/diffMakerInfo"; import btnComponent from "./components/buttonComponent"; import myModal from "./components/myModal"; import realPlayer from "@/components/scfComponents/videoPlayers/realPlayer"; export default { mixins: [popup, indexAddMakeToMap], props: { curWarningMarker: { type: Object, default: () => ({}) }, isWarningDialog: { type: Boolean, default: false }, showTree: { type: Boolean, default: true }, selectNode: { type: Object, default: () => { return {}; } }, pollingMarker: { type: String, default: () => '', }, }, components: { mapConfigs, myModal, realPlayer, btnComponent }, data() { return { map: null, curBitmap: null, refsEmap: null, resouceInfo: {}, allLayers: layers, markerResourceList:[], //所有的点位资源 allLayersArr: [],//集成测试的所有图层 markerResourceFlooterIcon: [], //底部展示的点位资源 // 其它消防设备 fireControlLayerArr:[{ layerCode: 'fireControlLayer' }], // 和消防相关的点位资源 // 记录所有的 点位 allMarkerLayers:[ {layerCode: 'hotareaLayer'}, {layerCode: 'videoLayer'}, {layerCode: 'fireControlLayer'}, ], curBitmapMakerList: {}, statusObj:{ 1: 'alarm', 2: 'offline', 3: 'shield', 4: 'fault', 5: 'nomal', }, mapStatePreparation:{}, // 监控地图状态 keyMakerLoop:{}, waitAllMakeInfoDone:{}, addNewLayer: addNewLayerFunction, clearAllLayers: clearAllLayersFunction, evenQueueClass: {},// ------------ 90175 ----报警逻辑 --- diffMakerInfo: new diffMakerInfo(), // 对比点位信息 propMark: 'dataWall' } }, watch: { dataWallMap(newVal, old) { console.log("dataWallMap change ", newVal) this.map = newVal // 监控地图状态 this.setMapStatePreparation(0) // 开始挂载点位的 事件 this.getMarkerLayers() // 开始挂载点位的 事件 this.customizeMapFunction() }, curBitmapObj(newVal, old) { this.curBitmap = newVal }, refsEmapObj(newVal, old) { this.refsEmap = newVal }, // 组织切换 selectNode: { deep: true, immediate: false, handler(val, oldVal) { let data = {id: null} if(oldVal){ data = oldVal } if(val.id && val.id !== data.id) { this.$store.commit("setOrgTreeNode", val); // 监控地图状态 this.setMapStatePreparation(6) } }, }, pollingMarker: { deep: true, immediate: true, handler(newVal) { // 90175 每一分钟 刷新一次当前图标的 状态信息 用于 更新坐标的报警状态 // console.log("pollingMarker ==newVal==",newVal); if(newVal && Object.keys(this.curBitmapMakerList).length){ // 监控地图状态 this.setMapStatePreparation(5) } }, }, // 地图点击事件回调 mapEventCallbackData: { deep: false, immediate: false, handler(newVal, oldVal) { console.log("mapEventCallbackData val ==", newVal); var {type, event, features} = newVal this.resouceInfo.clickType = '' if(type == 'dblclick' && features) { // 获取点位对象 let feature = features[0] // 如果是聚合点位 if(feature.isClusterFeature && feature.size === 1) { feature = feature.getProperties().features[0] } // 获取点位对象信息 let markerInfo = feature.getMarkerInfo() console.log("markerInfo ==", markerInfo); if(( ["fireControlLayer", "fireControlLayerAlarm", "fireControlLayerFault"].includes(markerInfo.layerCode)) && !markerInfo.channelType) { console.log('打开设备详情'); this.isArea = false; this.showModal = true; this.resouceInfo = markerInfo.info; this.resouceInfo.clickType = type } // 热区下钻 if (markerInfo.layerCode === "hotareaLayerAlarm") { console.log('热区下钻 hotareaLayerAlarm', markerInfo); if (markerInfo.id) { mapApi.BitmapApi.getBitmapInfo(markerInfo.id).then(data => { if (!data.isMain && !data.picId) { this.$message.warning(this.$t('emap.tips.no-picture-info')) return false } this.map.vuexCommit('EMAP_SET_CENTERMAP_ID', {id: markerInfo.id}) }) } } } }, }, // ---------------- 90175 ------------ 未来需要 在报警处理后 或者设备状态改变后 设备的报警及时的消失 ----------- mapConfigWarningInfo(val) { // console.log('mapConfigWarningInfo == ', val); // if (!this.showTree) { // return; // } // 报警逻辑 // this.evenQueueFunction(val) this.evenQueueClass.evenQueueFunction(val) }, // 获取推送的故障 pushFaultData: { deep: true, immediate: false, handler(newVal) { // console.log("pushFaultData ==", newVal); // this.evenQueueFunction(newVal.data) // 接收故障 this.evenQueueClass.evenQueueFunction(newVal.data) }, }, }, computed: { ...Vuex.mapState({ // 90175 --- dataWallMap: store => store.dataWallMap, pushFaultData: store => store.alarm.pushFaultData, mapConfigWarningInfo: store => store.mapConfigWarningInfo, curBitmapObj: store => store.curBitmapObj, refsEmapObj: store => store.refsEmapObj, mapEventCallbackData: store => store.mapEventCallbackData, // --- end--- }), }, methods: { /** * 关闭弹窗的函数 * @param {*} */ cancel() { this.showModal = false; this.showVideoModal = false; }, /** * 监听到地图的信息的变化 开始执行点位的 操作 ---- */ customizeMapFunction(){ var emap = this.map // 混入 的 popup 的 方法 用于悬浮 this.setMapEvent(emap.map, emap); }, // ---------------- 90175 第一步清楚地图 添加图层 ---------------- /** * * 1、 获取地图的图层 * */ // 获取地图的图层 getMarkerLayers() { mapApi.ConfigApi.getMarkerLayers().then(res => { if (typeof res !== 'undefined' && res.length > 0) { // 该图层分类要在哪种地图类型下展示 mapType : -1 都不显示(GPS类设备), 0-GIS地图下,1-光栅图下,2-都显示 let curMapMode = this.map.mapConfig.gisMode // "1": 光栅地图, "0": gis地图, "3":三维地图 // console.log(`当前的地图类型: ${curMapMode}`) let list = null var fireControlLayerArr = this.fireControlLayerArr.map(item => { return item.layerCode }) if(!this.markerResourceFlooterIcon.length){ let markerResourceFlooterIcon = [] // console.log('fireControlLayerArr', ['hotareaLayer', 'videoLayer', ...fireControlLayerArr]); if(curMapMode == "1" || curMapMode == "0" ) { list = res.filter((item) => { item.active = true return item.mapType < 3 && item.mapType !== -1 && ['hotareaLayer', 'videoLayer', ...fireControlLayerArr].indexOf(item.layerCode)> -1 }) this.allLayersArr = res.filter((item) => { item.active = true return ['hotareaLayer', 'videoLayer', ...fireControlLayerArr].indexOf(item.layerCode) == -1 }) markerResourceFlooterIcon = res.filter((item) => { item.active = true return item.mapType < 3 && item.mapType !== -1 && ['hotareaLayer', 'videoLayer', 'fireControlLayer'].indexOf(item.layerCode)> -1 }) } this.markerResourceFlooterIcon = [] let layerCode2index = { 'fireControlLayer': 0, 'videoLayer': 1, 'hotareaLayer': 2 } markerResourceFlooterIcon.forEach(element => { this.markerResourceFlooterIcon[layerCode2index[element.layerCode]] = element }); this.markerResourceList = list } this.waitAllMakeInfoDoneHandle() } }) }, /** * 整理数据并将marke 放置到地图上 */ waitAllMakeInfoDoneHandle(){ this.curBitmapMakerList = {} this.waitAllMakeInfoDone.waitAllMakeInfoDoneHandle(this.markerResourceList, this.map, this.selectNode, (res) => { if(localStorage.getItem("showConsole")){ console.log('this.waitAllMakeInfoDone waitAllMakeInfoDoneHandle'); } this.curBitmapMakerList = res this.setMapStatePreparation(3) }) }, // ----------------- end -------------- /** * 记录 地图 状态 * @param {*} state 状态 * * 0 dataWallMap 地图创建完成 * 1 addMarkeToMap 已将点位放在地图上 * 2 addNewLayer 已将图层放在地图上 * 3 waitAllMakeInfoDoneHandle 数据处理完成 放置图标之前 * 4 changeLayerOfFeature 完成图层切换后 * 5 pollingMarker 接受到 一分钟的轮询 * 6 selectNode 组织树切换 * 7 收到推送后处理信息 将 curBitmapMakerList 内部的点位的info 改变 */ setMapStatePreparation(state){ this.mapStatePreparation = { time: new Date().getTime(), state: state } this.setInfomation(state) }, setInfomation(state){ if(localStorage.getItem("showConsole")){ console.log('setMapStatePreparation==', state); } if(state === 0) { // 添加新的图层 // this.addNewLayer() this.addNewLayer(this.allLayers, this.map, (res) => { this.allMarkerLayers = res // 监控地图状态 this.setMapStatePreparation(2) }) this.keyMakerLoop.setMap(this.map) // 给报警循环地图 this.evenQueueClass.setMap(this.map) // 给报警推送处理地图 this.diffMakerInfo.setMap(this.map) // 给报对比点位信息地图 // mixin this.setShunt(false) // 切换地图重新判定 this.diffMakerInfo.initBitmapMakerList() //初始化数据 } if(state === 1){ } if(state === 2){ // 给报警队列中心 this.evenQueueClass.setAllMarkerLayers(this.allMarkerLayers) } if(state === 3){ // mixin 中的方法 添加点位到地图上 this.shuntInfo() } if(state == 4){ // 完成图层切换后 setMapStatePreparation 设置 1 用去去掉 点位的 名称 this.setMapStatePreparation(1) } if(state === 5){ // 第一版本逻辑是清除所有的 图层上的点位 但是 性能测试不通过,所以进行了 精准更新 diff 方法 // this.clearAllLayers(this.allMarkerLayers, this.map, () => { // this.waitAllMakeInfoDoneHandle() // }) this.waitAllMakeInfoDoneHandle() // if(this.pollingMarker.flag){ // this.waitAllMakeInfoDoneHandle() // } } if(state === 7){ // 这时点位信息发生了改变 这时就要即使赋给 diff // 将最新的点位信息 给 diff 类 setOldBitmapMakerList this.diffMakerInfo.setOldBitmapMakerList(this.curBitmapMakerList) this.setMapStatePreparation(1) } } // ------end -- }, created() { // 开始循环 this.keyMakerLoop = new keyMakerLoopClass() // console.log("this.keyMakerLoop ==", this.keyMakerLoop); this.keyMakerLoop.setAlarmMakerLoop() // 创建报警队列中心 this.evenQueueClass = new evenQueueFunctionClass() this.evenQueueClass.setMapStatePreparationFun(this.setMapStatePreparation) // console.log("this.evenQueueClass =", this.evenQueueClass); // 获取图层 上的所有点位 this.waitAllMakeInfoDone = new waitAllMakeInfoDoneHandleClass() // console.log("this.waitAllMakeInfoDone ==", this.waitAllMakeInfoDone); // 对比点位信息 // console.log('this.diffMakerInfo ==', this.diffMakerInfo); this.diffMakerInfo.setMapStatePreparationFun(this.setMapStatePreparation) } } </script> <style lang="less"> @import './mapControl.less'; @import "./emap.less"; .map-content{ .page{ display: none; } } </style>
最新发布
07-19
<think>这是一个Vue单文件组件(SFC),包含了一个地图展示和交互的功能。主要功能包括:地图配置、模态框显示、实时视频播放、点位管理、报警处理等。代码结构包括模板、脚本和样式三部分。 模板部分(template): - 包含地图配置组件(mapConfigs) - 模态框组件(myModal)用于显示设备详情或报警信息 - 实时播放器组件(realPlayer)用于播放视频 - 按钮组件(btnComponent)用于地图操作按钮 脚本部分(script): - 导入多个模块和类,包括地图配置、图层管理、报警处理等 - 使用mixins来复用点位悬浮点击、添加点位到地图等功能 - 定义了数据属性,如地图实例、当前点位、资源信息等 - 使用Vuex状态管理,通过computed属性获取状态 - 使用watch监听状态变化,如地图实例、当前点位、轮询标记、报警信息等 - 方法包括关闭弹窗、自定义地图功能、获取图层、处理点位数据、设置地图状态等 样式部分(style): - 引入外部less文件 主要功能点: 1. 地图初始化与配置 2. 图层管理:添加、清除图层 3. 点位管理:获取点位数据、更新点位状态、添加点位到地图 4. 报警处理:接收报警推送,更新点位状态,循环报警点位 5. 交互功能:点击点位显示详情,双击点位下钻或播放视频 代码中使用了多个自定义类来处理复杂逻辑: - keyMakerLoopClass: 处理报警点位的循环变换 - evenQueueFunctionClass: 报警事件队列处理 - waitAllMakeInfoDoneHandleClass: 热区设备点位数据组装 - addNewLayerFunction: 添加新图层 - clearAllLayersFunction: 清除所有图层 - diffMakerInfo: 点位信息差异对比 接下来,我将对代码进行详细解释,并针对一些关键部分进行说明。 由于代码较长,我将重点放在关键方法和逻辑上。</think>这个 Vue 组件是一个复杂的地图管理系统,集成了地图展示、点位管理、报警处理、视频监控等功能。下面我将详细解析核心功能并提供优化建议: ### 核心功能解析 1. **地图管理** - 使用 `mapApi` 控制地图 - 图层管理(热区层、视频层、消防设备层) - 点位状态管理(正常/报警/离线/故障) 2. **报警系统** - 实时接收推送报警 (`pushFaultData`) - 报警队列处理 (`evenQueueFunctionClass`) - 报警点位循环闪烁 (`keyMakerLoopClass`) 3. **点位管理** - 动态加载点位 (`waitAllMakeInfoDoneHandleClass`) - 点位状态更新 (`diffMakerInfo`) - 点位交互(点击/悬浮) 4. **组件通信** - Vuex 状态管理 - 父子组件通信 (props/events) - Mixins 复用逻辑 ### 关键代码优化建议 ```javascript // 优化后的图层过滤逻辑 getMarkerLayers() { mapApi.ConfigApi.getMarkerLayers().then(res => { if (!res?.length) return; const curMapMode = this.map.mapConfig.gisMode; const targetLayers = ['hotareaLayer', 'videoLayer', ...this.fireControlLayerArr.map(i => i.layerCode)]; // 使用Map优化图层索引 const layerMap = new Map([ ['fireControlLayer', 0], ['videoLayer', 1], ['hotareaLayer', 2] ]); this.markerResourceList = res.filter(item => item.mapType < 3 && item.mapType !== -1 && targetLayers.includes(item.layerCode) ); // 优化排序逻辑 this.markerResourceFlooterIcon = this.markerResourceList .filter(item => ['fireControlLayer', 'videoLayer', 'hotareaLayer'].includes(item.layerCode)) .sort((a, b) => layerMap.get(a.layerCode) - layerMap.get(b.layerCode)); }); } ``` ### 状态管理优化 ```javascript // 使用常量管理状态类型 const MAP_STATES = { INITIALIZED: 0, // 地图初始化完成 LAYERS_ADDED: 2, // 图层添加完成 DATA_READY: 3, // 点位数据准备就绪 POLLING_UPDATE: 5, // 轮询更新 ORG_CHANGED: 6, // 组织切换 PUSH_UPDATE: 7 // 推送更新 }; // 修改状态设置方法 setMapStatePreparation(state) { this.mapStatePreparation = { time: Date.now(), state, stateName: Object.keys(MAP_STATES).find(k => MAP_STATES[k] === state) }; // 添加状态处理 const stateHandlers = { [MAP_STATES.INITIALIZED]: () => { this.addNewLayer(this.allLayers, this.map); this.keyMakerLoop.setMap(this.map); this.evenQueueClass.setMap(this.map); }, [MAP_STATES.DATA_READY]: () => { this.shuntInfo(); } }; stateHandlers[state]?.(); } ``` ### 报警处理优化建议 ```javascript // 在evenQueueFunctionClass中添加防抖处理 class evenQueueFunctionClass { constructor() { this.alarmQueue = []; this.processing = false; this.debounceTimer = null; } evenQueueFunction(alarm) { this.alarmQueue.push(alarm); // 使用防抖优化高频报警 clearTimeout(this.debounceTimer); this.debounceTimer = setTimeout(() => { this.processQueue(); }, 300); } processQueue() { if (this.processing || !this.alarmQueue.length) return; this.processing = true; const currentAlarm = this.alarmQueue.shift(); // 实际处理逻辑... this.processing = false; this.processQueue(); // 处理下一个 } } ``` ### 性能优化建议 1. **点位渲染优化** ```javascript // 使用Web Worker处理大数据量点位计算 initWebWorker() { this.pointWorker = new Worker('@/workers/pointProcessor.js'); this.pointWorker.onmessage = (e) => { this.curBitmapMakerList = e.data; this.setMapStatePreparation(3); }; } // 调用方式 this.pointWorker.postMessage({ resources: this.markerResourceList, node: this.selectNode }); ``` 2. **内存管理** ```javascript beforeDestroy() { // 清理事件监听 this.map.off('dblclick'); // 清理Worker if (this.pointWorker) this.pointWorker.terminate(); // 释放图层资源 this.clearAllLayers(this.allMarkerLayers); } ``` ### 组件改进建议 ```vue <!-- 添加加载状态提示 --> <template> <div class="map-content"> <div v-if="loading" class="map-loading"> <i class="el-icon-loading"></i> {{ $t('common.loading') }} </div> <!-- ...原有内容... --> </div> </template> <script> // 添加加载状态管理 data() { return { loading: true, loadSteps: { layers: false, points: false, events: false } } }, watch: { loadSteps: { deep: true, handler(steps) { if (steps.layers && steps.points && steps.events) { this.loading = false; } } } } </script> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值