2025-02-25 10:17:33 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="dialog" v-bind="dialogBig">
|
|
|
|
|
|
<div class="dialog-content">
|
|
|
|
|
|
<div class="right-title">
|
|
|
|
|
|
<!-- <div>系数校准表</div> -->
|
|
|
|
|
|
<div>{{ outputDsc }}</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span style=" font-size: 18px;font-weight: 600;">
|
2025-03-17 15:55:30 +08:00
|
|
|
|
设备已合格 <span style="color: #91cc75">{{ qualified }}</span> 台/共 <span style="color: green">{{ total }}</span>
|
2025-02-25 10:17:33 +08:00
|
|
|
|
台
|
|
|
|
|
|
</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>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<span>大电压/电流系数下装</span><br/>
|
|
|
|
|
|
<span class="spanStyle">源输出为:</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 0">{{ big_V_Download }}</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 0">{{ big_I_Download }}</span>
|
|
|
|
|
|
<el-icon v-if="active === 1 " class="loading-box">
|
|
|
|
|
|
<el-icon-loading/>
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-step>
|
|
|
|
|
|
<el-step>
|
|
|
|
|
|
<template #title>
|
|
|
|
|
|
<span>小电压/电流系数下装</span><br/>
|
|
|
|
|
|
<span class="spanStyle">源输出为:</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 1">{{ small_V_Download }}</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 1">{{ small_I_Download }}</span>
|
|
|
|
|
|
<el-icon v-if="active === 2" class="loading-box">
|
|
|
|
|
|
<el-icon-loading/>
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-step>
|
|
|
|
|
|
<el-step>
|
|
|
|
|
|
<template #title>
|
|
|
|
|
|
<span>大电压/电流校准</span><br/>
|
|
|
|
|
|
<span class="spanStyle">源输出为:</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 2">{{ big_V_Adjust }}</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 2">{{ big_I_Adjust }}</span>
|
|
|
|
|
|
<el-icon v-if="active === 3" class="loading-box">
|
|
|
|
|
|
<el-icon-loading/>
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-step>
|
|
|
|
|
|
<el-step>
|
|
|
|
|
|
<template #title>
|
|
|
|
|
|
<span>小电压/电流校准</span><br/>
|
|
|
|
|
|
<span class="spanStyle">源输出为:</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 3">{{ small_V_Adjust }}</span><br/>
|
|
|
|
|
|
<span class="spanStyle" v-if="active > 3">{{ small_I_Adjust }}</span>
|
|
|
|
|
|
<el-icon v-if="active === 4" class="loading-box">
|
|
|
|
|
|
<el-icon-loading/>
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-step>
|
|
|
|
|
|
<el-step title="结束"/>
|
|
|
|
|
|
</el-steps>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="right-content">
|
|
|
|
|
|
<el-tabs type="border-card" v-model="editableTabsValue" :active-index="String(activeIndex)">
|
|
|
|
|
|
<el-tab-pane v-for="(device, index) in name" :key="index" :label="device">
|
|
|
|
|
|
<template #label>
|
|
|
|
|
|
<span class="custom-tabs-label">
|
|
|
|
|
|
<span>{{ device }}</span>
|
|
|
|
|
|
<el-icon v-if="errorStates[index]" class="icon-style">
|
|
|
|
|
|
<Failed/>
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<channelsTestTable
|
|
|
|
|
|
:tableData="getTableDataForChannel(index)"
|
|
|
|
|
|
:big_V_loading="big_V_loadingStates"
|
|
|
|
|
|
:curV="CurV">
|
|
|
|
|
|
</channelsTestTable>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
</el-tabs>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="tsx" setup name="FactorTest">
|
2025-08-11 11:14:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 系数校准组件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 功能概述:
|
|
|
|
|
|
* 1. 对电力设备进行系数校准,确保测量精度
|
|
|
|
|
|
* 2. 包含4个校准步骤:大/小电压电流系数的下装和校准
|
|
|
|
|
|
* 3. 支持多设备并行校准,实时显示校准数据和结果
|
|
|
|
|
|
* 4. 校准完成后自动统计合格设备数量并通知父组件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 校准流程:
|
|
|
|
|
|
* 第1步:大电压/电流系数下装 - 向设备下发大幅值的系数参数
|
|
|
|
|
|
* 第2步:小电压/电流系数下装 - 向设备下发小幅值的系数参数
|
|
|
|
|
|
* 第3步:大电压/电流校准 - 使用大幅值进行校准测试
|
|
|
|
|
|
* 第4步:小电压/电流校准 - 使用小幅值进行校准测试
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
import {type Device} from '@/api/device/interface/device';
|
|
|
|
|
|
import {Failed} from '@element-plus/icons-vue'
|
2025-02-26 10:52:39 +08:00
|
|
|
|
import {onBeforeMount, type Ref, ref, toRef, watch} from 'vue'
|
2025-02-25 10:17:33 +08:00
|
|
|
|
import {dialogBig} from '@/utils/elementBind'
|
|
|
|
|
|
import {ElMessageBox} from 'element-plus';
|
|
|
|
|
|
import {getCoefficientCheck} from '@/api/home/channelsTest/index'
|
|
|
|
|
|
import type {ChannelsTest} from '@/api/home/interface/channelsTest';
|
|
|
|
|
|
import type {Plan} from '@/api/plan/interface';
|
|
|
|
|
|
import {useCheckStore} from "@/stores/modules/check";
|
2025-03-28 09:31:46 +08:00
|
|
|
|
import {useUserStore} from "@/stores/modules/user";
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 状态管理 ====================
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const checkStore = useCheckStore()
|
2025-08-11 11:14:20 +08:00
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 界面控制变量 ====================
|
|
|
|
|
|
const activeIndex = ref(0) // 当前活跃的表格数据索引
|
|
|
|
|
|
const activeTotalNum = ref(4) // 总步骤数
|
|
|
|
|
|
const qualified = ref(0) // 已合格的设备数量
|
|
|
|
|
|
const outputDsc = ref('电压误差为:±0.1Un%; 电流误差为:±0.5%') // 输出描述信息
|
|
|
|
|
|
const total = ref(0) // 设备总数
|
|
|
|
|
|
const dialogVisible = ref(false) // 弹窗显示状态
|
|
|
|
|
|
const active = ref(0) // 当前激活的校准步骤(0-5)
|
|
|
|
|
|
const editableTabsValue = ref('0') // 当前选中的标签页
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 定时器管理 ====================
|
|
|
|
|
|
let timer1: NodeJS.Timeout | null = null // 定时器1
|
|
|
|
|
|
let timer2: NodeJS.Timeout | null = null // 定时器2
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 设备信息管理 ====================
|
|
|
|
|
|
const name = ref<string[]>([]) // 系数校准所选设备名称数组
|
|
|
|
|
|
const channel = ref<number[]>([]) // 系数校准所选设备通道数量数组
|
|
|
|
|
|
const devIdArray = ref<string[]>([]) // 系数校准所选设备ID数组
|
|
|
|
|
|
const select_Plan = ref<Plan.ReqPlan>() // 选中的检测计划
|
|
|
|
|
|
const planId = ref('') // 计划ID
|
|
|
|
|
|
const CurV = ref<number>() // 额定电压值
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 状态控制变量 ====================
|
|
|
|
|
|
const isButtonDisabled = ref(false) // 按钮禁用状态
|
|
|
|
|
|
const errorStates = ref(new Array(name.value.length).fill(false)) // 各设备错误状态数组
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 加载状态管理 ====================
|
|
|
|
|
|
const big_V_loadingStates = ref(false) // 大电压大电流下装加载状态
|
|
|
|
|
|
const small_V_loadingStates = ref(false) // 小电压小电流下装加载状态
|
|
|
|
|
|
const big_V_loadingStates2 = ref(false) // 大电压大电流校准加载状态
|
|
|
|
|
|
const small_V_loadingStates2 = ref(false) // 小电压小电流校准加载状态
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 源输出参数显示 ====================
|
|
|
|
|
|
const big_V_Download = ref('') // 大电压下装时的电压输出显示
|
|
|
|
|
|
const big_I_Download = ref('') // 大电压下装时的电流输出显示
|
|
|
|
|
|
const small_V_Download = ref('') // 小电压下装时的电压输出显示
|
|
|
|
|
|
const small_I_Download = ref('') // 小电压下装时的电流输出显示
|
|
|
|
|
|
const big_V_Adjust = ref('') // 大电压校准时的电压输出显示
|
|
|
|
|
|
const big_I_Adjust = ref('') // 大电压校准时的电流输出显示
|
|
|
|
|
|
const small_V_Adjust = ref('') // 小电压校准时的电压输出显示
|
|
|
|
|
|
const small_I_Adjust = ref('') // 小电压校准时的电流输出显示
|
|
|
|
|
|
// ==================== 组件Props定义 ====================
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const props = defineProps({
|
2025-02-26 10:52:39 +08:00
|
|
|
|
testStatus: {
|
|
|
|
|
|
type: String,
|
2025-08-11 11:14:20 +08:00
|
|
|
|
default: 'wait' // 从父组件接收的测试状态
|
2025-02-26 10:52:39 +08:00
|
|
|
|
},
|
2025-02-25 10:17:33 +08:00
|
|
|
|
webMsgSend: {
|
|
|
|
|
|
type: Object,
|
2025-08-11 11:14:20 +08:00
|
|
|
|
default: () => ({}) // 从父组件接收的WebSocket消息
|
2025-02-26 10:52:39 +08:00
|
|
|
|
},
|
2025-02-25 10:17:33 +08:00
|
|
|
|
})
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// ==================== 响应式Props引用 ====================
|
2025-02-26 10:52:39 +08:00
|
|
|
|
const testStatus = toRef(props, 'testStatus');
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const webMsgSend = toRef(props, 'webMsgSend');
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 数据管理 ====================
|
|
|
|
|
|
const tableDataMap = new Map<number, Ref<ChannelsTest.CoefficientVO[]>>([]); // 存储每个设备的表格数据映射
|
|
|
|
|
|
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish'); // 当前步骤状态
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 组件生命周期 ====================
|
2025-02-25 10:17:33 +08:00
|
|
|
|
onBeforeMount(() => {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
initData() // 组件挂载前初始化数据
|
2025-02-25 10:17:33 +08:00
|
|
|
|
})
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 初始化组件数据
|
|
|
|
|
|
* 从store中获取设备信息,初始化表格数据和状态变量
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const initData = () => {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 获取设备基础信息
|
|
|
|
|
|
CurV.value = checkStore.devices[0]?.devVolt || 57.74; // 获取额定电压,默认57.74V
|
|
|
|
|
|
isButtonDisabled.value = false; // 恢复按钮可用状态
|
|
|
|
|
|
select_Plan.value = checkStore.plan // 获取检测计划
|
|
|
|
|
|
planId.value = checkStore.devices[0]?.planId || ''; // 获取计划ID
|
|
|
|
|
|
|
|
|
|
|
|
// 提取设备信息数组
|
|
|
|
|
|
devIdArray.value = checkStore.devices.map(item => item.deviceId); // 设备ID数组
|
|
|
|
|
|
name.value = checkStore.devices.map(item => item.deviceName); // 设备名称数组
|
|
|
|
|
|
channel.value = checkStore.devices.map(item => item.chnNum); // 设备通道数量数组
|
|
|
|
|
|
|
|
|
|
|
|
// 设置界面状态
|
|
|
|
|
|
dialogVisible.value = true; // 显示弹窗
|
|
|
|
|
|
total.value = name.value.length; // 设置设备总数
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化错误状态数组,所有设备初始状态为无错误
|
2025-02-26 10:52:39 +08:00
|
|
|
|
errorStates.value = new Array(checkStore.devices.length).fill(false);
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 为每个设备初始化表格数据
|
2025-02-25 10:17:33 +08:00
|
|
|
|
for (let i = 0; i < channel.value.length; i++) {
|
|
|
|
|
|
const currentTableData = initializeTableData(dataTemplates, i);
|
2025-08-11 11:14:20 +08:00
|
|
|
|
tableDataMap.set(i, currentTableData); // 将表格数据存储到Map中,以设备索引为key
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 状态监听器 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 监听父组件传入的测试状态变化
|
|
|
|
|
|
* 当父组件通知开始测试时,启动系数校准流程
|
|
|
|
|
|
*/
|
2025-02-26 10:52:39 +08:00
|
|
|
|
watch(testStatus, function (newValue, oldValue) {
|
|
|
|
|
|
if (newValue === 'start') {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 父组件通知开始系数校准操作
|
|
|
|
|
|
handleSubmit()
|
|
|
|
|
|
}
|
2025-02-26 10:52:39 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 监听WebSocket消息,处理系数校准过程中的各种响应
|
|
|
|
|
|
* 主要处理:
|
|
|
|
|
|
* 1. 错误代码的统一处理
|
|
|
|
|
|
* 2. 系数校准流程的各个步骤响应
|
|
|
|
|
|
* 3. 表格数据的实时更新
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
watch(webMsgSend, function (newValue, oldValue) {
|
2025-02-26 19:20:02 +08:00
|
|
|
|
console.log('webMsgSend---code', newValue.code)
|
|
|
|
|
|
console.log('webMsgSend---requestId', newValue.requestId)
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 只有在非等待状态下才处理WebSocket消息
|
2025-04-14 13:22:46 +08:00
|
|
|
|
if (testStatus.value !== 'waiting') {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 通用错误代码处理 ====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
if (newValue.code == 10520) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 报文解析异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('报文解析异常!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10521) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 程控源参数有误
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('程控源參数有误!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10522) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 测试项解析有误
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('测试项解析有误!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10523) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 源连接失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('源连接失败!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10524) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 获取源控制权失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('获取源控制权失败!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10525) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 重置源失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('重置源失败!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10527) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 源未进行初始化
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('源未进行初始化!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10528) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 目标源有误(用户已控制其他源)
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('目标源有误(该用户已控制其他源,在关闭前无法操作新的源)!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10529) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 源状态有误,无法响应报文
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10550) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 设备连接异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert(`${newValue.data}设备连接异常!`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10551) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 设备触发报告异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
2025-08-11 11:14:20 +08:00
|
|
|
|
} else if (newValue.code == 10552) {
|
|
|
|
|
|
// 存在已经初始化步骤,执行自动关闭
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 特定业务消息处理 ====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
console.log('显示东西code', newValue.code)
|
|
|
|
|
|
console.log('显示东西requestId', newValue.requestId)
|
|
|
|
|
|
switch (newValue.requestId) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 处理源通讯校验相关消息
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'yjc_ytxjy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case'INIT_GATHER':
|
|
|
|
|
|
if (newValue.code == -1) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 源未知异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('源未知异常', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10523) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 源连接失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('源连接失败', '源连接失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 处理相序校验相关消息
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'YJC_xujy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'OPER_GATHER':
|
|
|
|
|
|
if (newValue.code == 10552) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 存在已经初始化步骤,执行自动关闭
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10520) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 解析报文异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('解析报文异常,执行自动关闭,请重新发起检测', '解析报文异常', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'DATA_REQUEST$02':
|
|
|
|
|
|
if (newValue.code == 25003) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 相序校验未通过
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('相序校验未通过,执行自动关闭,请重新发起检测', '相序校验未通过', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 处理设备通讯校验相关消息
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'yjc_sbtxjy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'INIT_GATHER$01':
|
|
|
|
|
|
if (newValue.code == 10550) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 设备连接异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('设备连接异常', '设备连接异常', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10551) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 设备触发报告异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('设备触发报告异常', '设备触发报告异常', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10552) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 存在已经初始化步骤,执行自动关闭
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
} else if (newValue.code == 10520) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 解析报文异常
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('解析报文异常,执行自动关闭,请重新发起检测', '解析报文异常', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 处理协议校验相关消息
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'yjc_xyjy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'VERIFY_MAPPING$01':
|
|
|
|
|
|
if (newValue.code == 10200) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 脚本与ICD校验失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
let data = JSON.parse(newValue.data)
|
|
|
|
|
|
ElMessageBox.alert(`脚本与icd校验失败!icd名称:${data['icdType']} -> 校验项:${data['dataType']}`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
}
|
2025-05-22 18:43:33 +08:00
|
|
|
|
if (newValue.code == 10500) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 装置中未找到该ICD
|
2025-05-22 18:43:33 +08:00
|
|
|
|
ElMessageBox.alert(`装置中未找到该icd!`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
}
|
2025-04-14 13:22:46 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ★★★ 处理系数校准核心业务消息 ★★★
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'Coefficient_Check':
|
|
|
|
|
|
console.log("Coefficient_Checkactive", active.value);
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// ==================== 第1阶段:大电压/电流系数下装 ====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'big_start':
|
|
|
|
|
|
// 大电压/电流系数下装开始,显示源输出参数
|
2025-04-14 13:22:46 +08:00
|
|
|
|
big_V_Download.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
|
|
|
|
|
|
big_I_Download.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
|
2025-04-14 19:51:06 +08:00
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'big_end':
|
|
|
|
|
|
// 大电压/电流系数下装完成,进入下一阶段
|
|
|
|
|
|
active.value++; // 步骤进度+1
|
|
|
|
|
|
tableLoading('small', '系数下装') // 开始小电压/电流下装的加载动画
|
2025-04-14 13:22:46 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// ==================== 第2阶段:小电压/电流系数下装 ====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'small_start':
|
|
|
|
|
|
// 小电压/电流系数下装开始,显示源输出参数
|
2025-04-14 13:22:46 +08:00
|
|
|
|
small_V_Download.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
|
|
|
|
|
|
small_I_Download.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
|
2025-04-14 19:51:06 +08:00
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'small_end':
|
|
|
|
|
|
// 小电压/电流系数下装完成,进入校准阶段
|
|
|
|
|
|
active.value++; // 步骤进度+1
|
|
|
|
|
|
tableLoading('big', '系数校准') // 开始大电压/电流校准的加载动画
|
2025-04-14 13:22:46 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// ==================== 第3阶段:大电压/电流系数校准 ====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'big_comp_start':
|
|
|
|
|
|
// 大电压/电流系数校准开始,显示源输出参数
|
2025-04-14 13:22:46 +08:00
|
|
|
|
big_V_Adjust.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
|
|
|
|
|
|
big_I_Adjust.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
|
2025-04-14 19:51:06 +08:00
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'big_comp_end':
|
|
|
|
|
|
// 大电压/电流系数校准完成,进入最后阶段
|
|
|
|
|
|
active.value++; // 步骤进度+1
|
|
|
|
|
|
tableLoading('small', '系数校准') // 开始小电压/电流校准的加载动画
|
2025-04-14 13:22:46 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// ==================== 第4阶段:小电压/电流系数校准(最终阶段)====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'small_comp_start':
|
|
|
|
|
|
// 小电压/电流系数校准开始,显示源输出参数
|
2025-04-14 13:22:46 +08:00
|
|
|
|
small_V_Adjust.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
|
|
|
|
|
|
small_I_Adjust.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
|
2025-04-14 19:51:06 +08:00
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'small_comp_end':
|
|
|
|
|
|
// ★★★ 小电压/电流系数校准完成 - 整个系数校准流程结束 ★★★
|
|
|
|
|
|
active.value++; // 步骤进度+1
|
|
|
|
|
|
active.value++; // 再+1,跳转到完成状态
|
2025-04-14 13:22:46 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 统计所有设备的校准结果
|
2025-04-14 13:22:46 +08:00
|
|
|
|
for (let i = 0; i < name.value.length; i++) {
|
|
|
|
|
|
const currentDataRef = tableDataMap.get(i);
|
|
|
|
|
|
if (currentDataRef) {
|
|
|
|
|
|
const currentData = currentDataRef.value;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 检查当前设备的校准数据是否合格
|
2025-04-14 13:22:46 +08:00
|
|
|
|
const hasError = checkForErrors(currentData);
|
2025-08-11 11:14:20 +08:00
|
|
|
|
if (!hasError) {
|
|
|
|
|
|
qualified.value++; // 合格设备计数+1
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-08-11 11:14:20 +08:00
|
|
|
|
updateErrorState(i, hasError); // 更新设备错误状态显示
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
isButtonDisabled.value = false; // 恢复按钮可用状态
|
|
|
|
|
|
|
|
|
|
|
|
// ★★★ 通知父组件系数校准成功完成,触发自动步骤切换 ★★★
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'success')
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 表格数据实时更新 ====================
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
case 'DATA_CHNFACTOR$02':
|
|
|
|
|
|
// 接收并更新表格中的系数校准数据
|
2025-04-14 13:22:46 +08:00
|
|
|
|
console.log('表格', name.value)
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 遍历所有设备,找到匹配的表格项并更新数据
|
2025-04-14 13:22:46 +08:00
|
|
|
|
for (let i = 0; i < name.value.length; i++) {
|
|
|
|
|
|
const targetArrayRef = tableDataMap.get(i);
|
|
|
|
|
|
if (targetArrayRef) {
|
|
|
|
|
|
const targetArray = targetArrayRef.value;
|
|
|
|
|
|
if (targetArray.length > 0) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 根据监测点号、类型、描述和设备名称找到对应的表格行
|
|
|
|
|
|
const firstCoefficientVO = targetArray.find(item =>
|
|
|
|
|
|
item.monitorNum === newValue.data.monitorNum &&
|
|
|
|
|
|
item.type === newValue.data.type &&
|
|
|
|
|
|
item.desc === newValue.data.desc &&
|
|
|
|
|
|
item.devName === newValue.data.devName);
|
|
|
|
|
|
|
|
|
|
|
|
if (firstCoefficientVO) {
|
|
|
|
|
|
// 更新A相电压数据和误差
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.aVuData = parseFloat(newValue.data.aVuData).toFixed(4);
|
|
|
|
|
|
if (!isNaN(parseFloat(newValue.data.aVuXi)) && isFinite(newValue.data.aVuXi)) {
|
|
|
|
|
|
firstCoefficientVO.aVuXi = (parseFloat(newValue.data.aVuXi) / 10000).toFixed(4);
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.aVuXi = newValue.data.aVuXi; // 可能是"不合格"等文本
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 更新B相电压数据和误差
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.bVuData = parseFloat(newValue.data.bVuData).toFixed(4);
|
|
|
|
|
|
if (!isNaN(parseFloat(newValue.data.bVuXi)) && isFinite(newValue.data.bVuXi)) {
|
|
|
|
|
|
firstCoefficientVO.bVuXi = (parseFloat(newValue.data.bVuXi) / 10000).toFixed(4);
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.bVuXi = newValue.data.bVuXi; // 可能是"不合格"等文本
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 更新C相电压数据和误差
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.cVuData = parseFloat(newValue.data.cVuData).toFixed(4);
|
|
|
|
|
|
if (!isNaN(parseFloat(newValue.data.cVuXi)) && isFinite(newValue.data.cVuXi)) {
|
|
|
|
|
|
firstCoefficientVO.cVuXi = (parseFloat(newValue.data.cVuXi) / 10000).toFixed(4);
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.cVuXi = newValue.data.cVuXi; // 可能是"不合格"等文本
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 更新A相电流数据和误差
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.aIeData = parseFloat(newValue.data.aIeData).toFixed(4);
|
|
|
|
|
|
if (!isNaN(parseFloat(newValue.data.aIeXi)) && isFinite(newValue.data.aIeXi)) {
|
|
|
|
|
|
firstCoefficientVO.aIeXi = (parseFloat(newValue.data.aIeXi) / 10000).toFixed(4);
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.aIeXi = newValue.data.aIeXi; // 可能是"不合格"等文本
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 更新B相电流数据和误差
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.bIeData = parseFloat(newValue.data.bIeData).toFixed(4);
|
|
|
|
|
|
if (!isNaN(parseFloat(newValue.data.bIeXi)) && isFinite(newValue.data.bIeXi)) {
|
|
|
|
|
|
firstCoefficientVO.bIeXi = (parseFloat(newValue.data.bIeXi) / 10000).toFixed(4);
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.bIeXi = newValue.data.bIeXi; // 可能是"不合格"等文本
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 更新C相电流数据和误差
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.cIeData = parseFloat(newValue.data.cIeData).toFixed(4);
|
|
|
|
|
|
if (!isNaN(parseFloat(newValue.data.cIeXi)) && isFinite(newValue.data.cIeXi)) {
|
|
|
|
|
|
firstCoefficientVO.cIeXi = (parseFloat(newValue.data.cIeXi) / 10000).toFixed(4);
|
|
|
|
|
|
} else {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.cIeXi = newValue.data.cIeXi; // 可能是"不合格"等文本
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 更新三相电压和电流的原始值
|
2025-04-14 13:22:46 +08:00
|
|
|
|
firstCoefficientVO.aV = newValue.data.aV;
|
|
|
|
|
|
firstCoefficientVO.bV = newValue.data.bV;
|
|
|
|
|
|
firstCoefficientVO.cV = newValue.data.cV;
|
|
|
|
|
|
firstCoefficientVO.aI = newValue.data.aI;
|
|
|
|
|
|
firstCoefficientVO.bI = newValue.data.bI;
|
|
|
|
|
|
firstCoefficientVO.cI = newValue.data.cI;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
2025-04-14 13:22:46 +08:00
|
|
|
|
console.log(newValue.data.devName + '对象:', firstCoefficientVO);
|
2025-08-11 11:14:20 +08:00
|
|
|
|
activeIndex.value++; // 更新活跃索引
|
2025-02-25 10:17:33 +08:00
|
|
|
|
} else {
|
2025-04-14 13:22:46 +08:00
|
|
|
|
console.log('未找到匹配的' + newValue.data.devName + '对象');
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2025-04-14 13:22:46 +08:00
|
|
|
|
console.log(newValue.data.devName + '数组为空');
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2025-04-14 13:22:46 +08:00
|
|
|
|
console.log('未找到' + newValue.data.devName + '对应的数组');
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-14 13:22:46 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 处理Socket连接超时
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'socket_timeout':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'VOLTAGE':
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 电压连接超时
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('连接超时!', '连接超时', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 处理连接失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'connect':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case "Source":
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 源服务端连接失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('源服务端连接失败', '源服务端连接失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "Dev":
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 设备服务端连接失败
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('设备服务端连接失败', '设备服务端连接失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
TableInit();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 错误处理函数 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 系数校准出错时的初始化处理
|
|
|
|
|
|
* 通知父组件检测失败,重置相关状态
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const TableInit = () => {
|
2025-02-26 19:20:02 +08:00
|
|
|
|
console.log("出错系数检测",active.value);
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 通知父组件系数校准失败
|
|
|
|
|
|
emit('update:testStatus', 'error')
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 界面动画控制 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 控制表格中特定类型和描述的行显示加载动画
|
|
|
|
|
|
* @param type 类型:'big' | 'small'
|
|
|
|
|
|
* @param desc 描述:'系数下装' | '系数校准'
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const tableLoading = (type: string, desc: string) => {
|
2025-02-26 19:20:02 +08:00
|
|
|
|
console.log('转动',channel.value)
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 遍历所有设备
|
2025-02-25 10:17:33 +08:00
|
|
|
|
for (let i = 0; i < channel.value.length; i++) {
|
|
|
|
|
|
const targetArrayRef = tableDataMap.get(i);
|
|
|
|
|
|
if (targetArrayRef) {
|
|
|
|
|
|
const targetArray = targetArrayRef.value;
|
|
|
|
|
|
if (targetArray.length > 0) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 遍历当前设备的所有通道
|
2025-02-25 10:17:33 +08:00
|
|
|
|
for (let j = 0; j < channel.value[i]; j++) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 找到对应类型和描述的表格行
|
|
|
|
|
|
const firstCoefficientVO = targetArray.find(item =>
|
|
|
|
|
|
item.monitorNum === (j + 1).toString() &&
|
|
|
|
|
|
item.type === type &&
|
|
|
|
|
|
item.desc === desc);
|
2025-02-25 10:17:33 +08:00
|
|
|
|
if (firstCoefficientVO) {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
firstCoefficientVO.loading = true; // 开启加载动画
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-11 11:14:20 +08:00
|
|
|
|
} else {
|
2025-02-26 19:20:02 +08:00
|
|
|
|
console.log('不转了')
|
2025-02-25 10:17:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 表格数据模板 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 系数校准表格的数据模板
|
|
|
|
|
|
* 每个设备的每个通道都会根据这4个模板生成对应的表格行
|
|
|
|
|
|
*
|
|
|
|
|
|
* 模板说明:
|
|
|
|
|
|
* 1. 监测点1 - 大幅值系数下装
|
|
|
|
|
|
* 2. 监测点2 - 小幅值系数下装
|
|
|
|
|
|
* 3. 监测点3 - 大幅值系数校准
|
|
|
|
|
|
* 4. 监测点4 - 小幅值系数校准
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const dataTemplates: ChannelsTest.CoefficientVO[] = [
|
|
|
|
|
|
{
|
2025-08-11 11:14:20 +08:00
|
|
|
|
monitorNum: '1', // 监测点编号
|
|
|
|
|
|
desc: '系数下装', // 操作描述
|
|
|
|
|
|
type: 'big', // 幅值类型:大幅值
|
|
|
|
|
|
aVuData: '—', // A相电压测量值
|
|
|
|
|
|
aVuXi: '—', // A相电压误差
|
|
|
|
|
|
bVuData: '—', // B相电压测量值
|
|
|
|
|
|
bVuXi: '—', // B相电压误差
|
|
|
|
|
|
cVuData: '—', // C相电压测量值
|
|
|
|
|
|
cVuXi: '—', // C相电压误差
|
|
|
|
|
|
aIeData: '—', // A相电流测量值
|
|
|
|
|
|
aIeXi: '—', // A相电流误差
|
|
|
|
|
|
bIeData: '—', // B相电流测量值
|
|
|
|
|
|
bIeXi: '—', // B相电流误差
|
|
|
|
|
|
cIeData: '—', // C相电流测量值
|
|
|
|
|
|
cIeXi: '—', // C相电流误差
|
|
|
|
|
|
loading: false, // 加载状态
|
|
|
|
|
|
devName: '', // 设备名称(动态填充)
|
|
|
|
|
|
aV: '—', // A相电压原始值
|
|
|
|
|
|
bV: '—', // B相电压原始值
|
|
|
|
|
|
cV: '—', // C相电压原始值
|
|
|
|
|
|
aI: '—', // A相电流原始值
|
|
|
|
|
|
bI: '—', // B相电流原始值
|
|
|
|
|
|
cI: '—', // C相电流原始值
|
2025-02-25 10:17:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-08-11 11:14:20 +08:00
|
|
|
|
monitorNum: '2', // 监测点编号
|
|
|
|
|
|
desc: '系数下装', // 操作描述
|
|
|
|
|
|
type: 'small', // 幅值类型:小幅值
|
2025-02-25 10:17:33 +08:00
|
|
|
|
aVuData: '—',
|
|
|
|
|
|
aVuXi: '—',
|
|
|
|
|
|
bVuData: '—',
|
|
|
|
|
|
bVuXi: '—',
|
|
|
|
|
|
cVuData: '—',
|
|
|
|
|
|
cVuXi: '—',
|
|
|
|
|
|
aIeData: '—',
|
|
|
|
|
|
aIeXi: '—',
|
|
|
|
|
|
bIeData: '—',
|
|
|
|
|
|
bIeXi: '—',
|
|
|
|
|
|
cIeData: '—',
|
|
|
|
|
|
cIeXi: '—',
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
devName: '',
|
|
|
|
|
|
aV: '—',
|
|
|
|
|
|
bV: '—',
|
|
|
|
|
|
cV: '—',
|
|
|
|
|
|
aI: '—',
|
|
|
|
|
|
bI: '—',
|
|
|
|
|
|
cI: '—',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-08-11 11:14:20 +08:00
|
|
|
|
monitorNum: '3', // 监测点编号
|
|
|
|
|
|
desc: '系数校准', // 操作描述
|
|
|
|
|
|
type: 'big', // 幅值类型:大幅值
|
2025-02-25 10:17:33 +08:00
|
|
|
|
aVuData: '—',
|
|
|
|
|
|
aVuXi: '—',
|
|
|
|
|
|
bVuData: '—',
|
|
|
|
|
|
bVuXi: '—',
|
|
|
|
|
|
cVuData: '—',
|
|
|
|
|
|
cVuXi: '—',
|
|
|
|
|
|
aIeData: '—',
|
|
|
|
|
|
aIeXi: '—',
|
|
|
|
|
|
bIeData: '—',
|
|
|
|
|
|
bIeXi: '—',
|
|
|
|
|
|
cIeData: '—',
|
|
|
|
|
|
cIeXi: '—',
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
devName: '',
|
|
|
|
|
|
aV: '—',
|
|
|
|
|
|
bV: '—',
|
|
|
|
|
|
cV: '—',
|
|
|
|
|
|
aI: '—',
|
|
|
|
|
|
bI: '—',
|
|
|
|
|
|
cI: '—',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-08-11 11:14:20 +08:00
|
|
|
|
monitorNum: '4', // 监测点编号
|
|
|
|
|
|
desc: '系数校准', // 操作描述
|
|
|
|
|
|
type: 'small', // 幅值类型:小幅值
|
2025-02-25 10:17:33 +08:00
|
|
|
|
aVuData: '—',
|
|
|
|
|
|
aVuXi: '—',
|
|
|
|
|
|
bVuData: '—',
|
|
|
|
|
|
bVuXi: '—',
|
|
|
|
|
|
cVuData: '—',
|
|
|
|
|
|
cVuXi: '—',
|
|
|
|
|
|
aIeData: '—',
|
|
|
|
|
|
aIeXi: '—',
|
|
|
|
|
|
bIeData: '—',
|
|
|
|
|
|
bIeXi: '—',
|
|
|
|
|
|
cIeData: '—',
|
|
|
|
|
|
cIeXi: '—',
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
devName: '',
|
|
|
|
|
|
aV: '—',
|
|
|
|
|
|
bV: '—',
|
|
|
|
|
|
cV: '—',
|
|
|
|
|
|
aI: '—',
|
|
|
|
|
|
bI: '—',
|
|
|
|
|
|
cI: '—',
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 工具函数 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 更新设备错误状态显示
|
|
|
|
|
|
* @param index 设备索引
|
|
|
|
|
|
* @param hasError 是否有错误
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const updateErrorState = (index: number, hasError: boolean) => {
|
|
|
|
|
|
errorStates.value[index] = hasError;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取指定设备的表格数据
|
|
|
|
|
|
* @param index 设备索引
|
|
|
|
|
|
* @returns 返回对应设备的表格数据数组
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const getTableDataForChannel = (index: number): any[] => {
|
|
|
|
|
|
const data = tableDataMap.get(index);
|
|
|
|
|
|
return data ? data.value : [];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 父子组件通信 ====================
|
|
|
|
|
|
const emit = defineEmits(['update:testStatus']);
|
2025-02-25 10:17:33 +08:00
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// ==================== 界面状态监听 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 监听活跃索引变化,更新界面描述信息
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
watch(activeIndex, function (newValue, oldValue) {
|
|
|
|
|
|
if (activeIndex.value === 1) {
|
|
|
|
|
|
outputDsc.value = "电压误差为:±0.1Un%; 电流误差为:±0.5%";
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// ==================== 业务逻辑函数 ====================
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 检查设备校准数据是否存在错误
|
|
|
|
|
|
* @param data 设备的校准数据数组
|
|
|
|
|
|
* @returns 返回是否存在不合格项
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const checkForErrors = (data: ChannelsTest.CoefficientVO[]): boolean => {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 检查各相电压和电流的误差值是否为"不合格"
|
2025-02-25 10:17:33 +08:00
|
|
|
|
return data.some(item =>
|
|
|
|
|
|
item.aVuXi === '不合格' ||
|
|
|
|
|
|
item.bVuXi === '不合格' ||
|
|
|
|
|
|
item.cVuXi === '不合格' ||
|
|
|
|
|
|
item.aIeXi === '不合格' ||
|
|
|
|
|
|
item.bIeXi === '不合格' ||
|
|
|
|
|
|
item.cIeXi === '不合格'
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理系数校准开始事件
|
|
|
|
|
|
* 由父组件通过状态监听触发
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const handleSubmit = async () => {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
isButtonDisabled.value = true; // 禁用按钮,防止重复提交
|
|
|
|
|
|
tableLoading('big', '系数下装') // 开启大幅值系数下装的加载动画
|
|
|
|
|
|
active.value++; // 步骤进度+1,进入第一个校准阶段
|
2025-02-26 19:05:56 +08:00
|
|
|
|
console.log('开始检测active.value', active.value)
|
2025-02-25 10:17:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-11 11:14:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 为指定设备初始化表格数据
|
|
|
|
|
|
* @param templates 数据模板数组
|
|
|
|
|
|
* @param index 设备索引
|
|
|
|
|
|
* @returns 返回初始化后的表格数据引用
|
|
|
|
|
|
*/
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const initializeTableData = (templates: ChannelsTest.CoefficientVO[], index: number): Ref<ChannelsTest.CoefficientVO[]> => {
|
|
|
|
|
|
const currentTableData = ref<ChannelsTest.CoefficientVO[]>([]);
|
2025-08-11 11:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 为当前设备的每个通道生成表格数据
|
2025-02-25 10:17:33 +08:00
|
|
|
|
for (let j = 0; j < channel.value[index]; j++) {
|
|
|
|
|
|
templates.forEach((template) => {
|
2025-08-11 11:14:20 +08:00
|
|
|
|
// 使用解构赋值复制模板,排除不需要的属性
|
2025-02-25 10:17:33 +08:00
|
|
|
|
const {devName, monitorNum: __, ...rest} = template;
|
|
|
|
|
|
currentTableData.value.push({
|
2025-08-11 11:14:20 +08:00
|
|
|
|
monitorNum: (j + 1).toString(), // 监测点号从1开始
|
|
|
|
|
|
devName: name.value[index], // 设置设备名称
|
|
|
|
|
|
...rest, // 其他模板属性
|
2025-02-25 10:17:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
return currentTableData;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
/* 确保 el-icon-loading 的动画效果没有被覆盖 */
|
|
|
|
|
|
.loading-box {
|
|
|
|
|
|
animation: rotate 2s linear infinite;
|
|
|
|
|
|
font-size: 30px; /* 增大图标的大小 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes rotate {
|
|
|
|
|
|
from {
|
|
|
|
|
|
transform: rotate(0deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
to {
|
|
|
|
|
|
transform: rotate(360deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.right-title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
|
/* 横向排列 */
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.custom-tabs-label .el-icon {
|
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.custom-tabs-label span {
|
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dialog-content {
|
|
|
|
|
|
height: 510px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-tabs--border-card {
|
|
|
|
|
|
height: 470px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* .el-icon svg {
|
|
|
|
|
|
color: #ff7171;
|
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
.icon-style {
|
|
|
|
|
|
color: #ff7171;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dialog-left {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.right-content {
|
|
|
|
|
|
flex: 6;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.spanStyle {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|