系数校准

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 dialogVisible = ref(false)
const active = ref(0) const active = ref(0)
let intervalId: NodeJS.Timeout | null = null; 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 name = ref<string[]>([])//系数校准所选设备名字数组
const channel = ref<number[]>([])//系数校准所选设备通道数组 const channel = ref<number[]>([])//系数校准所选设备通道数组
// 在 setup 函数中 // 在 setup 函数中
@@ -512,25 +514,6 @@ const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process
tableDataMap.set(i,currentTableData) 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=() => { const handleCancel=() => {
@@ -624,17 +607,17 @@ const handleSubmit = async () => {
clearInterval(intervalId); clearInterval(intervalId);
} }
// 初始化 currentTableData // 初始化 currentTableData
let isTimer2Completed = false; let isTimer2Completed = false;
// 设置 loading 状态为 true
// 初始化 loadingStates 为 true // 初始化 loadingStates 为 true
loadingStates.value = new Array(name.value.length).fill(true); loadingStates.value = new Array(name.value.length).fill(true);
for (let i = 0; i < channel.value.length; i++) { 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 currentTableData = ref<TableDataItem[]>([]);
const selectedTemplates = dataTemplates4; const selectedTemplates = dataTemplates4;
@@ -650,13 +633,23 @@ for (let i = 0; i < channel.value.length; i++) {
} }
tableDataMap.set(i, currentTableData); tableDataMap.set(i, currentTableData);
console.log('tableDataMap after set', tableDataMap);
activeIndex.value++; 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 // 启动 timer2
let timer2 = setInterval(() => { timer2 = setInterval(() => {
// 初始化 currentTableData // 初始化 currentTableData
const currentTableData = ref<TableDataItem[]>([]); const currentTableData = ref<TableDataItem[]>([]);
@@ -691,9 +684,7 @@ for (let i = 0; i < channel.value.length; i++) {
clearInterval(timer2); clearInterval(timer2);
const currentDataRef = tableDataMap.get(activeIndex.value - 1); const currentDataRef = tableDataMap.get(activeIndex.value - 1);
console.log('activeIndex.value',activeIndex.value); console.log('currentDataRef',currentDataRef)
console.log('tableDataMap',tableDataMap);
console.log('currentDataRef',currentDataRef);
if (currentDataRef) { if (currentDataRef) {
const currentData = currentDataRef.value; const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段 // 检查当前数据中有无不合格字段
@@ -704,7 +695,7 @@ for (let i = 0; i < channel.value.length; i++) {
} }
updateErrorState(activeIndex.value - 1, hasError); updateErrorState(activeIndex.value - 1, hasError);
} }
activeIndex.value++;
// 设置标志变量为 true表示 timer2 已经完成 // 设置标志变量为 true表示 timer2 已经完成
isTimer2Completed = true; isTimer2Completed = true;
}, 3000); }, 3000);
@@ -720,13 +711,7 @@ for (let i = 0; i < channel.value.length; i++) {
isTimer2Completed = false; isTimer2Completed = false;
} }
// 启动 timer1
let timer1 = setInterval(() => {
active.value++;
if (active.value > 5) {
clearInterval(timer1);
}
}, 1000);
}; };

View File

