Files
pqs-9100_client/frontend/src/views/home/components/channelsTest.vue

831 lines
22 KiB
Vue
Raw Normal View History

<template>
2024-12-30 14:43:13 +08:00
<el-dialog v-model='dialogVisible' title="系数校准" v-bind="dialogBig" width="1500px" @close="handleCancel">
2024-12-18 15:49:29 +08:00
<div class="test-dialog" >
2024-12-05 15:22:46 +08:00
<div class="dialog-content">
<div class="right-title">
2024-11-21 23:02:43 +08:00
<!-- <div>系数校准表</div> -->
2024-12-05 21:33:52 +08:00
<div>{{ outputDsc }}</div>
<div>
2024-12-05 15:22:46 +08:00
<span style=" font-size: 18px;font-weight: 600;">
设备已合格 <span style="color: #67C23A">{{ qualified }}</span> / <span style="color: green">{{ total }}</span>
</span>
<!-- <el-button type="primary" loading
v-if="activeIndex > 0 && activeIndex < activeTotalNum">通道系数已校准3台/共3台</el-button>
<el-button type="primary" :disabled="true" v-if="activeIndex === activeTotalNum">通道系数已校准3台/共3台</el-button> -->
</div>
2024-12-05 15:22:46 +08:00
</div>
2024-12-20 10:21:36 +08:00
<div class="container">
<div class="dialog-left">
<el-steps direction="vertical" :active="active" :process-status="currentStepStatus" finish-status="success">
<el-step title="开始" />
<el-step>
<template #title>
2024-12-30 14:43:13 +08:00
<span>大电压/电流系数下装</span><br/>
2024-12-20 10:21:36 +08:00
<span>源输出为</span><br/>
2024-12-30 14:43:13 +08:00
<span v-if="active > 0">Ua=Ub=Uc=57.74V</span><br/>
<span v-if="active > 0">Ia=Ib=Ic=10A</span>
2024-12-20 10:21:36 +08:00
</template>
</el-step>
<el-step>
<template #title>
2024-12-30 14:43:13 +08:00
<span>小电压/电流系数下装</span><br/>
2024-12-20 10:21:36 +08:00
<span>源输出为</span><br/>
2024-12-30 14:43:13 +08:00
<span v-if="active > 1">Ua=Ub=Uc=5.774V</span><br/>
<span v-if="active > 1">Ia=Ib=Ic=1A</span>
</template>
</el-step>
<el-step>
<template #title>
<span>大电压/电流校准</span><br/>
<span>源输出为</span><br/>
<span v-if="active > 2">Ua=Ub=Uc=57.74V</span><br/>
<span v-if="active > 2">Ia=Ib=Ic=10A</span>
</template>
</el-step>
<el-step>
<template #title>
<span>小电压/电流校准</span><br/>
<span>源输出为</span><br/>
<span v-if="active > 3">Ua=Ub=Uc=5.774V</span><br/>
<span v-if="active > 3">Ia=Ib=Ic=1A</span>
2024-12-20 10:21:36 +08:00
</template>
</el-step>
<el-step title="结束"/>
</el-steps>
</div>
<div class="right-content">
<el-tabs type="border-card">
2024-12-30 14:43:13 +08:00
<div >
<el-tab-pane v-for="(device, index) in name" :key="index" :label="device">
2024-12-20 10:21:36 +08:00
<template #label>
<span class="custom-tabs-label">
<span>{{ device }}</span>
<el-icon v-if="errorStates[index]">
<Failed />
</el-icon>
</span>
</template>
2024-12-30 14:43:13 +08:00
<channelsTestTable :tableData="getTableDataForChannel(index)" :loading="loadingStates[index]"></channelsTestTable>
2024-12-20 10:21:36 +08:00
</el-tab-pane>
</div>
<el-empty description="暂无数据,等待检测开始" v-if="activeIndex === 0" />
</el-tabs>
<!-- <el-tabs type="border-card">
<el-empty description="暂无数据,等待检测开始" v-if="activeIndex === 0" />
<el-tab-pane label="240001" v-if="activeIndex > 0">
<template #label>
<span class="custom-tabs-label">
<span>240001</span>
<el-icon>
<Failed />
</el-icon>
</span>
</template>
<channelsTestTable :tableData="tableData1"></channelsTestTable>
</el-tab-pane>
<el-tab-pane label="240002" v-if="activeIndex > 1">
<template #label>
<span class="custom-tabs-label">
<span>240002</span>
<el-icon>
<Failed />
</el-icon>
</span>
</template>
<channelsTestTable :tableData="tableData2"></channelsTestTable>
</el-tab-pane>
<el-tab-pane label="240003" v-if="activeIndex > 2">
<channelsTestTable :tableData="tableData3"></channelsTestTable>
</el-tab-pane>
<el-tab-pane label="240004" v-if="activeIndex > 3">
<channelsTestTable :tableData="tableData4"></channelsTestTable>
</el-tab-pane>
</el-tabs> -->
</div>
2024-12-05 15:22:46 +08:00
</div>
2024-12-20 10:21:36 +08:00
</div>
2024-12-05 15:22:46 +08:00
</div>
2024-12-18 15:49:29 +08:00
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="handleSubmit">开始系数校准</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="tsx" setup name="channelsTest">
2024-12-20 10:21:36 +08:00
import { type Device } from '@/api/device/interface/device';
2024-12-23 14:05:53 +08:00
import { SuccessFilled, Failed, Message, MessageBox } from '@element-plus/icons-vue'
2024-12-20 10:21:36 +08:00
import { type Ref, ref, toRef, watch } from 'vue'
import {dialogBig} from '@/utils/elementBind'
2024-12-23 14:05:53 +08:00
import { ElMessage, ElMessageBox } from 'element-plus';
2024-12-30 14:43:13 +08:00
import { el } from 'element-plus/es/locale';
const activeIndex = ref(0)
2024-12-05 21:33:52 +08:00
const activeTotalNum = ref(4)
2024-12-05 15:22:46 +08:00
const qualified = ref(0)
2024-12-05 21:33:52 +08:00
const outputDsc = ref('电压误差为±0.1Un% 电流误差为±0.5%')
2024-12-05 15:22:46 +08:00
const total = ref(0)
2024-12-18 15:49:29 +08:00
const dialogVisible = ref(false)
2024-12-20 10:21:36 +08:00
const active = ref(0)
let intervalId: NodeJS.Timeout | null = null;
const name = ref<string[]>([])//系数校准所选设备名字数组
const channel = ref<number[]>([])//系数校准所选设备通道数组
// 在 setup 函数中
const errorStates = ref(new Array(name.value.length).fill(false));
2024-12-30 14:43:13 +08:00
const loadingStates = ref(new Array(name.value.length).fill(false)); // 初始化 loading 状态
2024-12-20 10:21:36 +08:00
2024-12-23 14:05:53 +08:00
// 定义 TableDataItem 接口
interface TableDataItem {
id: string;
2024-12-23 15:08:14 +08:00
deviceName?: string;
2024-12-23 14:05:53 +08:00
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;
}
2024-12-23 15:08:14 +08:00
2024-12-30 14:43:13 +08:00
const dataTemplates3 = [
2024-12-23 15:08:14 +08:00
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
UaData: '—',
UaChannel:'—',
UbData: '—',
UbChannel: '—',
UcData: '—',
UcChannel: '—',
IaData: '—',
IaChannel: '—',
IbData: '—',
IbChannel: '—',
IcData: '—',
IcChannel: '—',
2024-12-23 15:08:14 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
UaData: '—',
UaChannel:'—',
UbData: '—',
UbChannel: '—',
UcData: '—',
UcChannel: '—',
IaData: '—',
IaChannel: '—',
IbData: '—',
IbChannel: '—',
IcData: '—',
IcChannel: '—',
2024-12-23 15:08:14 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
UaData: '—',
UaChannel:'—',
UbData: '—',
UbChannel: '—',
UcData: '—',
UcChannel: '—',
IaData: '—',
IaChannel: '—',
IbData: '—',
IbChannel: '—',
IcData: '—',
IcChannel: '—',
2024-12-23 15:08:14 +08:00
},
2024-12-30 14:43:13 +08:00
2024-12-23 15:08:14 +08:00
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
UaData: '—',
UaChannel:'—',
UbData: '—',
UbChannel: '—',
UcData: '—',
UcChannel: '—',
IaData: '—',
IaChannel: '—',
IbData: '—',
IbChannel: '—',
IcData: '—',
IcChannel: '—',
2024-12-23 15:08:14 +08:00
},
2024-12-30 14:43:13 +08:00
2024-12-23 15:08:14 +08:00
];
2024-12-30 14:43:13 +08:00
const dataTemplates4 = [
2024-12-23 15:08:14 +08:00
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
2024-12-23 15:08:14 +08:00
UaData: 57.74,
UaChannel: 1.0003,
UbData: 57.74,
UbChannel: 1.0003,
UcData: 57.74,
UcChannel: 1.0003,
2024-12-30 14:43:13 +08:00
IaData: 10,
2024-12-23 15:08:14 +08:00
IaChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IbData: 10,
2024-12-23 15:08:14 +08:00
IbChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IcData: 10,
2024-12-23 15:08:14 +08:00
IcChannel: 1.0001,
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
UaData: 5.774,
2024-12-23 15:08:14 +08:00
UaChannel: 1.0003,
2024-12-30 14:43:13 +08:00
UbData: 5.774,
2024-12-23 15:08:14 +08:00
UbChannel: 1.0003,
2024-12-30 14:43:13 +08:00
UcData: 5.774,
2024-12-23 15:08:14 +08:00
UcChannel: 1.0003,
2024-12-30 14:43:13 +08:00
IaData: 1,
2024-12-23 15:08:14 +08:00
IaChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IbData: 1,
2024-12-23 15:08:14 +08:00
IbChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IcData: 1,
2024-12-23 15:08:14 +08:00
IcChannel: 1.0001,
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
UaData: '—',
UaChannel:'—',
UbData: '—',
UbChannel: '—',
UcData: '—',
UcChannel: '—',
IaData: '—',
IaChannel: '—',
IbData: '—',
IbChannel: '—',
IcData: '—',
IcChannel: '—',
2024-12-23 15:08:14 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
UaData: '—',
UaChannel:'—',
UbData: '—',
UbChannel: '—',
UcData: '—',
UcChannel: '—',
IaData: '—',
IaChannel: '—',
IbData: '—',
IbChannel: '—',
IcData: '—',
IcChannel: '—',
2024-12-23 15:08:14 +08:00
},
];
2024-12-30 14:43:13 +08:00
const dataTemplates5 = [
2024-12-05 15:22:46 +08:00
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
2024-12-20 10:21:36 +08:00
UaData: 57.74,
UaChannel: 1.0003,
UbData: 57.74,
UbChannel: 1.0003,
UcData: 57.74,
UcChannel: 1.0003,
2024-12-30 14:43:13 +08:00
IaData: 10,
2024-12-20 10:21:36 +08:00
IaChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IbData: 10,
2024-12-20 10:21:36 +08:00
IbChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IcData: 10,
2024-12-20 10:21:36 +08:00
IcChannel: 1.0001,
2024-12-05 15:22:46 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
UaData: 5.774,
2024-12-20 10:21:36 +08:00
UaChannel: 1.0003,
2024-12-30 14:43:13 +08:00
UbData: 5.774,
2024-12-20 10:21:36 +08:00
UbChannel: 1.0003,
2024-12-30 14:43:13 +08:00
UcData: 5.774,
2024-12-20 10:21:36 +08:00
UcChannel: 1.0003,
2024-12-30 14:43:13 +08:00
IaData: 1,
2024-12-20 10:21:36 +08:00
IaChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IbData: 1,
2024-12-20 10:21:36 +08:00
IbChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IcData: 1,
2024-12-20 10:21:36 +08:00
IcChannel: 1.0001,
2024-12-05 15:22:46 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
2024-12-20 10:21:36 +08:00
UaData: 57.74,
2024-12-30 14:43:13 +08:00
UaChannel: '不合格',
2024-12-20 10:21:36 +08:00
UbData: 57.74,
UbChannel: '合格',
UcData: 57.74,
UcChannel: '合格',
2024-12-30 14:43:13 +08:00
IaData: 10,
2024-12-20 10:21:36 +08:00
IaChannel: '合格',
2024-12-30 14:43:13 +08:00
IbData: 10,
2024-12-20 10:21:36 +08:00
IbChannel: '合格',
2024-12-30 14:43:13 +08:00
IcData: 10,
2024-12-20 10:21:36 +08:00
IcChannel: '合格',
2024-12-05 15:22:46 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
UaData: 5.774,
UaChannel: '不合格',
UbData: 5.774,
2024-12-20 10:21:36 +08:00
UbChannel: '合格',
2024-12-30 14:43:13 +08:00
UcData: 5.774,
2024-12-20 10:21:36 +08:00
UcChannel: '合格',
2024-12-30 14:43:13 +08:00
IaData: 1,
2024-12-20 10:21:36 +08:00
IaChannel: '合格',
2024-12-30 14:43:13 +08:00
IbData: 1,
2024-12-20 10:21:36 +08:00
IbChannel: '合格',
2024-12-30 14:43:13 +08:00
IcData: 1,
2024-12-20 10:21:36 +08:00
IcChannel: '合格',
2024-12-05 15:22:46 +08:00
},
2024-12-30 14:43:13 +08:00
];
const dataTemplates6 = [
2024-12-05 15:22:46 +08:00
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
2024-12-20 10:21:36 +08:00
UaData: 57.74,
UaChannel: 1.0003,
UbData: 57.74,
UbChannel: 1.0003,
UcData: 57.74,
UcChannel: 1.0003,
2024-12-30 14:43:13 +08:00
IaData: 10,
2024-12-20 10:21:36 +08:00
IaChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IbData: 10,
2024-12-20 10:21:36 +08:00
IbChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IcData: 10,
2024-12-20 10:21:36 +08:00
IcChannel: 1.0001,
2024-12-05 15:22:46 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数下装',
UaData: 5.774,
2024-12-20 10:21:36 +08:00
UaChannel: 1.0003,
2024-12-30 14:43:13 +08:00
UbData: 5.774,
2024-12-20 10:21:36 +08:00
UbChannel: 1.0003,
2024-12-30 14:43:13 +08:00
UcData: 5.774,
2024-12-20 10:21:36 +08:00
UcChannel: 1.0003,
2024-12-30 14:43:13 +08:00
IaData: 1,
2024-12-20 10:21:36 +08:00
IaChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IbData: 1,
2024-12-20 10:21:36 +08:00
IbChannel: 1.0001,
2024-12-30 14:43:13 +08:00
IcData: 1,
2024-12-20 10:21:36 +08:00
IcChannel: 1.0001,
2024-12-05 15:22:46 +08:00
},
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
2024-12-20 10:21:36 +08:00
UaData: 57.74,
UaChannel: '合格',
UbData: 57.74,
UbChannel: '合格',
UcData: 57.74,
UcChannel: '合格',
2024-12-30 14:43:13 +08:00
IaData: 10,
2024-12-20 10:21:36 +08:00
IaChannel: '合格',
2024-12-30 14:43:13 +08:00
IbData: 10,
2024-12-20 10:21:36 +08:00
IbChannel: '合格',
2024-12-30 14:43:13 +08:00
IcData: 10,
2024-12-20 10:21:36 +08:00
IcChannel: '合格',
},
2024-12-05 15:22:46 +08:00
{
2024-12-30 14:43:13 +08:00
deviceName: '系数校准',
UaData: 5.774,
2024-12-20 10:21:36 +08:00
UaChannel: '合格',
2024-12-30 14:43:13 +08:00
UbData: 5.774,
2024-12-20 10:21:36 +08:00
UbChannel: '合格',
2024-12-30 14:43:13 +08:00
UcData: 5.774,
2024-12-20 10:21:36 +08:00
UcChannel: '合格',
2024-12-30 14:43:13 +08:00
IaData: 1,
2024-12-20 10:21:36 +08:00
IaChannel: '合格',
2024-12-30 14:43:13 +08:00
IbData: 1,
IbChannel: '合格',
IcData: 1,
2024-12-20 10:21:36 +08:00
IcChannel: '合格',
2024-12-05 15:22:46 +08:00
},
2024-12-30 14:43:13 +08:00
];
// 更新错误状态的方法
const updateErrorState = (index: number, hasError: boolean) => {
errorStates.value[index] = hasError;
};
const activities = [
2024-12-05 15:22:46 +08:00
{
2024-12-30 14:43:13 +08:00
content: '开始检测',
timestamp: '2018-04-12 20:46',
size: 'large',
color: '#0bbd87',
icon: SuccessFilled,
2024-12-05 21:33:52 +08:00
},
2024-12-23 14:05:53 +08:00
{
2024-12-30 14:43:13 +08:00
content: 'GPS上送时刻',
timestamp: '2018-04-03 20:46',
hollow: true,
2024-12-05 21:33:52 +08:00
},
{
2024-12-30 14:43:13 +08:00
content: '设备最早上送时刻',
timestamp: '2018-04-03 20:46',
hollow: true,
2024-12-05 21:33:52 +08:00
},
{
2024-12-30 14:43:13 +08:00
content: '设备最晚上送时刻',
timestamp: '2018-04-03 20:46',
hollow: true,
2024-12-05 21:33:52 +08:00
},
{
2024-12-30 14:43:13 +08:00
content: '检测结束',
timestamp: '2018-04-03 20:46',
hollow: true,
2024-12-05 15:22:46 +08:00
},
2024-12-30 14:43:13 +08:00
]
2024-12-23 14:05:53 +08:00
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
2024-12-23 15:08:14 +08:00
// [0, tableData1],
// [1, tableData2],
// [2, tableData3],
// [3, tableData1],
// [4, tableData1],
// [5, tableData1],
2024-12-23 14:05:53 +08:00
]);
2024-12-20 10:21:36 +08:00
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
2024-12-18 15:49:29 +08:00
// 打开弹窗,可能是新增,也可能是编辑
2024-12-20 10:21:36 +08:00
const open = (selection: Device.ResPqDev[]) => {
2024-12-23 14:05:53 +08:00
const checkStates = selection.map(item => item.checkState);
const allCheckStatesEqual = new Set(checkStates).size <= 1;
2024-12-30 14:43:13 +08:00
2024-12-23 14:05:53 +08:00
if (!allCheckStatesEqual) {
ElMessageBox.confirm(
'所勾选设备检测状态不一致,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return
}
2024-12-20 10:21:36 +08:00
name.value = selection.map(item => item.name)
channel.value = selection.map(item => item.devChns)
2024-12-18 15:49:29 +08:00
dialogVisible.value = true;
2024-12-20 10:21:36 +08:00
total.value = name.value.length
2024-12-23 15:08:14 +08:00
2024-12-30 14:43:13 +08:00
// 初始化 loadingStates 为 false
loadingStates.value = new Array(selection.length).fill(false);
errorStates.value = new Array(selection.length).fill(false);
2024-12-23 15:08:14 +08:00
for (let i = 0; i < channel.value.length; i++) {
const currentTableData = ref<TableDataItem[]>([]);
// 随机选择 dataTemplates 或 dataTemplates2
2024-12-30 14:43:13 +08:00
const selectedTemplates = dataTemplates3;
2024-12-23 15:08:14 +08:00
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)
}
2024-12-30 14:43:13 +08:00
// // 循环生成数据
// 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)
// }
2024-12-20 10:21:36 +08:00
}
const handleCancel=() => {
// 清空 name, channel, total
name.value = [];
channel.value = [];
total.value = 0;
activeIndex.value = 0
qualified.value = 0
active.value = 0
2024-12-20 10:21:36 +08:00
dialogVisible.value = false
2024-12-05 15:22:46 +08:00
}
2024-12-18 15:49:29 +08:00
2024-12-20 10:21:36 +08:00
const getTableDataForChannel = (index: number): any[] => {
const data = tableDataMap.get(index);
2024-12-30 14:43:13 +08:00
// console.log('index',index)
// console.log('data',data)
2024-12-20 10:21:36 +08:00
return data ? data.value : [];
}
2024-12-18 15:49:29 +08:00
// const props = defineProps({
// testStatus: {
// type: String,
// default: 'wait'
// }
// })
// const testStatus = toRef(props, 'testStatus');
// const ts = ref('');
// //监听goods_sn的变化
// watch(testStatus, function (newValue, oldValue) {
// ts.value = props.testStatus;
// if (ts.value === 'start') {
// ts.value = 'process'
// 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)
// ts.value = 'success'
// }
// else {
// clearInterval(timer)
// ts.value = 'success'
// }
// total.value = activeTotalNum.value
// }, 1000);
// }
// })
// const emit = defineEmits(['update:testStatus']);
// //监听sn
// watch(ts, function (newValue, oldValue) {
// //修改父组件
// emit('update:testStatus', ts.value)
// })
watch(activeIndex, function (newValue, oldValue) {
2024-12-20 10:21:36 +08:00
if(activeIndex.value === 1)
{
outputDsc.value = "电压误差为±0.1Un% 电流误差为±0.5%";
// 当前源输出为Ua=Ub=Uc=57.74V Ia=Ib=Ic=1A"
}
})
2024-12-18 15:49:29 +08:00
2024-12-20 10:21:36 +08:00
// 示例的 checkForErrors 函数,根据实际需求进行调整
const checkForErrors = (data: TableDataItem[]): boolean => {
// 这里假设不合格字段的标准是 status 为 '不合格' 或 isValid 为 false
return data.some(item =>
item.UaChannel === '不合格' ||
item.UbChannel === '不合格' ||
item.UcChannel === '不合格' ||
item.IaChannel === '不合格' ||
item.IbChannel === '不合格' ||
item.IcChannel === '不合格'
);
};
2024-12-30 14:43:13 +08:00
const handleSubmit = async () => {
if (intervalId !== null) {
clearInterval(intervalId);
}
// 初始化 currentTableData
let isTimer2Completed = false;
// 设置 loading 状态为 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);
const currentTableData = ref<TableDataItem[]>([]);
const selectedTemplates = dataTemplates4;
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);
console.log('tableDataMap after set', tableDataMap);
activeIndex.value++;
// 启动 timer2
let 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();
selectedTemplates.forEach((template) => {
currentTableData.value.push({
id: id,
MonitorIdx: j + 1,
...template,
});
});
}
}
tableDataMap.set(i, currentTableData);
clearInterval(timer2);
const currentDataRef = tableDataMap.get(activeIndex.value - 1);
console.log('activeIndex.value',activeIndex.value);
console.log('tableDataMap',tableDataMap);
console.log('currentDataRef',currentDataRef);
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
} else {
qualified.value++;
}
updateErrorState(activeIndex.value - 1, hasError);
}
activeIndex.value++;
// 设置标志变量为 true表示 timer2 已经完成
isTimer2Completed = true;
}, 3000);
// 等待 timer2 完成
while (!isTimer2Completed) {
// 这里可以添加一个短暂的等待,避免死循环
await new Promise(resolve => setTimeout(resolve, 100));
}
// 重置标志变量
isTimer2Completed = false;
}
// 启动 timer1
let timer1 = setInterval(() => {
active.value++;
if (active.value > 5) {
clearInterval(timer1);
}
}, 1000);
};
const handleSubmit2 = () => {
2024-12-20 10:21:36 +08:00
if (intervalId !== null) {
clearInterval(intervalId);
}
intervalId = setInterval(() => {
if (activeIndex.value < name.value.length) {
activeIndex.value++;
// 获取当前活动索引对应的 tableData
2024-12-23 14:05:53 +08:00
const currentDataRef = tableDataMap.get(activeIndex.value - 1);
2024-12-20 10:21:36 +08:00
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
2024-12-23 14:05:53 +08:00
}else{
2024-12-20 10:21:36 +08:00
qualified.value++;
}
2024-12-23 14:05:53 +08:00
updateErrorState(activeIndex.value - 1, hasError);
2024-12-05 15:22:46 +08:00
}
2024-12-20 10:21:36 +08:00
} else {
clearInterval(intervalId!); // 停止定时器
}
2024-12-05 15:22:46 +08:00
2024-12-23 14:05:53 +08:00
}, 1000); // 每隔3秒显示下一个tab
2024-12-20 10:21:36 +08:00
// 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);
2024-12-18 15:49:29 +08:00
2024-12-20 10:21:36 +08:00
let timer2 = setInterval(() => {
active.value++
2024-12-30 14:43:13 +08:00
if (active.value++ > 5) {
2024-12-20 10:21:36 +08:00
clearInterval(timer2)
}
}, 1000);
2024-12-18 15:49:29 +08:00
};
2024-11-21 23:02:43 +08:00
2024-12-18 15:49:29 +08:00
// 对外映射
defineExpose({ open })
2024-12-18 15:49:29 +08:00
</script>
<style scoped>
2024-12-05 15:22:46 +08:00
.right-title {
display: flex;
flex-direction: row;
/* 横向排列 */
justify-content: space-between;
margin-bottom: 10px;
}
.custom-tabs-label .el-icon {
2024-11-25 21:11:10 +08:00
vertical-align: middle;
}
2024-12-05 15:22:46 +08:00
2024-11-25 21:11:10 +08:00
.custom-tabs-label span {
vertical-align: middle;
margin-left: 4px;
}
2024-12-05 15:22:46 +08:00
.dialog-content {
2024-12-30 14:43:13 +08:00
height: 510px;
2024-12-05 11:07:54 +08:00
}
2024-12-05 15:22:46 +08:00
2024-12-05 11:07:54 +08:00
.el-tabs--border-card {
2024-12-20 10:21:36 +08:00
height: 470px;
2024-12-05 15:22:46 +08:00
}
.el-icon svg {
color: #ff7171;
2024-12-05 11:07:54 +08:00
}
2024-12-20 10:21:36 +08:00
.container {
display: flex;
}
.dialog-left {
flex: 1;
}
.right-content {
flex: 5;
}
</style>