This commit is contained in:
sjl
2025-08-07 14:44:04 +08:00
11 changed files with 477 additions and 4321 deletions

View File

@@ -1,999 +0,0 @@
<template>
<el-dialog v-model='dialogVisible' title="系数校准" v-bind="dialogBig" width="1550px" @close="handleCancel" :before-close="beforeClose">
<div class="test-dialog">
<div class="dialog-content">
<div class="right-title">
<!-- <div>系数校准表</div> -->
<div>{{ outputDsc }}</div>
<div>
<span style=" font-size: 18px;font-weight: 600;">
设备已合格 <span style="color: #91cc75">{{ 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>
</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 #footer>
<div class="dialog-footer">
<el-button type="primary" @click="handleSubmit" :disabled="isButtonDisabled">开始系数校准</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="tsx" setup name="channelsTest">
import {type Device} from '@/api/device/interface/device';
import {Failed} from '@element-plus/icons-vue'
import {type Ref, ref, toRef, watch} from 'vue'
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 {useUserStore} from "@/stores/modules/user";
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)
let timer1: NodeJS.Timeout | null = null; // 声明并初始化 timer1
let timer2: NodeJS.Timeout | null = null; // 同样声明并初始化 timer2
const name = ref<string[]>([])//系数校准所选设备名字数组
const channel = ref<number[]>([])//系数校准所选设备通道数组
const devIdArray = ref<string[]>([])//系数校准所选设备ID数组
const select_Plan = ref<Plan.ReqPlan>()
const planId = ref('')
const isButtonDisabled = ref(false);
const CurV = ref<number>()//额定电压
// 在 setup 函数中
const errorStates = ref(new Array(name.value.length).fill(false));
//const loadingStates = ref(new Array(name.value.length).fill(false)); // 初始化 loading 状态
const big_V_loadingStates = ref(false); // 初始化 大电压大电流下装loading 状态
const small_V_loadingStates = ref(false); // 初始化 小电压小电流下装loading 状态
const big_V_loadingStates2 = ref(false); // 初始化 大电压大电流校准loading 状态
const small_V_loadingStates2 = ref(false); // 初始化 小电压小电流校准loading 状态
const editableTabsValue = ref('0')
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('')
const props = defineProps({
webMsgSend: {
type: Object,
default: () => ({})
}
})
const userStore = useUserStore()
const tableDataMap = new Map<number, Ref<ChannelsTest.CoefficientVO[]>>([]);
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
const webMsgSend = toRef(props, 'webMsgSend');
watch(webMsgSend, function (newValue, oldValue) {
if (newValue.code == 10520) {
ElMessageBox.alert('报文解析异常!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10521) {
ElMessageBox.alert('程控源參数有误!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10522) {
ElMessageBox.alert('测试项解析有误!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10523) {
ElMessageBox.alert('源连接失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10524) {
ElMessageBox.alert('获取源控制权失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10525) {
ElMessageBox.alert('重置源失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10527) {
ElMessageBox.alert('源未进行初始化!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10528) {
ElMessageBox.alert('目标源有误(该用户已控制其他源,在关闭前无法操作新的源)', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10529) {
ElMessageBox.alert('源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10550) {
ElMessageBox.alert(`${newValue.data}设备连接异常!`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10551) {
ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10552) { //todo 10552之后还会发送消息吗
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else {
switch (newValue.requestId) {
case 'yjc_ytxjy':
switch (newValue.operateCode) {
case'INIT_GATHER':
if (newValue.code == -1) {
ElMessageBox.alert('源未知异常', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10523) {
ElMessageBox.alert('源连接失败', '源连接失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
}
break;
case 'YJC_xujy':
switch (newValue.operateCode) {
case 'OPER_GATHER':
if (newValue.code == 10552) {
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10520) {
ElMessageBox.alert('解析报文异常,执行自动关闭,请重新发起检测', '解析报文异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
case 'DATA_REQUEST$02':
if (newValue.code == 25003) {
ElMessageBox.alert('相序校验未通过,执行自动关闭,请重新发起检测', '相序校验未通过', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
}
break;
case 'yjc_sbtxjy':
switch (newValue.operateCode) {
case 'INIT_GATHER$01':
if (newValue.code == 10550) {
ElMessageBox.alert('设备连接异常', '设备连接异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10551) {
ElMessageBox.alert('设备触发报告异常', '设备触发报告异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10552) {
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
} else if (newValue.code == 10520) {
ElMessageBox.alert('解析报文异常,执行自动关闭,请重新发起检测', '解析报文异常', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
}
break;
case 'yjc_xyjy':
switch (newValue.operateCode) {
case 'VERIFY_MAPPING$01':
if (newValue.code == 10200) {
let data = JSON.parse(newValue.data)
ElMessageBox.alert(`脚本与icd检验失败! icd名称${data['icdType']} -> 校验项:${data['dataType']}`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
if (newValue.code == 10500) {
ElMessageBox.alert(`装置中未找到该icd`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
}
break;
}
break;
case 'Coefficient_Check':
console.log("Coefficient_Checkactive", active.value);
switch (newValue.operateCode) {
case 'big_start'://大电压,电流下装
big_V_Download.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
big_I_Download.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
break;
case 'big_end'://大电压,电流下装
active.value++;
tableLoading('small', '系数下装')
break;
}
switch (newValue.operateCode) {
case 'small_start'://小电压,电流下装
small_V_Download.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
small_I_Download.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
break;
case 'small_end'://小电压,电流下装
active.value++;
tableLoading('big', '系数校准')
break;
}
switch (newValue.operateCode) {
case 'big_comp_start'://大电压,电流校准
big_V_Adjust.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
big_I_Adjust.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
break;
case 'big_comp_end'://大电压,电流校准
active.value++;
tableLoading('small', '系数校准')
break;
}
switch (newValue.operateCode) {
case 'small_comp_start'://小电压,电流校准
small_V_Adjust.value = 'Ua=Ub=Uc=' + newValue.data.devVolt + 'V';
small_I_Adjust.value = 'Ia=Ib=Ic=' + newValue.data.devCurr + 'A';
break;
case 'small_comp_end'://小电压,电流校准
active.value++;
active.value++;
for (let i = 0; i < name.value.length; i++) {
const currentDataRef = tableDataMap.get(i);
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
} else {
qualified.value++;
}
updateErrorState(i, hasError);
}
}
//editableTabsValue.value = (tabNumber.value).toString();//显示下一个tab
isButtonDisabled.value = false; // 恢复按钮
break;
}
switch (newValue.operateCode) {
case 'DATA_CHNFACTOR$02'://表格
// 输出 key 为 0 的数组中的第一条 ChannelsTest.CoefficientVO 对象
for (let i = 0; i < name.value.length; i++) {
const targetArrayRef = tableDataMap.get(i);
if (targetArrayRef) {
const targetArray = targetArrayRef.value;
if (targetArray.length > 0) {
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) { // 检查 firstCoefficientVO 是否存在
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 {
firstCoefficientVO.aVuXi = newValue.data.aVuXi;
}
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 {
firstCoefficientVO.bVuXi = newValue.data.bVuXi;
}
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 {
firstCoefficientVO.cVuXi = newValue.data.cVuXi;
}
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 {
firstCoefficientVO.aIeXi = newValue.data.aIeXi;
}
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 {
firstCoefficientVO.bIeXi = newValue.data.bIeXi;
}
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 {
firstCoefficientVO.cIeXi = newValue.data.cIeXi;
}
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;
//console.log(newValue.data.devName + '对象:', firstCoefficientVO);
activeIndex.value++;
} else {
//console.log('未找到匹配的'+ newValue.data.devName+'对象');
}
} else {
//console.log(newValue.data.devName + '数组为空');
}
} else {
//console.log('未找到'+newValue.data.devName+'对应的数组');
}
}
break;
}
break;
case 'socket_timeout':
switch (newValue.operateCode) {
case 'VOLTAGE':
ElMessageBox.alert('连接超时!', '连接超时', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
break;
}
break;
case 'connect':
switch (newValue.operateCode) {
case "Source":
ElMessageBox.alert('源服务端连接失败', '源服务端连接失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
break;
case "Dev":
ElMessageBox.alert('设备服务端连接失败', '设备服务端连接失败', {
confirmButtonText: '确定',
type: 'error',
})
TableInit();
break;
}
break;
}
}
})
//出错系数检测初始化
const TableInit = () => {
console.log("TableInitactive", active.value);
isButtonDisabled.value = false; // 恢复按钮
for (let i = 0; i < channel.value.length; i++) {
const currentTableData = initializeTableData(dataTemplates, i);
tableDataMap.set(i, currentTableData)
// const targetArrayRef = tableDataMap.get(i);
// if (targetArrayRef) {
// const targetArray = targetArrayRef.value;
// if (targetArray.length > 0) {
// targetArray.forEach(item => item.loading =false)
// }
// }
}
activeIndex.value = 0
qualified.value = 0
active.value = 0
}
//按行图标转动
const tableLoading = (type: string, desc: string) => {
for (let i = 0; i < channel.value.length; i++) {
const targetArrayRef = tableDataMap.get(i);
if (targetArrayRef) {
const targetArray = targetArrayRef.value;
if (targetArray.length > 0) {
for (let j = 0; j < channel.value[i]; j++) {
const firstCoefficientVO = targetArray.find(item => item.monitorNum === (j + 1).toString() &&
item.type === type &&
item.desc === desc);
if (firstCoefficientVO) {
firstCoefficientVO.loading = true;
}
}
}
}
}
}
const dataTemplates: ChannelsTest.CoefficientVO[] = [
{
monitorNum: '1',
desc: '系数下装',
type: 'big',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
{
monitorNum: '2',
desc: '系数下装',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
{
monitorNum: '3',
desc: '系数校准',
type: 'big',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
{
monitorNum: '4',
desc: '系数校准',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: '',
aV: '—',
bV: '—',
cV: '—',
aI: '—',
bI: '—',
cI: '—',
},
];
const dataTemplates2: ChannelsTest.CoefficientVO[] = [
{
monitorNum: '1',
desc: '系数下装',
type: 'big',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
{
monitorNum: '2',
desc: '系数下装',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
{
monitorNum: '3',
desc: '系数校准',
type: 'big',
aVuData: '—',
aVuXi: '不合格',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
{
monitorNum: '4',
desc: '系数校准',
type: 'small',
aVuData: '—',
aVuXi: '—',
bVuData: '—',
bVuXi: '—',
cVuData: '—',
cVuXi: '—',
aIeData: '—',
aIeXi: '—',
bIeData: '—',
bIeXi: '—',
cIeData: '—',
cIeXi: '—',
loading: false,
devName: ''
},
];
// 更新错误状态的方法
const updateErrorState = (index: number, hasError: boolean) => {
errorStates.value[index] = hasError;
};
// 打开弹窗,可能是新增,也可能是编辑
const open = (selection: Device.ResPqDev[], plan: Plan.ReqPlan) => {
CurV.value = selection[0]?.devVolt || 57.74;
isButtonDisabled.value = false; // 恢复按钮
select_Plan.value = plan
planId.value = selection[0]?.planId || '';
devIdArray.value = selection.map(item => item.id);
name.value = selection.map(item => item.name)
channel.value = selection.map(item => item.devChns)
dialogVisible.value = true;
total.value = name.value.length
// 初始化 loadingStates 为 false
// loadingStates.value = new Array(selection.length).fill(false);
errorStates.value = new Array(selection.length).fill(false);
for (let i = 0; i < channel.value.length; i++) {
const currentTableData = initializeTableData(dataTemplates, i);
tableDataMap.set(i, currentTableData)
}
//console.log('tableDataMap',tableDataMap);
}
const emit = defineEmits<{
(e: 'quitClicked'): void;
(e: 'submitClicked', callback: (resolve: (value: boolean) => void) => void): void;
}>();
const beforeClose = (done: () => void) => {
ElMessageBox.confirm('是否退出系数校准?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
handleCancel()
})
}
const handleCancel = () => {
//dataSocket.socketServe.closeWs()
// 清空 name, channel, total
name.value = [];
channel.value = [];
total.value = 0;
activeIndex.value = 0
qualified.value = 0
active.value = 0
dialogVisible.value = false
editableTabsValue.value = '0'
emit('quitClicked'); // 触发事件
}
const getTableDataForChannel = (index: number): any[] => {
const data = tableDataMap.get(index);
return data ? data.value : [];
}
watch(activeIndex, function (newValue, oldValue) {
if (activeIndex.value === 1) {
outputDsc.value = "电压误差为±0.1Un% 电流误差为±0.5%";
// 当前源输出为Ua=Ub=Uc=57.74V Ia=Ib=Ic=1A"
}
})
// 示例的 checkForErrors 函数,根据实际需求进行调整
const checkForErrors = (data: ChannelsTest.CoefficientVO[]): boolean => {
// 这里假设不合格字段的标准是 status 为 '不合格' 或 isValid 为 false
return data.some(item =>
item.aVuXi === '不合格' ||
item.bVuXi === '不合格' ||
item.cVuXi === '不合格' ||
item.aIeXi === '不合格' ||
item.bIeXi === '不合格' ||
item.cIeXi === '不合格'
);
};
const handleSubmit = async () => {
// 创建一个 Promise 来等待父组件的回调
const response = await new Promise<boolean>((resolve) => {
emit('submitClicked', resolve);
});
if (!response) {
return;
}
isButtonDisabled.value = true; // 禁用按钮
tableLoading('big', '系数下装')
await getCoefficientCheck({
userPageId: "cdf",
devIds: devIdArray.value,
planId: planId.value,
errorSysId: select_Plan.value?.errorSysId,
scriptId: select_Plan.value?.scriptId,
operateType: '0', // '0'为预检测、1为正式检测
userId: userStore.userInfo.id
})
active.value++;
// 初始化 loadingStates 为 true
// loadingStates.value = new Array(name.value.length).fill(true);
return;
// 初始化 currentTableData
// let isTimer2Completed = false;
// //"80b4b4f52a4c4064a18319525f8ac13c",
// for (let i = 0; i < channel.value.length; i++) {
// // 重置状态变量
// active.value = 0;
// //activeIndex.value = 0;
// editableTabsValue.value = i.toString();
// // 初始化并填充 currentTableData
// const currentTableData = initializeTableData(dataTemplates2, i);
// tableDataMap.set(i, currentTableData);
// //activeIndex.value++;
// // 清除之前的 timer1
// clearInterval(timer1);
// // 启动 timer1
// timer1 = setInterval(() => {
// active.value++;
// if (active.value > 5) {
// clearInterval(timer1);
// }
// }, 3000);
// // 清除之前的 timer2
// clearInterval(timer2);
// // 启动 timer2
// timer2 = setInterval(() => {
// // 初始化并填充 currentTableData
// const currentTableData = initializeTableData(i > 0 ? dataTemplates2 : dataTemplates2, i);
// 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;
// }
};
// 提取初始化并填充 currentTableData 的函数
const initializeTableData = (templates: ChannelsTest.CoefficientVO[], index: number): Ref<ChannelsTest.CoefficientVO[]> => {
const currentTableData = ref<ChannelsTest.CoefficientVO[]>([]);
for (let j = 0; j < channel.value[index]; j++) {
templates.forEach((template) => {
// 使用解构赋值排除 id 和 MonitorIdx 属性
const {devName, monitorNum: __, ...rest} = template;
currentTableData.value.push({
monitorNum: (j + 1).toString(),
devName: name.value[index],
...rest,
});
});
}
return currentTableData;
};
// 对外映射
defineExpose({open})
</script>
<style scoped>
/* 确保 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>

View File

@@ -1,202 +0,0 @@
<template>
<!-- 基础信息弹出框 -->
<el-dialog :model-value="visible" title="被检监测点匹配" v-bind="dialogSmall" @close="handleCancel" width="500" draggable>
<div>
<el-form :model="formData" ref='formRuleRef' :rules='rules' change-event="selectChange">
<el-form-item label="监测点名称:" :label-width="100">
<el-tree-select v-model="value1" :data="sourcesList" style="width: 240px" />
</el-form-item>
<el-form-item label="监测点名称:" :label-width="100">
<el-tree-select v-model="value2" :data="sourcesList" style="width: 240px" />
</el-form-item>
<el-form-item label="监测点名称:" :label-width="100">
<el-tree-select v-model="value3" :data="sourcesList" style="width: 240px" />
</el-form-item>
<el-form-item label="监测点名称:" :label-width="100">
<el-tree-select v-model="value4" :data="sourcesList" style="width: 240px" />
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleCancel"> </el-button>
<el-button type="primary" @click="handleSubmit"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import{ElMessage, FormInstance,FormItemRule}from'element-plus'
import { defineProps, defineEmits, reactive,watch,ref, Ref } from 'vue';
import { dialogSmall} from '@/utils/elementBind'
import {dictPattern,dictTestState,dictReportState,dictResult,testPlanDataList,sourceDataList,deviceDataList,testSoureDataList,testScriptDataList,testErrSystDataList,planData,testFatherPlanList} from '@/api/plan/planData'
const selectChange = (val: any) => {
console.log(val)
}
const value1 = ref()
const value2 = ref()
const value3 = ref()
const value4 = ref()
const sourcesList = [
{
value: '1',
label: '高精度设备-PQV520-1',
disabled: false,
children: [
{
value: '1-1',
label: '监测点1',
disabled: false,
},
{
value: '1-2',
label: '监测点2',
disabled: false,
},
],
},
{
value: '2',
label: '高精度设备-PQV520-2',
disabled: false,
children: [
{
value: '2-1',
label: '监测点1',
disabled: false,
},
{
value: '2-2',
label: '监测点2',
disabled: false,
},
],
},
{
value: '3',
label: '高精度设备-PQV520-3',
disabled: false,
children: [
{
value: '3-1',
label: '监测点1',
disabled: false,
},
{
value: '3-2',
label: '监测点2',
disabled: false,
},
],
},
{
value: '4',
label: '高精度设备-PQV520-4',
disabled: false,
children: [
{
value: '4-1',
label: '监测点1',
disabled: false,
},
{
value: '4-2',
label: '监测点2',
disabled: false,
},
],
},
]
const props = defineProps<{
visible: boolean;
}>();
const fatherPlanList = [
{ label: '/', value: 'type0' },
{ label: '检测计划1', value: 'type1' },
{ label: '检测计划2', value: 'type2' },
{ label: '检测计划3', value: 'type3' },
{ label: '检测计划4', value: 'type4' },
];
const sourceList = [
{ label: '分钟统计数据最大值', value: 'type0' },
{ label: '分钟统计数据最大值', value: 'type1' },
{ label: '分钟统计数据CP95值', value: 'type2' },
];
const scriptList = [
{ label: '/', value: 'type0' },
{ label: '国网入网检测脚本(单影响量-模拟式)', value: 'type1' },
{ label: '国网入网检测脚本Q/GDW 10650.4 - 2021) 数字式', value: 'type1' },
];
const errorList = [
{ label: 'Q/GDW 1650.2- 2016', value: 'type0' },
{ label: 'Q/GDW 10650.2 - 2021', value: 'type1' },
];
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void;
(e: 'submit', data: any): void;
}>();
// 定义规则
const formRuleRef = ref<FormInstance>()
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
name: [{ required: true, message: '检测计划名称必填!', trigger: 'blur' }],
source_Id: [{ required: true, message: '检测源必选!', trigger: 'blur' }],
dataSource_Id: [{ required: true, message: '数据源必选!', trigger: 'blur' }],
script_Id: [{ required: true, message: '检测脚本必选!', trigger: 'blur' }],
error_Sys_Id: [{ required: true, message: '误差体系必选!', trigger: 'blur' }],
// name: [{ required: true, message: '检测计划名称必填!', trigger: 'blur' }],
// father_Plan_Id: [{ required: true, message: '参照标准名称必填!', trigger: 'change' }],
});
const handleCancel = () => {
//重置表单内容
//取消表单校验状态
formRuleRef.value && formRuleRef.value.resetFields()
emit('update:visible', false); // 关闭对话框
};
const handleSubmit = () => {
try {
formRuleRef.value?.validate((valid: boolean) => {
if (valid)
{
// 将表单数据转为json,发送到后端
let confirmFormData = JSON.parse(JSON.stringify(props.formData));
//console.log(confirmFormData)
emit('submit', props.formData); // 提交表单数据
emit('update:visible', false); // 提交后关闭对话框
}
else
{
ElMessage.error('请填选必填项!')
}
})
} catch (error) {
console.error('验证过程中发生错误', error)
}
};
// 当 props.visible 改变时,更新 formData
watch(() => props.visible, (newVal) => {
if (!newVal) {
// 这里可以重置表单数据,如果需要的话
}
});
</script>
<style scoped>
</style>

View File

@@ -1,154 +0,0 @@
<template>
<el-dialog title="报告生成" :model-value='visible' @close="handleCancel" width="832px" draggable>
<div class="report-dialog">
<div class="report-title form-two">
<el-form-item label="检测脚本" label-width="100px">
<el-input v-model='testScriptName' :disabled="true"/>
</el-form-item>
<el-form-item label="误差体系" label-width="100px">
<el-input v-model='errorSysName' :disabled="true"/>
</el-form-item>
<el-form-item label="数据原则" label-width="100px">
<el-input v-model='dataRule' :disabled="true"/>
</el-form-item>
<el-form-item label="报告模板" label-width="100px">
<el-input v-model='reportTemplate' :disabled="true"/>
</el-form-item>
</div>
<div class="report-content">
<div>
<el-tabs type="border-card">
<el-tab-pane label="报告生成进度">
<div class="form-grid">
<div class="tabs-title ">
<el-button type="primary" :icon="Download" >报告下载</el-button>
<span style=" font-size: 18px;font-weight: 600;">
已生成 <span style="color: #91cc75">2</span> / <span style="color: green">3</span>
</span>
</div>
<div class="table-main">
<el-table :data="reportData" :header-cell-style="{ textAlign: 'center' } " :cell-style="{ textAlign: 'center' }" style="width: 100%" border class="custom-table">
<el-table-column type="selection" width="55" />
<el-table-column prop="id" width="70" label="序号" />
<el-table-column prop="deviceName" width="150" label="设备名称" />
<el-table-column label="生成进度">
<template #default="scope">
<el-progress :color="customColors" :percentage="scope.row.processValue" />
</template>
</el-table-column>
<el-table-column prop="action" label="操作" width="100">
<template #default="scope">
<el-button type='primary' link :icon='Download' :disabled="scope.row.processValue < 100">下载</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</el-dialog>
</template>
<script setup lang='ts'>
import IPAddress from '@/components/IpAddress/index.vue'
import { dialogBig } from '@/utils/elementBind'
import { type Device } from '@/api/device/interface/device'
import { ElMessage, type FormItemRule } from 'element-plus'
import { addPqDev, updatePqDev } from '@/api/device/device'
import { computed, reactive, type Ref, ref } from 'vue'
import { useDictStore } from '@/stores/modules/dict'
import { CirclePlus, Delete, Download,View } from '@element-plus/icons-vue'
const reportTemplate = ref('国网检测模板V1.0');
const testScriptName = ref('Q/GDW 10650.4-2021 模拟式');
const errorSysName = ref('Q/GDW 10650.2-2021');
const dataRule = ref('所有值');
const scriptSwitch = ref(true);
const currentScriptDsc = ref('电压准确度检测频率42.5Hz Ua=46.192V 0° Ub=46.192V -120° Uc=46.192V 120° Ia=1A 0° Ib=1A -120° Ic=1A 120°');
const reportData = ref([
{ id: '1', deviceName: '240001', processValue: '100' , action:'查看' },
{ id: '2', deviceName: '240002', processValue: '100' , action:'查看' },
{ id: '3', deviceName: '240003', processValue: '10', action:'查看' },
])
const customColors = [
{ color: "red", percentage: 0 },
{ color: "red", percentage: 10 },
{ color: "red", percentage: 20 },
{ color: "red", percentage: 30 }, //红
{ color: "red", percentage: 40 },
{ color: "#e6a23c", percentage: 50 },
{ color: "#e6a23c", percentage: 60 },
{ color: "#e6a23c", percentage: 70 }, //黄
{ color: "#e6a23c", percentage: 80 }, //1989fa
{ color: "#e6a23c", percentage: 90 }, //1989fa
{ color: "#5cb87a", percentage: 100 }, //绿
];
const handleNodeClick = (data) => {
console.log(data);
};
const MonIsShow = ref(false)
const DevIsShow = ref(false)
const IsPasswordShow = ref(false)
const dictStore = useDictStore()
// 定义弹出组件元信息
const dialogFormRef = ref()
const disabledDate = (time: Date) => {
return time.getTime() > Date.now()
}
const props = defineProps<{
visible: boolean;
}>();
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void;
(e: 'submit', data: any): void;
}>();
const handleCancel = () => {
emit('update:visible', false); // 关闭对话框
};
</script>
<style scoped>
.report-dialog{
display: flex;
flex-direction: column;
}
.report-title{
margin-left: 15px;
/* display: flex; */
/* flex-direction: row;
margin-top: 10px; */
}
.report-content{
display: flex;
flex-direction: column;
}
.tabs-title{
display: flex;
justify-content: space-between;
margin-bottom: 10px;
}
.el-tabs__content{
padding-top: 5px !important;
}
</style>

View File

@@ -43,7 +43,6 @@
import { useDictStore } from '@/stores/modules/dict'
import preTest from './preTest.vue'
import timeTest from './timeTest.vue'
import channelsTest from './channelsTest.vue'
import DataCheckPopup from './dataCheckPopup.vue';
import { log } from 'console';

File diff suppressed because it is too large Load Diff

View File

@@ -1,39 +1,39 @@
<template>
<el-dialog title="填写实验室环境" v-model='dialogVisible' @close="handleClose" v-bind="dialogSmall" >
<el-dialog title='填写实验室环境' v-model='dialogVisible' @close='handleClose' v-bind='dialogSmall'>
<div>
<el-form ref="dialogFormRef" :model="formContent" :rules='rules' >
<el-form-item label="温度(℃)" prop="temperature" :label-width="110">
<el-input v-model="formContent.temperature" placeholder="请输入温度" maxlength="32" show-word-limit/>
</el-form-item>
<el-form-item label="相对湿度(%)" prop="humidity" :label-width="110">
<el-input v-model="formContent.humidity" placeholder="请输入湿度" maxlength="32" show-word-limit/>
</el-form-item>
<el-form ref='dialogFormRef' :model='formContent' :rules='rules'>
<el-form-item label='温度(℃)' prop='temperature' :label-width='110'>
<el-input v-model='formContent.temperature' placeholder='请输入温度' maxlength='32' show-word-limit />
</el-form-item>
<el-form-item label='相对湿度(%)' prop='humidity' :label-width='110'>
<el-input v-model='formContent.humidity' placeholder='请输入湿度' maxlength='32' show-word-limit />
</el-form-item>
</el-form>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleStart">确定</el-button>
<span class='dialog-footer'>
<el-button @click='handleClose'>取消</el-button>
<el-button type='primary' @click='handleStart'>确定</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang='tsx' name='selectTestItemPopup'>
import {dialogSmall} from "@/utils/elementBind";
import {reactive, Ref, ref} from "vue";
import type {Device} from "@/api/device/interface/device.ts";
import {ElMessageBox, FormItemRule} from "element-plus";
import {useCheckStore} from "@/stores/modules/check";
import { dialogSmall } from '@/utils/elementBind'
import { reactive, Ref, ref } from 'vue'
import type { Device } from '@/api/device/interface/device.ts'
import { ElMessageBox, FormItemRule } from 'element-plus'
import { useCheckStore } from '@/stores/modules/check'
const emit = defineEmits(['openTestDialog2'])
const dialogFormRef = ref()
const dialogVisible = ref(false)
const formContent = reactive<Device.ResTH>({temperature:0,humidity:0})
const checkStore = useCheckStore();
const formContent = reactive<Device.ResTH>({ temperature: 0, humidity: 0 })
const checkStore = useCheckStore()
const open = async () => {
resetFormContent()
dialogVisible.value = true
@@ -41,35 +41,39 @@ const open = async () => {
// 清空表单内容
const resetFormContent = () => {
Object.assign(formContent,{temperature:'22',humidity:'50'})
Object.assign(formContent, { temperature: '22', humidity: '50' })
}
//定义校验规则
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
temperature: [{ required: true, message: '温度必填!', trigger: 'blur' },
// 指定正则,此处是数字正则
{ pattern: /^(?:(?:-50)|-?[1-4][0-9]|-?[0-9]|[1-4][0-9]|50)(\.[0-9]+)?$/,
//定义校验规则
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
temperature: [{ required: true, message: '温度必填!', trigger: 'blur' },
// 指定正则,此处是数字正则
{
pattern: /^(?:(?:-50)|-?[1-4][0-9]|-?[0-9]|[1-4][0-9]|50)(\.[0-9]+)?$/,
message: '温度必须为 -50 到 50 之间的合法数字',
trigger: 'blur'
trigger: 'blur',
}],
humidity: [{ required: true, message: '湿度必填!', trigger: 'blur' },
{ pattern: /^(?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?|0?\.\d+)$/ , message: '湿度必须为 0 到 100 之间的合法数字', trigger: 'blur' },
],
})
humidity: [{ required: true, message: '湿度必填!', trigger: 'blur' },
{
pattern: /^(?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?|0?\.\d+)$/,
message: '湿度必须为 0 到 100 之间的合法数字',
trigger: 'blur',
},
],
})
const handleStart = () => {
try {
dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
checkStore.setTemperature(formContent.temperature)
checkStore.setHumidity(formContent.humidity)
emit('openTestDialog2')
handleClose()
}
try {
dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
checkStore.setTemperature(formContent.temperature)
checkStore.setHumidity(formContent.humidity)
emit('openTestDialog2')
handleClose()
}
})
} catch (err) {
console.error('验证过程中出现错误', err)
@@ -85,11 +89,11 @@ const handleClose = () => {
dialogFormRef.value?.resetFields()
}
defineExpose({open})
defineExpose({ open })
</script>
<style scoped lang="scss">
<style scoped lang='scss'>
</style>

View File

@@ -120,7 +120,7 @@ import pie from '@/components/echarts/pie/default.vue'
import tree from '../components/tree.vue'
import Table from '../components/table.vue'
import { getBoundPqDevList, getPlanListByPattern, getPlanList } from '@/api/plan/plan'
import { onBeforeMount, onUnmounted, ref, watch } from 'vue'
import { onBeforeMount, onUnmounted, ref, watch, nextTick } from 'vue'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useDictStore } from '@/stores/modules/dict'
import { useViewSize } from '@/hooks/useViewSize'
@@ -223,16 +223,25 @@ const tableRef1 = ref() // 主表格组件引用
const currentId = ref('') // 当前选中的计划ID
// ============================ 监听器 ============================
let isUpdatingTabs = false // 防止重复调用的标志
/**
* 监听功能切换并通知表格组件更新配置
* 不再传递静态数据让表格组件通过API获取真实数据
*/
watch(
() => form.value.activeTabs,
(newTabs) => {
async (newTabs) => {
if (isUpdatingTabs) return // 如果正在更新中,跳过
isUpdatingTabs = true
// 只传递功能模式,不传递静态假数据
// 表格组件会根据功能模式通过API获取对应的真实数据
tableRef1.value && tableRef1.value.changeActiveTabs(newTabs)
// 等待一个微任务队列后重置标志
await nextTick()
isUpdatingTabs = false
}
// 去掉 immediate: true避免初始化时重复调用
)
@@ -662,7 +671,7 @@ const handleBatchGenerate = async () => {
// 重新获取饼图数据deviceData更新后watch会自动触发表格更新
getPieData(currentId.value)
// 移除重复的表格渲染调用 - watch监听器已经处理了这部分逻辑
// 批量操作后的表格刷新 - 这个调用与watch监听器无关是通过emit触发的
tableRef1.value && tableRef1.value.changeActiveTabs(form.value.activeTabs)
}
</script>