系数校准调整

This commit is contained in:
sjl
2024-12-30 19:59:15 +08:00
parent fa4b5d26e5
commit 0fd6ebf810

View File

@@ -55,7 +55,6 @@
</el-steps>
</div>
<div class="right-content">
<el-tabs type="border-card">
<div >
<el-tab-pane v-for="(device, index) in name" :key="index" :label="device">
@@ -120,9 +119,8 @@
import { type Device } from '@/api/device/interface/device';
import { SuccessFilled, Failed, Message, MessageBox } from '@element-plus/icons-vue'
import { type Ref, ref, toRef, watch } from 'vue'
import {dialogBig} from '@/utils/elementBind'
import {dialogBig} from '@/utils/elementBind'
import { ElMessage, ElMessageBox } from 'element-plus';
import { el } from 'element-plus/es/locale';
const activeIndex = ref(0)
const activeTotalNum = ref(4)
const qualified = ref(0)
@@ -133,8 +131,8 @@ 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[]>([])//系数校准所选设备通道数组
const name = ref<string[]>([])//系数校准所选设备名字数组
const channel = ref<number[]>([])//系数校准所选设备通道数组
// 在 setup 函数中
const errorStates = ref(new Array(name.value.length).fill(false));
const loadingStates = ref(new Array(name.value.length).fill(false)); // 初始化 loading 状态
@@ -161,7 +159,6 @@ interface TableDataItem {
updateTime?: string;
}
const dataTemplates3 = [
{
deviceName: '系数下装',
@@ -227,7 +224,6 @@ const dataTemplates3 = [
];
const dataTemplates4 = [
{
deviceName: '系数下装',
@@ -452,19 +448,9 @@ const activities = [
},
]
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([]);
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
// [0, tableData1],
// [1, tableData2],
// [2, tableData3],
// [3, tableData1],
// [4, tableData1],
// [5, tableData1],
]);
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
// 打开弹窗,可能是新增,也可能是编辑
const open = (selection: Device.ResPqDev[]) => {
@@ -529,8 +515,6 @@ const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process
const getTableDataForChannel = (index: number): any[] => {
const data = tableDataMap.get(index);
// console.log('index',index)
// console.log('data',data)
return data ? data.value : [];
}
// const props = defineProps({
@@ -587,7 +571,6 @@ watch(activeIndex, function (newValue, oldValue) {
}
})
// 示例的 checkForErrors 函数,根据实际需求进行调整
const checkForErrors = (data: TableDataItem[]): boolean => {
// 这里假设不合格字段的标准是 status 为 '不合格' 或 isValid 为 false
@@ -601,13 +584,11 @@ const checkForErrors = (data: TableDataItem[]): boolean => {
);
};
const handleSubmit = async () => {
if (intervalId !== null) {
clearInterval(intervalId);
}
// 初始化 currentTableData
let isTimer2Completed = false;
// 初始化 loadingStates 为 true
@@ -615,9 +596,9 @@ const handleSubmit = async () => {
for (let i = 0; i < channel.value.length; i++) {
// 完成所有步骤后重置状态变量
active.value = 0;
// 重置状态变量
active.value = 0;activeIndex.value = 0;
console.log('activeIndex', activeIndex.value);
const currentTableData = ref<TableDataItem[]>([]);
const selectedTemplates = dataTemplates4;
@@ -634,9 +615,9 @@ for (let i = 0; i < channel.value.length; i++) {
tableDataMap.set(i, currentTableData);
activeIndex.value++;
// 清除之前的 timer1
clearInterval(timer1);
console.log('activeIndex', activeIndex.value);
// 清除之前的 timer1
clearInterval(timer1);
// 启动 timer1
timer1 = setInterval(() => {
active.value++;
@@ -644,28 +625,16 @@ clearInterval(timer1);
if (active.value > 5) {
clearInterval(timer1);
}
}, 500);
}, 500);
// 清除之前的 timer2
clearInterval(timer2);
// 清除之前的 timer2
clearInterval(timer2);
// 启动 timer2
timer2 = setInterval(() => {
// 初始化 currentTableData
const currentTableData = ref<TableDataItem[]>([]);
if(i > 0){
const selectedTemplates = dataTemplates6;
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,
});
});
}
}else{
const selectedTemplates = dataTemplates5;
for (let j = 0; j < channel.value[i]; j++) {
const id = (j + 1).toString();
@@ -677,13 +646,28 @@ clearInterval(timer2);
});
});
}
}else{
const selectedTemplates = dataTemplates6;
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,
});
});
}
}
console.log('currentTableData', currentTableData);
tableDataMap.set(i, currentTableData);
activeIndex.value++;
clearInterval(timer2);
const currentDataRef = tableDataMap.get(activeIndex.value - 1);
console.log('activeIndex', activeIndex.value);
console.log('tableDataMap', tableDataMap);
const currentDataRef = tableDataMap.get(i);
console.log('activeIndex.value - 2',activeIndex.value)
console.log('currentDataRef',currentDataRef)
if (currentDataRef) {
const currentData = currentDataRef.value;
@@ -693,7 +677,7 @@ clearInterval(timer2);
} else {
qualified.value++;
}
updateErrorState(activeIndex.value - 1, hasError);
updateErrorState(i, hasError);
}
// 设置标志变量为 true表示 timer2 已经完成
@@ -712,67 +696,10 @@ clearInterval(timer2);
}
};
const handleSubmit2 = () => {
if (intervalId !== null) {
clearInterval(intervalId);
}
intervalId = setInterval(() => {
if (activeIndex.value < name.value.length) {
activeIndex.value++;
// 获取当前活动索引对应的 tableData
const currentDataRef = tableDataMap.get(activeIndex.value - 1);
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
}else{
qualified.value++;
}
updateErrorState(activeIndex.value - 1, hasError);
}
} else {
clearInterval(intervalId!); // 停止定时器
}
}, 1000); // 每隔3秒显示下一个tab
// let timer = setInterval(() => {
// if (activeIndex.value < activeTotalNum.value) {
// activeIndex.value++
// if(activeIndex.value > 1)
// qualified.value = activeIndex.value -1;//演示效果,实际运行时使用后端传来的真实数据即可
// else
// qualified.value = activeIndex.value;
// }
// else if (activeIndex.value === activeTotalNum.value) {
// clearInterval(timer)
// }
// else {
// clearInterval(timer)
// }
// total.value = activeTotalNum.value
// }, 1000);
let timer2 = setInterval(() => {
active.value++
if (active.value++ > 5) {
clearInterval(timer2)
}
}, 1000);
};
// 对外映射
defineExpose({ open })
</script>
<style scoped>
.right-title {