From fa4b5d26e533c730f3d8d25dfe05f1ccf6dbed69 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Mon, 30 Dec 2024 19:17:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E6=95=B0=E6=A0=A1=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/home/components/channelsTest.vue | 65 +++++++------------ .../home/components/channelsTestTable.vue | 38 +++++++---- 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/frontend/src/views/home/components/channelsTest.vue b/frontend/src/views/home/components/channelsTest.vue index 58db81f..8344161 100644 --- a/frontend/src/views/home/components/channelsTest.vue +++ b/frontend/src/views/home/components/channelsTest.vue @@ -131,6 +131,8 @@ const total = ref(0) const dialogVisible = ref(false) const active = ref(0) let intervalId: NodeJS.Timeout | null = null; +let timer1: NodeJS.Timeout | null = null; // 声明并初始化 timer1 +let timer2: NodeJS.Timeout | null = null; // 同样声明并初始化 timer2 const name = ref([])//系数校准所选设备名字数组 const channel = ref([])//系数校准所选设备通道数组 // 在 setup 函数中 @@ -512,25 +514,6 @@ const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process tableDataMap.set(i,currentTableData) } - // // 循环生成数据 - // for (let i = 0; i < channel.value.length; i++) { - // const currentTableData = ref([]); - // // 随机选择 dataTemplates 或 dataTemplates2 - // const selectedTemplates = Math.random() < 0.5 ? dataTemplates : dataTemplates2; - - // for(let j = 0; j < channel.value[i]; j++){ - // const id = (j + 1).toString(); - // selectedTemplates.forEach((template) => { - // currentTableData.value.push({ - // id: id, - // MonitorIdx: j + 1, - // ...template, - // }); - // }); - // } - - // tableDataMap.set(i,currentTableData) - // } } const handleCancel=() => { @@ -624,17 +607,17 @@ const handleSubmit = async () => { clearInterval(intervalId); } + // 初始化 currentTableData let isTimer2Completed = false; - - // 设置 loading 状态为 true - // 初始化 loadingStates 为 true - loadingStates.value = new Array(name.value.length).fill(true); + // 初始化 loadingStates 为 true + loadingStates.value = new Array(name.value.length).fill(true); for (let i = 0; i < channel.value.length; i++) { - - console.log('channel', channel.value[i]); - console.log('activeIndex', activeIndex.value); + + + // 完成所有步骤后重置状态变量 + active.value = 0; const currentTableData = ref([]); const selectedTemplates = dataTemplates4; @@ -650,13 +633,23 @@ for (let i = 0; i < channel.value.length; i++) { } tableDataMap.set(i, currentTableData); - console.log('tableDataMap after set', tableDataMap); activeIndex.value++; - +// 清除之前的 timer1 +clearInterval(timer1); + // 启动 timer1 + timer1 = setInterval(() => { + active.value++; + console.log('active', active.value); + if (active.value > 5) { + clearInterval(timer1); + } +}, 500); +// 清除之前的 timer2 +clearInterval(timer2); // 启动 timer2 - let timer2 = setInterval(() => { + timer2 = setInterval(() => { // 初始化 currentTableData const currentTableData = ref([]); @@ -691,9 +684,7 @@ for (let i = 0; i < channel.value.length; i++) { clearInterval(timer2); const currentDataRef = tableDataMap.get(activeIndex.value - 1); - console.log('activeIndex.value',activeIndex.value); - console.log('tableDataMap',tableDataMap); - console.log('currentDataRef',currentDataRef); + console.log('currentDataRef',currentDataRef) if (currentDataRef) { const currentData = currentDataRef.value; // 检查当前数据中有无不合格字段 @@ -704,7 +695,7 @@ for (let i = 0; i < channel.value.length; i++) { } updateErrorState(activeIndex.value - 1, hasError); } - activeIndex.value++; + // 设置标志变量为 true,表示 timer2 已经完成 isTimer2Completed = true; }, 3000); @@ -720,13 +711,7 @@ for (let i = 0; i < channel.value.length; i++) { isTimer2Completed = false; } - // 启动 timer1 - let timer1 = setInterval(() => { - active.value++; - if (active.value > 5) { - clearInterval(timer1); - } - }, 1000); + }; diff --git a/frontend/src/views/home/components/channelsTestTable.vue b/frontend/src/views/home/components/channelsTestTable.vue index 2691e04..27b6164 100644 --- a/frontend/src/views/home/components/channelsTestTable.vue +++ b/frontend/src/views/home/components/channelsTestTable.vue @@ -13,7 +13,7 @@