实时数据对齐,修改成标准对应被检
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
</span>
|
||||
</template>
|
||||
<div class="table-toolbar">
|
||||
<el-form-item label="被检设备通道号" prop="createId">
|
||||
<el-form-item label="标准设备通道号" prop="createId">
|
||||
<el-select
|
||||
v-model="selectedChannels[deviceName]"
|
||||
placeholder="选择通道"
|
||||
@@ -25,13 +25,13 @@
|
||||
@change="() => handleDutChannelChange(deviceName)">
|
||||
<el-option
|
||||
v-for="channel in device.channelDataList"
|
||||
:key="channel.devNum"
|
||||
:label="`通道${channel.devNum}`"
|
||||
:value="`通道${channel.devNum}`">
|
||||
:key="channel.stdDevNum"
|
||||
:label="`通道${channel.stdDevNum}`"
|
||||
:value="`通道${channel.stdDevNum}`">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<span style="margin-left: 20px; font-size: 14px; color: var(--el-color-primary);">
|
||||
被检设备:{{ deviceName }}-{{ selectedChannels[deviceName] }} ---> 标准设备:{{ formatStandardChannelLabel(getMappedStandardChannel(deviceName, selectedChannels[deviceName])) }}
|
||||
标准设备:{{ deviceName }}-{{ selectedChannels[deviceName] }} ---> 被检设备:{{ formatDutChannelLabel(getMappedDutChannel(deviceName, selectedChannels[deviceName])) }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-button type="primary" @click="exportData">导出数据</el-button>
|
||||
@@ -44,17 +44,17 @@
|
||||
:style="{ height: '400px',maxHeight: '400px',overflow:'hidden'}">
|
||||
|
||||
<el-table-column :label="`${deviceName}-${selectedChannels[deviceName] || '通道1'}`">
|
||||
<el-table-column prop="timeStdDev" label="数据时标" width="200"/>
|
||||
<el-table-column prop="uaStdDev" label="A相(V)"/>
|
||||
<el-table-column prop="ubStdDev" label="B相(V)"/>
|
||||
<el-table-column prop="ucStdDev" label="C相(V)"/>
|
||||
</el-table-column>
|
||||
<el-table-column :label="formatDutChannelLabel(getMappedDutChannel(deviceName, selectedChannels[deviceName]))">
|
||||
<el-table-column prop="timeDev" label="数据时标" width="200"/>
|
||||
<el-table-column prop="uaDev" label="A相(V)"/>
|
||||
<el-table-column prop="ubDev" label="B相(V)"/>
|
||||
<el-table-column prop="ucDev" label="C相(V)"/>
|
||||
</el-table-column>
|
||||
<el-table-column :label="formatStandardChannelLabel(getMappedStandardChannel(deviceName, selectedChannels[deviceName]))">
|
||||
<el-table-column prop="timeStdDev" label="数据时标" width="200"/>
|
||||
<el-table-column prop="uaStdDev" label="A相(V)"/>
|
||||
<el-table-column prop="uaStdDev" label="B相(V)"/>
|
||||
<el-table-column prop="uaStdDev" label="C相(V)"/>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
<script setup lang='tsx' name='realTimeDataAlign'>
|
||||
import { dialogBig } from "@/utils/elementBind";
|
||||
import { PropType, ref } from "vue";
|
||||
import { PropType, ref, nextTick } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { CircleCheck, CircleClose } from '@element-plus/icons-vue';
|
||||
|
||||
@@ -72,8 +72,8 @@ const activeTab = ref('channel1');
|
||||
|
||||
// 在 script setup 中定义接口
|
||||
interface ChannelData {
|
||||
devNum: string;
|
||||
standardDevInfo: string;
|
||||
stdDevNum: string;
|
||||
devInfo: string;
|
||||
dataList: {
|
||||
timeDev: string | null;
|
||||
uaDev: number | null;
|
||||
@@ -87,185 +87,18 @@ interface ChannelData {
|
||||
}
|
||||
|
||||
interface DeviceData {
|
||||
devName: string;
|
||||
stdDevName: string;
|
||||
channelDataList: ChannelData[];
|
||||
}
|
||||
|
||||
// 修改 testDataStructure 的类型声明
|
||||
const testDataStructure = ref<Record<string, DeviceData>>({});
|
||||
|
||||
// 重构后的 testDataStructure
|
||||
// const testDataStructure = ref({
|
||||
// "被检1": {
|
||||
// devName: "被检设备1",
|
||||
// channelDataList: [
|
||||
// {
|
||||
// devNum: "1",
|
||||
// standardDevInfo: "标准设备1通道1",
|
||||
// dataList: [
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.234",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: null,
|
||||
// uaStdDev: null,
|
||||
// ubStdDev: null,
|
||||
// ucStdDev: null
|
||||
// },
|
||||
// {
|
||||
// timeDev: null,
|
||||
// uaDev: null,
|
||||
// ubDev: null,
|
||||
// ucDev: null,
|
||||
// timeStdDev: "2025-09-02 14:00:02.237",
|
||||
// uaStdDev: 57.74,
|
||||
// ubStdDev: 57.74,
|
||||
// ucStdDev: 57.74
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// devNum: "2",
|
||||
// standardDevInfo: "标准设备2通道4",
|
||||
// dataList: [
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// "被检2": {
|
||||
// devName: "被检设备2",
|
||||
// channelDataList: [
|
||||
// {
|
||||
// devNum: "1",
|
||||
// standardDevInfo: "标准设备1通道1",
|
||||
// dataList: [
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.234",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.234",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.237",
|
||||
// uaStdDev: 57.74,
|
||||
// ubStdDev: 57.74,
|
||||
// ucStdDev: 57.74
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// devNum: "3",
|
||||
// standardDevInfo: "标准设备2通道4",
|
||||
// dataList: [
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// },
|
||||
// {
|
||||
// timeDev: "2025-09-02 14:00:02.231",
|
||||
// uaDev: 57.74,
|
||||
// ubDev: 57.74,
|
||||
// ucDev: 57.74,
|
||||
// timeStdDev: "2025-09-02 14:00:02.231",
|
||||
// uaStdDev: 57.73,
|
||||
// ubStdDev: 57.73,
|
||||
// ucStdDev: 57.74
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// });
|
||||
|
||||
// 每个设备选中的通道
|
||||
const selectedChannels = ref<Record<string, string>>({});
|
||||
|
||||
// 通道映射关系:被检设备通道 -> 标准设备通道
|
||||
const channelMapping = ref<Record<string, Record<string, string>>>({
|
||||
// '被检1': {
|
||||
// '通道1': '标准设备1通道2',
|
||||
// '通道2': '标准设备2通道4',
|
||||
// },
|
||||
// '被检2': {
|
||||
// '通道1': '标准设备1通道3',
|
||||
// '通道3': '标准设备2通道1'
|
||||
// }
|
||||
});
|
||||
// 通道映射关系:标准设备通道 -> 被检设备通道
|
||||
const channelMapping = ref<Record<string, Record<string, string>>>({});
|
||||
|
||||
// 每个设备的表格数据
|
||||
const tableDataMap = ref<Record<string, any[]>>({});
|
||||
@@ -279,40 +112,41 @@ const hasIncompleteData = (deviceName: string) => {
|
||||
if (!tableData || tableData.length === 0) return false;
|
||||
|
||||
// 检查每一行是否有缺失数据(包含null的字段)
|
||||
return tableData.some(row => {
|
||||
return row.Ua1 === '/' || row.Ub1 === '/' || row.Uc1 === '/' ||
|
||||
row.Ua2 === '/' || row.Ub2 === '/' || row.Uc2 === '/';
|
||||
return tableData.some(row => {
|
||||
return row.uaDev === '/' || row.ubDev === '/' || row.ucDev === '/' ||
|
||||
row.uaStdDev === '/' || row.ubStdDev === '/' || row.ucStdDev === '/';
|
||||
});
|
||||
};
|
||||
|
||||
// 获取映射的标准设备通道
|
||||
const getMappedStandardChannel = (deviceName: string, dutChannel: string) => {
|
||||
|
||||
return channelMapping.value[deviceName][dutChannel];
|
||||
// 获取映射的被检设备通道
|
||||
const getMappedDutChannel = (deviceName: string, stdChannel: string) => {
|
||||
console.log('getMappedDutChannel', deviceName, stdChannel,channelMapping.value);
|
||||
// 添加安全检查
|
||||
if (!channelMapping.value[deviceName]) return '';
|
||||
return channelMapping.value[deviceName][stdChannel] || '';
|
||||
};
|
||||
|
||||
// 格式化被检设备通道标签,将设备名称和通道号用"-"连接
|
||||
const formatDutChannelLabel = (dutChannel: string) => {
|
||||
// 如果是"被检设备X通道Y"格式,则转换为"被检设备X-通道Y"
|
||||
if (!dutChannel) return '未映射';
|
||||
return dutChannel.replace(/(被检设备\d+)(通道\d+)/, '$1-$2');
|
||||
};
|
||||
|
||||
// 格式化标准设备通道标签,将设备名称和通道号用"-"连接
|
||||
const formatStandardChannelLabel = (standardChannel: string) => {
|
||||
// 如果是"标准设备X通道Y"格式,则转换为"标准设备X-通道Y"
|
||||
return standardChannel.replace(/(标准设备\d+)(通道\d+)/, '$1-$2');
|
||||
};
|
||||
|
||||
// 处理被检设备通道切换
|
||||
// 处理标准设备通道切换
|
||||
const handleDutChannelChange = (deviceName: string) => {
|
||||
// 更新指定设备的表格数据,但不改变tab图标状态
|
||||
updateTableData(deviceName);
|
||||
};
|
||||
|
||||
// 根据 testDataStructure 生成表格数据
|
||||
const generateTableData = (deviceName: string, dutChannel: string) => {
|
||||
const generateTableData = (deviceName: string, stdChannel: string) => {
|
||||
const deviceData = testDataStructure.value[deviceName];
|
||||
if (!deviceData) return [];
|
||||
|
||||
|
||||
// 根据实际通道编号查找对应的数据
|
||||
const channelData = deviceData.channelDataList.find(channel =>
|
||||
`通道${channel.devNum}` === dutChannel
|
||||
`通道${channel.stdDevNum}` === stdChannel
|
||||
);
|
||||
|
||||
if (!channelData) return [];
|
||||
@@ -338,16 +172,23 @@ const updateTableData = (deviceName: string) => {
|
||||
if (selectedChannel) {
|
||||
const tableData = generateTableData(deviceName, selectedChannel);
|
||||
tableDataMap.value[deviceName] = tableData;
|
||||
console.log('tableDataMap:', tableDataMap.value);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化所有设备的数据和状态
|
||||
const initAllTableData = () => {
|
||||
Object.keys(testDataStructure.value).forEach(deviceName => {
|
||||
|
||||
// 确保设备有数据
|
||||
if (!testDataStructure.value[deviceName] ||
|
||||
!testDataStructure.value[deviceName].channelDataList ||
|
||||
testDataStructure.value[deviceName].channelDataList.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 默认选择第一个可用通道
|
||||
const firstChannel = testDataStructure.value[deviceName].channelDataList[0];
|
||||
selectedChannels.value[deviceName] = `通道${firstChannel.devNum}`;
|
||||
selectedChannels.value[deviceName] = `通道${firstChannel.stdDevNum}`;
|
||||
|
||||
// 生成表格数据
|
||||
updateTableData(deviceName);
|
||||
@@ -377,13 +218,13 @@ const open = async (mapping : Record<string, Record<string, string>>,data : any)
|
||||
// 假设传入的数据是一个数组,需要转换为以设备名为键的对象
|
||||
if (Array.isArray(parsedData)) {
|
||||
parsedData.forEach((deviceItem: any) => {
|
||||
const deviceName = deviceItem.devName;
|
||||
const deviceName = deviceItem.stdDevName;
|
||||
convertedData[deviceName] = {
|
||||
devName: deviceName,
|
||||
channelDataList: deviceItem.channelDataList.map((channel: any) => ({
|
||||
devNum: channel.devNum,
|
||||
standardDevInfo: channel.standardDevInfo,
|
||||
dataList: channel.dataList.map((dataItem: any) => ({
|
||||
stdDevName: deviceName,
|
||||
channelDataList: deviceItem.channelDataList?.map((channel: any) => ({
|
||||
stdDevNum: channel.stdDevNum,
|
||||
devInfo: channel.devInfo,
|
||||
dataList: channel.dataList?.map((dataItem: any) => ({
|
||||
timeDev: dataItem.timeDev,
|
||||
uaDev: dataItem.uaDev,
|
||||
ubDev: dataItem.ubDev,
|
||||
@@ -392,8 +233,8 @@ const open = async (mapping : Record<string, Record<string, string>>,data : any)
|
||||
uaStdDev: dataItem.uaStdDev,
|
||||
ubStdDev: dataItem.ubStdDev,
|
||||
ucStdDev: dataItem.ucStdDev
|
||||
}))
|
||||
}))
|
||||
})) || []
|
||||
})) || []
|
||||
};
|
||||
});
|
||||
} else if (parsedData && typeof parsedData === 'object') {
|
||||
@@ -401,8 +242,11 @@ const open = async (mapping : Record<string, Record<string, string>>,data : any)
|
||||
Object.assign(convertedData, parsedData);
|
||||
}
|
||||
testDataStructure.value = convertedData;
|
||||
console.log('testDataStructure:', testDataStructure.value);
|
||||
channelMapping.value = mapping;
|
||||
dialogVisible.value = true;
|
||||
// 使用 nextTick 确保 DOM 更新后再初始化数据
|
||||
await nextTick();
|
||||
// 初始化数据和状态
|
||||
initAllTableData();
|
||||
|
||||
@@ -419,6 +263,11 @@ const exportData = () => {
|
||||
// 关闭弹窗
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false;
|
||||
// 清空数据
|
||||
testDataStructure.value = {};
|
||||
tableDataMap.value = {};
|
||||
selectedChannels.value = {};
|
||||
tabStatus.value = {};
|
||||
};
|
||||
|
||||
defineExpose({ open });
|
||||
|
||||
Reference in New Issue
Block a user