@@ -13,7 +13,7 @@
<el-table-column prop="Ua" label="L1"> <el-table-column prop="Ua" label="L1">
<el-table-column prop="UaData" label="数据(V)"> <el-table-column prop="UaData" label="数据(V)">
<template #default="scope"> <template #default="scope">
<el-icon v-if="scope.row.UaData === '—'&& loading"> <el-icon v-if="scope.row.UaData === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -26,7 +26,7 @@
<el-tag type="danger" v-if="scope.row.UaChannel === '不合格'"> <el-tag type="danger" v-if="scope.row.UaChannel === '不合格'">
{{ scope.row.UaChannel }} {{ scope.row.UaChannel }}
</el-tag> </el-tag>
<el-icon v-else-if="scope.row.UaChannel === '—'&& loading"> <el-icon v-else-if="scope.row.UaChannel === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -39,7 +39,7 @@
<el-table-column prop="Ub" label="L2"> <el-table-column prop="Ub" label="L2">
<el-table-column prop="UbData" label="数据(V)"> <el-table-column prop="UbData" label="数据(V)">
<template #default="scope"> <template #default="scope">
<el-icon v-if="scope.row.UbData === '—'&& loading"> <el-icon v-if="scope.row.UbData === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -52,7 +52,7 @@
<el-tag type="danger" v-if="scope.row.UbChannel === '不合格'"> <el-tag type="danger" v-if="scope.row.UbChannel === '不合格'">
{{ scope.row.UbChannel }} {{ scope.row.UbChannel }}
</el-tag> </el-tag>
<el-icon v-else-if="scope.row.UbChannel === '—'&& loading"> <el-icon v-else-if="scope.row.UbChannel === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -64,7 +64,7 @@
<el-table-column prop="Uc" label="L3"> <el-table-column prop="Uc" label="L3">
<el-table-column prop="UcData" label="数据(V)"> <el-table-column prop="UcData" label="数据(V)">
<template #default="scope"> <template #default="scope">
<el-icon v-if="scope.row.UcData === '—'&& loading"> <el-icon v-if="scope.row.UcData === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -77,7 +77,7 @@
<el-tag type="danger" v-if="scope.row.UcChannel === '不合格'"> <el-tag type="danger" v-if="scope.row.UcChannel === '不合格'">
{{ scope.row.UcChannel }} {{ scope.row.UcChannel }}
</el-tag> </el-tag>
<el-icon v-else-if="scope.row.UcChannel === '—'&& loading"> <el-icon v-else-if="scope.row.UcChannel === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -91,7 +91,7 @@
<el-table-column prop="Ia" label="L1"> <el-table-column prop="Ia" label="L1">
<el-table-column prop="IaData" label="数据(A)"> <el-table-column prop="IaData" label="数据(A)">
<template #default="scope"> <template #default="scope">
<el-icon v-if="scope.row.IaData === '—'&& loading"> <el-icon v-if="scope.row.IaData === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -104,7 +104,7 @@
<el-tag type="danger" v-if="scope.row.IaChannel === '不合格'"> <el-tag type="danger" v-if="scope.row.IaChannel === '不合格'">
{{ scope.row.IaChannel }} {{ scope.row.IaChannel }}
</el-tag> </el-tag>
<el-icon v-else-if="scope.row.IaChannel === '—'&& loading"> <el-icon v-else-if="scope.row.IaChannel === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -116,7 +116,7 @@
<el-table-column prop="Ib" label="L2"> <el-table-column prop="Ib" label="L2">
<el-table-column prop="IbData" label="数据(A)"> <el-table-column prop="IbData" label="数据(A)">
<template #default="scope"> <template #default="scope">
<el-icon v-if="scope.row.IbData === '—'&& loading"> <el-icon v-if="scope.row.IbData === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -129,7 +129,7 @@
<el-tag type="danger" v-if="scope.row.IbChannel === '不合格'"> <el-tag type="danger" v-if="scope.row.IbChannel === '不合格'">
{{ scope.row.IbChannel }} {{ scope.row.IbChannel }}
</el-tag> </el-tag>
<el-icon v-else-if="scope.row.IbChannel === '—'&& loading"> <el-icon v-else-if="scope.row.IbChannel === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -141,7 +141,7 @@
<el-table-column prop="Ic" label="L3"> <el-table-column prop="Ic" label="L3">
<el-table-column prop="IcData" label="数据(A)"> <el-table-column prop="IcData" label="数据(A)">
<template #default="scope"> <template #default="scope">
<el-icon v-if="scope.row.IcData === '—'&& loading"> <el-icon v-if="scope.row.IcData === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -154,7 +154,7 @@
<el-tag type="danger" v-if="scope.row.IcChannel === '不合格'"> <el-tag type="danger" v-if="scope.row.IcChannel === '不合格'">
{{ scope.row.IcChannel }} {{ scope.row.IcChannel }}
</el-tag> </el-tag>
<el-icon v-else-if="scope.row.IcChannel === '—'&& loading"> <el-icon v-else-if="scope.row.IcChannel === '—'&& loading" class="loading-box">
<el-icon-loading /> <el-icon-loading />
</el-icon> </el-icon>
<span v-else> <span v-else>
@@ -176,7 +176,7 @@
</template> </template>
<script lang="ts" setup name="ErrorSystemDialog"> <script lang="ts" setup name="ErrorSystemDialog">
import { defineProps, defineEmits, reactive,watch,ref, Ref } from 'vue'; import { defineProps } from 'vue';
import { ElIcon, ElLoading, ElTag } from 'element-plus'; import { ElIcon, ElLoading, ElTag } from 'element-plus';
//import IndicatorTypeDialog from "@/views/machine/errorSystem/components/IndicatorTypeDialog.vue"; // 导入子组件 //import IndicatorTypeDialog from "@/views/machine/errorSystem/components/IndicatorTypeDialog.vue"; // 导入子组件
@@ -327,5 +327,17 @@
overflow-x: hidden; /* 隐藏水平滚动条 */ overflow-x: hidden; /* 隐藏水平滚动条 */
} }
/* 确保 el-icon-loading 的动画效果没有被覆盖 */
.loading-box {
animation: rotate 2s linear infinite;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style> </style>