更改定时器
This commit is contained in:
@@ -42,15 +42,18 @@ type EChartsOption = echarts.ComposeOption<
|
|||||||
let timeoutDuration = 5 * 1000; // 设置5s进行刷新请求
|
let timeoutDuration = 5 * 1000; // 设置5s进行刷新请求
|
||||||
let loadId: any = null;
|
let loadId: any = null;
|
||||||
|
|
||||||
// 定时制图
|
// // 定时制图
|
||||||
function resetTimeout() {
|
// function resetTimeout() {
|
||||||
if (loadId) {
|
// if (loadId) {
|
||||||
clearInterval(loadId);
|
// clearInterval(loadId);
|
||||||
}
|
// }
|
||||||
loadId = setInterval(() => {
|
// loadId = setInterval(() => {
|
||||||
initPicture();
|
// initPicture();
|
||||||
}, timeoutDuration);
|
// }, timeoutDuration);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
/**定时器ID */
|
||||||
|
const timeoutId = ref<any>(null);
|
||||||
|
|
||||||
/**图DOM节点实例对象 */
|
/**图DOM节点实例对象 */
|
||||||
const upfFlow = ref<HTMLElement | undefined>(undefined);
|
const upfFlow = ref<HTMLElement | undefined>(undefined);
|
||||||
@@ -75,9 +78,8 @@ function fnDesign(container: HTMLElement | undefined, option: EChartsOption) {
|
|||||||
|
|
||||||
//渲染速率图
|
//渲染速率图
|
||||||
function initPicture() {
|
function initPicture() {
|
||||||
if (loadId) {
|
clearTimeout(timeoutId.value);
|
||||||
clearInterval(loadId);
|
|
||||||
}
|
|
||||||
let queryArr: any = [];
|
let queryArr: any = [];
|
||||||
const initTime: Date = new Date();
|
const initTime: Date = new Date();
|
||||||
const startTime: Date = new Date(initTime);
|
const startTime: Date = new Date(initTime);
|
||||||
@@ -87,8 +89,9 @@ function initPicture() {
|
|||||||
queryArr = [parseDateToStr(startTime), parseDateToStr(endTime)];
|
queryArr = [parseDateToStr(startTime), parseDateToStr(endTime)];
|
||||||
|
|
||||||
listUPFData(queryArr).then(res => {
|
listUPFData(queryArr).then(res => {
|
||||||
resetTimeout();
|
timeoutId.value = setTimeout(() => {
|
||||||
|
initPicture(); // 5秒后再次获取数据
|
||||||
|
}, 5000);
|
||||||
let timeArr: any = [];
|
let timeArr: any = [];
|
||||||
let upValue: any = [];
|
let upValue: any = [];
|
||||||
let downValue: any = [];
|
let downValue: any = [];
|
||||||
@@ -230,7 +233,7 @@ function initPicture() {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initPicture();
|
initPicture();
|
||||||
resetTimeout();
|
clearTimeout(timeoutId.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**组件实例被卸载之后调用 */
|
/**组件实例被卸载之后调用 */
|
||||||
|
|||||||
Reference in New Issue
Block a user