预见测
This commit is contained in:
@@ -51,7 +51,7 @@ import SelectTestItemPopup from "@/views/home/components/selectTestItemPopup.vue
|
||||
import CompareTestPopup from './compareTestPopup.vue'
|
||||
import { ElMessage } from 'element-plus';
|
||||
import CustomEdge from './RemoveableEdge.vue' // 导入自定义连接线组件
|
||||
import {contrastTest} from '@/api/socket/socket'
|
||||
|
||||
import { jwtUtil } from "@/utils/jwtUtil";
|
||||
|
||||
|
||||
@@ -200,17 +200,15 @@ function logConnections() {
|
||||
}
|
||||
|
||||
const nodes = ref([])
|
||||
const sourceIdArray = ref<string[]>()
|
||||
const planId = ref('')
|
||||
const devIds = ref<string[]>()
|
||||
const standardDevIds = ref<string[]>()
|
||||
|
||||
const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[],sourceIds: string[],fatherPlanId: string) => {
|
||||
const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[],fatherPlanId: string) => {
|
||||
edges.value = []
|
||||
devIds.value = device.map(d => d.id)
|
||||
standardDevIds.value = standardDev.map(d => d.id)
|
||||
planId.value = fatherPlanId
|
||||
sourceIdArray.value = sourceIds
|
||||
nodes.value = createNodes(device, standardDev)
|
||||
dialogVisible.value = true
|
||||
onPaneReady()
|
||||
@@ -222,32 +220,69 @@ const handleNext = () => {
|
||||
return
|
||||
}
|
||||
dialogVisible.value = false
|
||||
selectTestItemPopupRef.value?.open(sourceIdArray.value)
|
||||
selectTestItemPopupRef.value?.open()
|
||||
}
|
||||
|
||||
const openTestDialog = async () => {
|
||||
|
||||
// 转换连接信息,只保留设备ID和通道号
|
||||
const connections = edges.value.reduce((map, edge) => {
|
||||
// 从source中提取设备ID和通道号: 被检通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||
const sourceKey = edge.source.replace('被检通道-', '');
|
||||
|
||||
const sourceKey = edge.source.replace('被检通道-', '').replace('-', '_');
|
||||
|
||||
// 从target中提取设备ID和通道号: 标准通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||
const targetValue = edge.target.replace('标准通道-', '');
|
||||
const targetValue = edge.target.replace('标准通道-', '').replace('-', '_');
|
||||
|
||||
map[sourceKey] = targetValue;
|
||||
return map;
|
||||
}, {} as Record<string, string>);
|
||||
|
||||
console.log('通道配对信息:', connections);
|
||||
await contrastTest({
|
||||
planId: planId.value,
|
||||
loginName: jwtUtil.getLoginName(),
|
||||
devIds: devIds.value,
|
||||
standardDevIds: standardDevIds.value,
|
||||
pairs:connections
|
||||
|
||||
generateChannelMapping()
|
||||
testPopup.value?.open(dialogTitle.value,channelMapping.value,planId.value,jwtUtil.getLoginName(),devIds.value,standardDevIds.value,connections)
|
||||
}
|
||||
|
||||
// 转换 edges.value 为 channelMapping 格式
|
||||
const channelMapping = ref<Record<string, Record<string, string>>>({})
|
||||
|
||||
// 生成映射关系的方法
|
||||
const generateChannelMapping = () => {
|
||||
const mapping: Record<string, Record<string, string>> = {}
|
||||
|
||||
edges.value.forEach(edge => {
|
||||
// 解析 source 节点信息(被检通道)
|
||||
const sourceParts = edge.source.split('-')
|
||||
const sourceDeviceId = sourceParts[1]
|
||||
const sourceChannel = sourceParts[2]
|
||||
|
||||
// 解析 target 节点信息(标准通道)
|
||||
const targetParts = edge.target.split('-')
|
||||
const targetDeviceId = targetParts[1]
|
||||
const targetChannel = targetParts[2]
|
||||
|
||||
// 查找对应的节点以获取显示名称
|
||||
const sourceDeviceNode = nodes.value.find(node => node.id === sourceDeviceId)
|
||||
const targetDeviceNode = nodes.value.find(node => node.id === targetDeviceId)
|
||||
|
||||
if (sourceDeviceNode && targetDeviceNode) {
|
||||
// 提取设备显示文本
|
||||
const sourceDeviceText = sourceDeviceNode.data.label.children[1].children
|
||||
const targetDeviceText = targetDeviceNode.data.label.children[1].children
|
||||
|
||||
// 构造键名
|
||||
const sourceKey = `${sourceDeviceText}`.replace('设备名称:', '')
|
||||
const targetValue = `${targetDeviceText}通道${targetChannel}`.replace('设备名称:', '')
|
||||
|
||||
// 初始化对象
|
||||
if (!mapping[sourceKey]) {
|
||||
mapping[sourceKey] = {}
|
||||
}
|
||||
|
||||
// 添加映射关系
|
||||
mapping[sourceKey][`通道${sourceChannel}`] = targetValue
|
||||
}
|
||||
})
|
||||
testPopup.value?.open(dialogTitle.value,sourceIdArray.value)
|
||||
|
||||
channelMapping.value = mapping
|
||||
}
|
||||
|
||||
const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[]) => {
|
||||
@@ -398,9 +433,8 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
console.log(newNodes)
|
||||
|
||||
//页面高度取决于设备通道
|
||||
dialogHeight.value = Math.max(yPosition.value, yPosition2.value)
|
||||
|
||||
return newNodes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user