Compare commits
2 Commits
859d890434
...
0ffc0cd01e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ffc0cd01e | ||
|
|
079263ed38 |
@@ -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) {
|
||||
|
||||
@@ -362,7 +362,7 @@ defineExpose({
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
z-index: 2000;
|
||||
z-index: 1;
|
||||
width: 110px;
|
||||
height: 70px;
|
||||
padding: 10px;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
frameborder="0"
|
||||
scrolling="no"
|
||||
id="iframeLeft"
|
||||
:key="keyof"
|
||||
@load="onIframeLoad"
|
||||
></iframe>
|
||||
<el-button class="backButton" @click="backButton" size="small" :icon="Back"
|
||||
@@ -35,7 +36,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
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);
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user