From a3cd259861b447a07019201f9031265b6b538d83 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Thu, 1 Feb 2024 15:13:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AE=9A=E6=97=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../overview/components/UPFFlow/index.vue | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/views/dashboard/overview/components/UPFFlow/index.vue b/src/views/dashboard/overview/components/UPFFlow/index.vue index 7ffb133e..cbbf73fa 100644 --- a/src/views/dashboard/overview/components/UPFFlow/index.vue +++ b/src/views/dashboard/overview/components/UPFFlow/index.vue @@ -42,15 +42,18 @@ type EChartsOption = echarts.ComposeOption< let timeoutDuration = 5 * 1000; // 设置5s进行刷新请求 let loadId: any = null; -// 定时制图 -function resetTimeout() { - if (loadId) { - clearInterval(loadId); - } - loadId = setInterval(() => { - initPicture(); - }, timeoutDuration); -} +// // 定时制图 +// function resetTimeout() { +// if (loadId) { +// clearInterval(loadId); +// } +// loadId = setInterval(() => { +// initPicture(); +// }, timeoutDuration); +// } + +/**定时器ID */ +const timeoutId = ref(null); /**图DOM节点实例对象 */ const upfFlow = ref(undefined); @@ -75,9 +78,8 @@ function fnDesign(container: HTMLElement | undefined, option: EChartsOption) { //渲染速率图 function initPicture() { - if (loadId) { - clearInterval(loadId); - } + clearTimeout(timeoutId.value); + let queryArr: any = []; const initTime: Date = new Date(); const startTime: Date = new Date(initTime); @@ -87,8 +89,9 @@ function initPicture() { queryArr = [parseDateToStr(startTime), parseDateToStr(endTime)]; listUPFData(queryArr).then(res => { - resetTimeout(); - + timeoutId.value = setTimeout(() => { + initPicture(); // 5秒后再次获取数据 + }, 5000); let timeArr: any = []; let upValue: any = []; let downValue: any = []; @@ -230,7 +233,7 @@ function initPicture() { onMounted(() => { initPicture(); - resetTimeout(); + clearTimeout(timeoutId.value); }); /**组件实例被卸载之后调用 */