系数校准

This commit is contained in:
sjl
2024-12-30 19:17:39 +08:00
parent 23f45b38cb
commit fa4b5d26e5
2 changed files with 50 additions and 53 deletions

View File

@@ -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<string[]>([])//系数校准所选设备名字数组
const channel = ref<number[]>([])//系数校准所选设备通道数组
// 在 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<TableDataItem[]>([]);
// // 随机选择 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<TableDataItem[]>([]);
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<TableDataItem[]>([]);
@@ -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);
};