This commit is contained in:
sjl
2024-12-23 14:05:53 +08:00
parent 5f0b36b3bb
commit fdf91965d9
6 changed files with 138 additions and 105 deletions

View File

@@ -42,7 +42,7 @@
<el-tabs type="border-card">
<div v-if="activeIndex > 0">
<el-tab-pane v-for="(device, index) in name.slice(0, activeIndex + 1)" :key="index" :label="device">
<el-tab-pane v-for="(device, index) in name.slice(0, activeIndex )" :key="index" :label="device">
<template #label>
<span class="custom-tabs-label">
<span>{{ device }}</span>
@@ -102,9 +102,10 @@
</template>
<script lang="tsx" setup name="channelsTest">
import { type Device } from '@/api/device/interface/device';
import { SuccessFilled, Failed } from '@element-plus/icons-vue'
import { SuccessFilled, Failed, Message, MessageBox } from '@element-plus/icons-vue'
import { type Ref, ref, toRef, watch } from 'vue'
import {dialogBig} from '@/utils/elementBind'
import { ElMessage, ElMessageBox } from 'element-plus';
const activeIndex = ref(0)
const activeTotalNum = ref(4)
const qualified = ref(0)
@@ -118,6 +119,28 @@ let intervalId: NodeJS.Timeout | null = null;
// 在 setup 函数中
const errorStates = ref(new Array(name.value.length).fill(false));
// 定义 TableDataItem 接口
interface TableDataItem {
id: string;
deviceName: string;
MonitorIdx: number;
UaData?: number | string;
UaChannel?: number | string;
UbData?: number | string;
UbChannel?: number | string;
UcData?: number | string;
UcChannel?: number | string;
IaData?: number | string;
IaChannel?: number | string;
IbData?: number | string;
IbChannel?: number | string;
IcData?: number | string;
IcChannel?: number | string;
Result?: string | string;
updateTime?: string;
}
// 更新错误状态的方法
const updateErrorState = (index: number, hasError: boolean) => {
errorStates.value[index] = hasError;
@@ -361,7 +384,7 @@ const tableData2 = ref<TableDataItem[]>([
},
])
const tableData3 = ref<TableDataItem[]>([
{
{
id: '1',
updateTime: '2024-10-10 10:30:00',
deviceName: '大电压大电流',
@@ -413,7 +436,7 @@ const tableData3 = ref<TableDataItem[]>([
IaData: 5,
IaChannel: '合格',
IbData: 5,
IbChannel: 1.0001,
IbChannel: '合格',
IcData: 5,
IcChannel: '合格',
Result: '合格',
@@ -439,10 +462,38 @@ const tableData3 = 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 open = (selection: Device.ResPqDev[]) => {
const checkStates = selection.map(item => item.checkState);
const allCheckStatesEqual = new Set(checkStates).size <= 1;
if (!allCheckStatesEqual) {
ElMessageBox.confirm(
'所勾选设备检测状态不一致,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return
}
name.value = selection.map(item => item.name)
channel.value = selection.map(item => item.devChns)
dialogVisible.value = true;
@@ -460,35 +511,6 @@ const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process
dialogVisible.value = false
}
// 定义 TableDataItem 接口
interface TableDataItem {
id: string;
deviceName: string;
MonitorIdx: number;
UaData?: number;
UaChannel?: number | string;
UbData?: number;
UbChannel?: number | string;
UcData?: number;
UcChannel?: number | string;
IaData?: number;
IaChannel?: number | string;
IbData?: number;
IbChannel?: number | string;
IcData?: number;
IcChannel?: number | string;
Result?: string;
updateTime?: string;
}
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
[0, tableData1],
[1, tableData2],
[2, tableData3],
]);
const getTableDataForChannel = (index: number): any[] => {
const data = tableDataMap.get(index);
return data ? data.value : [];
@@ -566,28 +588,26 @@ const handleSubmit = () => {
clearInterval(intervalId);
}
intervalId = setInterval(() => {
console.log('开始')
if (activeIndex.value < name.value.length) {
activeIndex.value++;
console.log('active index',activeIndex.value)
// 获取当前活动索引对应的 tableData
const currentDataRef = tableDataMap.get(activeIndex.value);
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, hasError);
updateErrorState(activeIndex.value - 1, hasError);
}
} else {
console.log('停')
clearInterval(intervalId!); // 停止定时器
}
}, 3000); // 每隔3秒显示下一个tab
}, 1000); // 每隔3秒显示下一个tab
// let timer = setInterval(() => {
// if (activeIndex.value < activeTotalNum.value) {