微调
This commit is contained in:
@@ -55,8 +55,8 @@
|
||||
</el-steps>
|
||||
</div>
|
||||
<div class="right-content">
|
||||
<el-tabs type="border-card">
|
||||
<div >
|
||||
<el-tabs type="border-card" :active-index="String(activeIndex)" >
|
||||
<!-- <div > -->
|
||||
<el-tab-pane v-for="(device, index) in name" :key="index" :label="device">
|
||||
<template #label>
|
||||
<span class="custom-tabs-label">
|
||||
@@ -68,8 +68,8 @@
|
||||
</template>
|
||||
<channelsTestTable :tableData="getTableDataForChannel(index)" :loading="loadingStates[index]"></channelsTestTable>
|
||||
</el-tab-pane>
|
||||
</div>
|
||||
<el-empty description="暂无数据,等待检测开始" v-if="activeIndex === 0" />
|
||||
<!-- </div> -->
|
||||
<!-- <el-empty description="暂无数据,等待检测开始" v-if="activeIndex === 0" /> -->
|
||||
</el-tabs>
|
||||
|
||||
<!-- <el-tabs type="border-card">
|
||||
@@ -120,7 +120,7 @@ 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 { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElMessage, ElMessageBox, TabsPaneContext } from 'element-plus';
|
||||
const activeIndex = ref(0)
|
||||
const activeTotalNum = ref(4)
|
||||
const qualified = ref(0)
|
||||
@@ -128,7 +128,6 @@ const outputDsc = ref('电压误差为:±0.1Un%; 电流误差为:±0.5%')
|
||||
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[]>([])//系数校准所选设备名字数组
|
||||
@@ -137,6 +136,21 @@ const channel = ref<number[]>([])//系数校准所选设备通道数组
|
||||
const errorStates = ref(new Array(name.value.length).fill(false));
|
||||
const loadingStates = ref(new Array(name.value.length).fill(false)); // 初始化 loading 状态
|
||||
|
||||
const props = defineProps({
|
||||
webMsgSend: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const webMsgSend = toRef(props, 'webMsgSend');
|
||||
|
||||
watch(webMsgSend,function (newValue,oldValue){
|
||||
switch (newValue.requestId){
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 定义 TableDataItem 接口
|
||||
interface TableDataItem {
|
||||
@@ -161,6 +175,8 @@ interface TableDataItem {
|
||||
|
||||
const dataTemplates3 = [
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 1, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: '—',
|
||||
UaChannel:'—',
|
||||
@@ -176,6 +192,8 @@ const dataTemplates3 = [
|
||||
IcChannel: '—',
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 2, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: '—',
|
||||
UaChannel:'—',
|
||||
@@ -191,6 +209,8 @@ const dataTemplates3 = [
|
||||
IcChannel: '—',
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 3, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: '—',
|
||||
UaChannel:'—',
|
||||
@@ -207,6 +227,8 @@ const dataTemplates3 = [
|
||||
},
|
||||
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 4, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: '—',
|
||||
UaChannel:'—',
|
||||
@@ -226,6 +248,8 @@ const dataTemplates3 = [
|
||||
|
||||
const dataTemplates4 = [
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: 57.74,
|
||||
UaChannel: 1.0003,
|
||||
@@ -241,6 +265,8 @@ const dataTemplates4 = [
|
||||
IcChannel: 1.0001,
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: 5.774,
|
||||
UaChannel: 1.0003,
|
||||
@@ -256,6 +282,8 @@ const dataTemplates4 = [
|
||||
IcChannel: 1.0001,
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: '—',
|
||||
UaChannel:'—',
|
||||
@@ -271,6 +299,8 @@ const dataTemplates4 = [
|
||||
IcChannel: '—',
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: '—',
|
||||
UaChannel:'—',
|
||||
@@ -289,6 +319,8 @@ const dataTemplates4 = [
|
||||
|
||||
const dataTemplates5 = [
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: 57.74,
|
||||
UaChannel: 1.0003,
|
||||
@@ -304,6 +336,8 @@ const dataTemplates5 = [
|
||||
IcChannel: 1.0001,
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: 5.774,
|
||||
UaChannel: 1.0003,
|
||||
@@ -319,6 +353,8 @@ const dataTemplates5 = [
|
||||
IcChannel: 1.0001,
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: 57.74,
|
||||
UaChannel: '不合格',
|
||||
@@ -334,6 +370,8 @@ const dataTemplates5 = [
|
||||
IcChannel: '合格',
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: 5.774,
|
||||
UaChannel: '不合格',
|
||||
@@ -352,6 +390,8 @@ const dataTemplates5 = [
|
||||
|
||||
const dataTemplates6 = [
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: 57.74,
|
||||
UaChannel: 1.0003,
|
||||
@@ -367,6 +407,8 @@ const dataTemplates6 = [
|
||||
IcChannel: 1.0001,
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数下装',
|
||||
UaData: 5.774,
|
||||
UaChannel: 1.0003,
|
||||
@@ -382,6 +424,8 @@ const dataTemplates6 = [
|
||||
IcChannel: 1.0001,
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: 57.74,
|
||||
UaChannel: '合格',
|
||||
@@ -397,6 +441,8 @@ const dataTemplates6 = [
|
||||
IcChannel: '合格',
|
||||
},
|
||||
{
|
||||
id: '', // 新增 id 属性
|
||||
MonitorIdx: 0, // 新增 MonitorIdx 属性
|
||||
deviceName: '系数校准',
|
||||
UaData: 5.774,
|
||||
UaChannel: '合格',
|
||||
@@ -454,7 +500,6 @@ const activities = [
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = (selection: Device.ResPqDev[]) => {
|
||||
|
||||
const checkStates = selection.map(item => item.checkState);
|
||||
const allCheckStatesEqual = new Set(checkStates).size <= 1;
|
||||
|
||||
@@ -483,21 +528,7 @@ const activities = [
|
||||
errorStates.value = new Array(selection.length).fill(false);
|
||||
|
||||
for (let i = 0; i < channel.value.length; i++) {
|
||||
const currentTableData = ref<TableDataItem[]>([]);
|
||||
// 随机选择 dataTemplates 或 dataTemplates2
|
||||
const selectedTemplates = dataTemplates3;
|
||||
|
||||
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,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const currentTableData = initializeTableData(dataTemplates3, i);
|
||||
tableDataMap.set(i,currentTableData)
|
||||
}
|
||||
}
|
||||
@@ -569,7 +600,9 @@ watch(activeIndex, function (newValue, oldValue) {
|
||||
outputDsc.value = "电压误差为:±0.1Un%; 电流误差为:±0.5%";
|
||||
// 当前源输出为:Ua=Ub=Uc=57.74V Ia=Ib=Ic=1A"
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 示例的 checkForErrors 函数,根据实际需求进行调整
|
||||
const checkForErrors = (data: TableDataItem[]): boolean => {
|
||||
@@ -585,35 +618,21 @@ const checkForErrors = (data: TableDataItem[]): boolean => {
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (intervalId !== null) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
|
||||
// 初始化 currentTableData
|
||||
let isTimer2Completed = false;
|
||||
// 初始化 loadingStates 为 true
|
||||
loadingStates.value = new Array(name.value.length).fill(true);
|
||||
|
||||
for (let i = 0; i < channel.value.length; i++) {
|
||||
|
||||
// 重置状态变量
|
||||
active.value = 0;activeIndex.value = 0;
|
||||
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,
|
||||
});
|
||||
});
|
||||
}
|
||||
active.value = 0;
|
||||
//activeIndex.value = 0;
|
||||
|
||||
// 初始化并填充 currentTableData
|
||||
const currentTableData = initializeTableData(dataTemplates4, i);
|
||||
tableDataMap.set(i, currentTableData);
|
||||
activeIndex.value++;
|
||||
//activeIndex.value++;
|
||||
|
||||
// 清除之前的 timer1
|
||||
clearInterval(timer1);
|
||||
// 启动 timer1
|
||||
@@ -628,35 +647,8 @@ for (let i = 0; i < channel.value.length; i++) {
|
||||
clearInterval(timer2);
|
||||
// 启动 timer2
|
||||
timer2 = setInterval(() => {
|
||||
// 初始化 currentTableData
|
||||
const currentTableData = ref<TableDataItem[]>([]);
|
||||
|
||||
if(i > 0){
|
||||
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,
|
||||
});
|
||||
});
|
||||
}
|
||||
}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,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化并填充 currentTableData
|
||||
const currentTableData = initializeTableData(i > 0 ? dataTemplates5 : dataTemplates6, i);
|
||||
tableDataMap.set(i, currentTableData);
|
||||
activeIndex.value++;
|
||||
|
||||
@@ -681,16 +673,139 @@ for (let i = 0; i < channel.value.length; i++) {
|
||||
while (!isTimer2Completed) {
|
||||
// 这里可以添加一个短暂的等待,避免死循环
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
}
|
||||
|
||||
// 重置标志变量
|
||||
isTimer2Completed = false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// 提取初始化并填充 currentTableData 的函数
|
||||
const initializeTableData = (templates: TableDataItem[], index: number): Ref<TableDataItem[]> => {
|
||||
const currentTableData = ref<TableDataItem[]>([]);
|
||||
|
||||
for (let j = 0; j < channel.value[index]; j++) {
|
||||
const id = (j + 1).toString();
|
||||
templates.forEach((template) => {
|
||||
// 使用解构赋值排除 id 和 MonitorIdx 属性
|
||||
const { id: _, MonitorIdx: __, ...rest } = template;
|
||||
currentTableData.value.push({
|
||||
id,
|
||||
MonitorIdx: j + 1,
|
||||
...rest,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return currentTableData;
|
||||
};
|
||||
|
||||
|
||||
// const handleSubmit = async () => {
|
||||
// // 初始化 currentTableData
|
||||
// let isTimer2Completed = false;
|
||||
// // 初始化 loadingStates 为 true
|
||||
// loadingStates.value = new Array(name.value.length).fill(true);
|
||||
|
||||
// for (let i = 0; i < channel.value.length; i++) {
|
||||
|
||||
// // 重置状态变量
|
||||
// active.value = 0;activeIndex.value = 0;
|
||||
// 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);
|
||||
// activeIndex.value++;
|
||||
// // 清除之前的 timer1
|
||||
// clearInterval(timer1);
|
||||
// // 启动 timer1
|
||||
// timer1 = setInterval(() => {
|
||||
// active.value++;
|
||||
// if (active.value > 5) {
|
||||
// clearInterval(timer1);
|
||||
// }
|
||||
// }, 500);
|
||||
|
||||
// // 清除之前的 timer2
|
||||
// clearInterval(timer2);
|
||||
// // 启动 timer2
|
||||
// timer2 = setInterval(() => {
|
||||
// // 初始化 currentTableData
|
||||
// const currentTableData = ref<TableDataItem[]>([]);
|
||||
|
||||
// if(i > 0){
|
||||
// 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,
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }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,
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// tableDataMap.set(i, currentTableData);
|
||||
// activeIndex.value++;
|
||||
|
||||
// clearInterval(timer2);
|
||||
// const currentDataRef = tableDataMap.get(i);
|
||||
// if (currentDataRef) {
|
||||
// const currentData = currentDataRef.value;
|
||||
// // 检查当前数据中有无不合格字段
|
||||
// const hasError = checkForErrors(currentData);
|
||||
// if (hasError) {
|
||||
// } else {
|
||||
// qualified.value++;
|
||||
// }
|
||||
// updateErrorState(i, hasError);
|
||||
// }
|
||||
|
||||
// // 设置标志变量为 true,表示 timer2 已经完成
|
||||
// isTimer2Completed = true;
|
||||
// }, 3000);
|
||||
|
||||
// // 等待 timer2 完成
|
||||
// while (!isTimer2Completed) {
|
||||
// // 这里可以添加一个短暂的等待,避免死循环
|
||||
// await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
// }
|
||||
|
||||
// // 重置标志变量
|
||||
// isTimer2Completed = false;
|
||||
// }
|
||||
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
@@ -290,8 +290,6 @@
|
||||
|
||||
// 监听 tableData 的变化
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
></matchPopup>
|
||||
|
||||
<!--系数校准-->
|
||||
<ChannelsTest ref="channelsTest"></ChannelsTest>
|
||||
<ChannelsTest ref="channelsTest" :webMsgSend="webMsgSend"></ChannelsTest>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -262,7 +262,7 @@ import socketClient from '@/utils/webSocketClient';
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const checkStore = useCheckStore()
|
||||
|
||||
const webMsgSend = ref();//webSocket推送的数据
|
||||
let devNum = 0;//当前选取的被检设备数量
|
||||
let devChannelsNum = 0;//当前选择的被检设备通道总数
|
||||
let devTestedNum = 0;//当前选择的已完成检测的被检设备数量
|
||||
@@ -855,11 +855,28 @@ const handleTest = async (val:string) => {
|
||||
|
||||
}
|
||||
|
||||
if(val==='系数校准')
|
||||
{
|
||||
if(val === '系数校准') {
|
||||
// //开始创建webSocket客户端
|
||||
// const data = reactive({
|
||||
// socketServe: socketClient.Instance,
|
||||
// });
|
||||
// const url = 'ws://localhost:7777/hello?name=cdf';
|
||||
// socketClient.Instance.connect(url);
|
||||
// data.socketServe = socketClient.Instance;
|
||||
// data.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
|
||||
// // 处理来自服务器的消息
|
||||
// console.log('Received message:', res);
|
||||
// // 根据需要在这里添加更多的处理逻辑
|
||||
// if(res.code === 20000){
|
||||
// ElMessage.error(message.message)
|
||||
// loading.close()
|
||||
// }else {
|
||||
// webMsgSend.value = res
|
||||
// }
|
||||
// });
|
||||
|
||||
channelsTest.value?.open(channelsSelection.value)
|
||||
return
|
||||
channelsTest.value?.open(channelsSelection.value);
|
||||
return;
|
||||
}
|
||||
|
||||
if(devTestedNum == 0)
|
||||
|
||||
Reference in New Issue
Block a user