diff --git a/frontend/src/views/home/components/comparePreTest.vue b/frontend/src/views/home/components/comparePreTest.vue index 3eb071c..43b7408 100644 --- a/frontend/src/views/home/components/comparePreTest.vue +++ b/frontend/src/views/home/components/comparePreTest.vue @@ -348,6 +348,7 @@ watch(webMsgSend, function (newValue, oldValue) { log: '正在进行实时数据对齐检验.....', }]; }else if (newValue.code == 25002) { //单个监测点失败 + step3InitLog.value.push({ type: 'error', log: newValue.data + '实时数据对齐检验失败!', @@ -359,10 +360,12 @@ watch(webMsgSend, function (newValue, oldValue) { activeIndex.value = 3 testDataStructure.value = newValue.data }else if (newValue.code == 25003) { //最终失败 + isShowDialog.value = true step3.value = 'error' ts.value = 'error' step5.value = 'error' + testDataStructure.value = newValue.data } break; } @@ -562,11 +565,13 @@ function initializeParameters() { ] // 清空实时数据对齐验证的数据 + testDataStructure.value = {} isShowDialog.value = false } const openDialog = () => { + realTimeDataRef.value.open(props.mapping,testDataStructure.value) } diff --git a/frontend/src/views/home/components/realTimeDataAlign.vue b/frontend/src/views/home/components/realTimeDataAlign.vue index e5d344b..b01836c 100644 --- a/frontend/src/views/home/components/realTimeDataAlign.vue +++ b/frontend/src/views/home/components/realTimeDataAlign.vue @@ -112,7 +112,7 @@ const tabStatus = ref>({}); const hasIncompleteData = (deviceName: string) => { const tableData = tableDataMap.value[deviceName]; if (!tableData || tableData.length === 0) return false; - + // 检查每一行是否有缺失数据(包含null的字段) return tableData.some(row => { return row.uaDev === '/' || row.ubDev === '/' || row.ucDev === '/' || @@ -122,7 +122,7 @@ const hasIncompleteData = (deviceName: string) => { // 获取映射的被检设备通道 const getMappedDutChannel = (deviceName: string, stdChannel: string) => { - console.log('getMappedDutChannel', deviceName, stdChannel,channelMapping.value); + // 添加安全检查 if (!channelMapping.value[deviceName]) return ''; return channelMapping.value[deviceName][stdChannel] || ''; @@ -152,7 +152,7 @@ const generateTableData = (deviceName: string, stdChannel: string) => { ); if (!channelData) return []; - + // 生成表格数据 return channelData.dataList.map(dataItem => { return { @@ -174,7 +174,7 @@ const updateTableData = (deviceName: string) => { if (selectedChannel) { const tableData = generateTableData(deviceName, selectedChannel); tableDataMap.value[deviceName] = tableData; - console.log('tableDataMap:', tableDataMap.value); + } }; @@ -204,7 +204,7 @@ const initAllTableData = () => { const open = async (mapping : Record>,data : any) => { let parsedData = data; - + // 如果 data 是字符串,先解析为对象 if (typeof data === 'string') { try { @@ -217,8 +217,10 @@ const open = async (mapping : Record>,data : any) } // 转换数据格式以匹配组件期望的格式 const convertedData: Record = {}; + // 假设传入的数据是一个数组,需要转换为以设备名为键的对象 if (Array.isArray(parsedData)) { + parsedData.forEach((deviceItem: any) => { const deviceName = deviceItem.stdDevName; convertedData[deviceName] = { @@ -240,11 +242,13 @@ const open = async (mapping : Record>,data : any) }; }); } else if (parsedData && typeof parsedData === 'object') { + // 如果已经是期望的格式,直接使用 Object.assign(convertedData, parsedData); } + testDataStructure.value = convertedData; - console.log('testDataStructure:', testDataStructure.value); + channelMapping.value = mapping; dialogVisible.value = true; // 使用 nextTick 确保 DOM 更新后再初始化数据