From 079263ed38ee60af70b466b31aeb5ee4d4b0df90 Mon Sep 17 00:00:00 2001 From: guanj Date: Mon, 27 Oct 2025 15:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=8E=A5=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E7=AC=AC=E4=B8=80=E6=AC=A1=E5=8A=A0=E8=BD=BD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.ts | 1 - .../SagTraceResult_WX/components/bdMap.vue | 2 +- .../components/eventStatistics/index.vue | 42 ++++++++++++++++--- .../SagTraceResult_WX/components/plan.vue | 8 +++- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index b59b81f..8a65711 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -58,7 +58,6 @@ export default createStore({ state.count++; }, [Mutations.SET_STATE](state: State, data: any) { - console.log("🚀 ~ data:", data) state[data.key] = data.value; }, [Mutations.SET_TOKEN](state: State, data: any) { diff --git a/src/views/SagTraceResult_WX/components/bdMap.vue b/src/views/SagTraceResult_WX/components/bdMap.vue index e18d850..ba46ab8 100644 --- a/src/views/SagTraceResult_WX/components/bdMap.vue +++ b/src/views/SagTraceResult_WX/components/bdMap.vue @@ -362,7 +362,7 @@ defineExpose({ position: absolute; bottom: 10px; left: 10px; - z-index: 2000; + z-index: 1; width: 110px; height: 70px; padding: 10px; diff --git a/src/views/SagTraceResult_WX/components/eventStatistics/index.vue b/src/views/SagTraceResult_WX/components/eventStatistics/index.vue index 2e22aa2..e8f1d7d 100644 --- a/src/views/SagTraceResult_WX/components/eventStatistics/index.vue +++ b/src/views/SagTraceResult_WX/components/eventStatistics/index.vue @@ -623,6 +623,7 @@ watch(flag, (newVal) => { setTimeout(() => { if (flag.value == 0) { initHasEventList(); + // flag 变化后重新绑定事件 bindRankingClickEvent(); } @@ -635,6 +636,29 @@ watch(flag, (newVal) => { } }, 100); }); +watch( + () => store.state.showMap, + (newVal) => { + if (newVal) { + return; + } + setTimeout(() => { + if (flag.value == 0) { + initHasEventList(); + + // flag 变化后重新绑定事件 + bindRankingClickEvent(); + } + if (flag.value == 2) { + renderChart2(); + initHasUpEventList(); + } + if (flag.value == 1) { + callHarmOneImageApi(getFirstTableData.value, getTimes.value); + } + }, 100); + } +); // 暂降记录个数 const initialData = () => { @@ -688,11 +712,9 @@ const initialAggregation = () => { tableData.splice(0, tableData.length); }); }; - +const interval = ref(null); // 提取发送消息到iframe的公共方法 const sendMessageToIframe = (type: string, payload: any) => { - // console.log(123,store.state.iframeLoad); - // window.parent.postMessage( // { // type, @@ -701,6 +723,10 @@ const sendMessageToIframe = (type: string, payload: any) => { // "*" // ); // 如果 iframe 已加载完成,直接发送消息 + if (store.state.showMap) { + return; + } + if (store.state.iframeLoad) { window.parent.postMessage( { @@ -711,9 +737,13 @@ const sendMessageToIframe = (type: string, payload: any) => { ); return; } + if (interval.value) { + clearInterval(interval.value); + interval.value = null; + } // 如果未加载完成,每 1 秒尝试发送一次 - const interval = setInterval(() => { + interval.value = setInterval(() => { console.log("等待 iframe 加载,1 秒后重试..."); if (store.state.iframeLoad) { // 加载完成后发送消息并清除定时器 @@ -724,7 +754,7 @@ const sendMessageToIframe = (type: string, payload: any) => { }, "*" // 建议替换为具体域名 ); - clearInterval(interval); + clearInterval(interval.value); } }, 1000); }; @@ -1267,7 +1297,7 @@ const handleChildClose = () => { const init = () => { initialData(); initialAggregation(); - initHasEventList(); + // initHasEventList(); initialResponsibilityList(); // getInfoListAmplify(); tableInfoAmplify(); diff --git a/src/views/SagTraceResult_WX/components/plan.vue b/src/views/SagTraceResult_WX/components/plan.vue index 5394398..108f0d6 100644 --- a/src/views/SagTraceResult_WX/components/plan.vue +++ b/src/views/SagTraceResult_WX/components/plan.vue @@ -16,6 +16,7 @@ frameborder="0" scrolling="no" id="iframeLeft" + :key="keyof" @load="onIframeLoad" > (); const iframeSrc = ref(""); - +const keyof = ref(0); // 监听 props 变化 watch( () => props.project, @@ -57,6 +58,7 @@ watch( // 点击监测点传入 接线图id const pointClick = (row: any) => { setUrl(row.pictureId, row.pictureName); + keyof.value += 1; }; onMounted(() => { @@ -133,8 +135,10 @@ const sendKeysToIframe = (keyList: string[]) => { }; // 返回地图 const backButton = () => { - window.removeEventListener("message", handleMessage); + store.dispatch("setStateKey", { key: "iframeLoad", value: false }); store.dispatch("setStateKey", { key: "showMap", value: true }); + + // window.removeEventListener("message", handleMessage); };