预检测出错
This commit is contained in:
@@ -474,10 +474,6 @@ watch(
|
||||
}
|
||||
break;
|
||||
case 'yjc_sbtxjy' :
|
||||
if(newValue.code == 10550){
|
||||
setLogList('error', '设备通讯校验时,设备连接异常!')
|
||||
stopTimeCount()
|
||||
}
|
||||
if (newValue.code == 10552) {
|
||||
ElMessageBox.alert('重复的初始化操作!', '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -534,35 +530,31 @@ watch(
|
||||
testLogList.shift()
|
||||
}
|
||||
switch (newValue.code) {
|
||||
case 25001:
|
||||
case 25006:
|
||||
case 25005:
|
||||
case 25007:// 添加闪变处理
|
||||
{
|
||||
let result: CheckData.ScriptChnItem[] = []
|
||||
|
||||
case 25001:
|
||||
case 25006:
|
||||
case 25005:
|
||||
case 25007:
|
||||
{
|
||||
let message = JSON.parse(newValue.data)
|
||||
|
||||
|
||||
// 先保存当前所有项目的状态
|
||||
const previousStates = new Map()
|
||||
checkResult.forEach(item => {
|
||||
previousStates.set(item.scriptType, JSON.parse(JSON.stringify(item.devices)))
|
||||
})
|
||||
|
||||
// 当收到 25005/25006 消息时,录波项目开始loading
|
||||
|
||||
if (newValue.code == 25005 || newValue.code == 25006) {
|
||||
// 设置录波项目为LOADING状态
|
||||
const waveResultItem = checkResult.find(item => item.code === 'wave_data')
|
||||
|
||||
if (waveResultItem) {
|
||||
waveResultItem.devices.forEach(device => {
|
||||
device.chnResult.fill(CheckData.ChnCheckResultEnum.LOADING)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (newValue.code == 25007) {
|
||||
|
||||
// 设置闪变项目为LOADING状态
|
||||
if (newValue.code == 25007) {
|
||||
const flickerResultItem = checkResult.find(item => item.code === 'F')
|
||||
|
||||
if (flickerResultItem) {
|
||||
flickerResultItem.devices.forEach(device => {
|
||||
device.chnResult.fill(CheckData.ChnCheckResultEnum.LOADING)
|
||||
@@ -570,67 +562,65 @@ watch(
|
||||
}
|
||||
}
|
||||
|
||||
// 重建结果时保留其他正在进行的项目状态
|
||||
let result: CheckData.ScriptChnItem[] = []
|
||||
scriptData.forEach(item => {
|
||||
// 处理当前节点的数据
|
||||
const temp: CheckData.ScriptChnItem = {
|
||||
scriptType: item.id,
|
||||
scriptName: item.scriptName,
|
||||
code: item.code,
|
||||
devices: []
|
||||
}
|
||||
|
||||
// 特殊处理录波项目 - 如果是25005消息且当前项目是录波项目,则使用已设置的状态
|
||||
if ((newValue.code == 25005 || newValue.code == 25006) && item.code === 'wave_data') {
|
||||
|
||||
const existingWaveItem = checkResult.find(checkItem => checkItem.scriptType === 'wave_data')
|
||||
if (existingWaveItem) {
|
||||
temp.devices = [...existingWaveItem.devices] // 保留已设置的devices
|
||||
// 如果是当前处理的项目类型,则使用新数据
|
||||
if ((newValue.code == 25005 || newValue.code == 25006) && item.code === 'wave_data') {
|
||||
// 使用已设置的录波状态
|
||||
const existingItem = checkResult.find(i => i.scriptType === item.id)
|
||||
if (existingItem) {
|
||||
temp.devices = [...existingItem.devices]
|
||||
}
|
||||
} // 特殊处理闪变项目 - 如果是25007消息且当前项目是闪变项目,则使用已设置的状态
|
||||
else if (newValue.code == 25007 && item.code === 'F') {
|
||||
|
||||
const existingFlickerItem = checkResult.find(checkItem => checkItem.scriptName === '闪变')
|
||||
|
||||
if (existingFlickerItem) {
|
||||
temp.devices = [...existingFlickerItem.devices] // 保留已设置的devices
|
||||
} else if (newValue.code == 25007 && item.code === 'F') {
|
||||
// 使用已设置的闪变状态
|
||||
const existingItem = checkResult.find(i => i.scriptType === item.id)
|
||||
if (existingItem) {
|
||||
temp.devices = [...existingItem.devices]
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// 找到message中所有scriptName与当前item.code匹配的项
|
||||
} else {
|
||||
// 对于其他项目,保留之前的状态
|
||||
const matchedDevices = message
|
||||
.filter((msg: any) => msg.scriptName === item.code)
|
||||
.map((msg: any) => ({
|
||||
deviceId: msg.deviceId,
|
||||
deviceName: msg.deviceName,
|
||||
chnResult: msg.chnResult
|
||||
}))
|
||||
.filter((msg: any) => msg.scriptName === item.code)
|
||||
.map((msg: any) => ({
|
||||
deviceId: msg.deviceId,
|
||||
deviceName: msg.deviceName,
|
||||
chnResult: msg.chnResult
|
||||
}))
|
||||
|
||||
// 添加匹配到的设备
|
||||
temp.devices.push(...matchedDevices)
|
||||
|
||||
// 对于未匹配到的设备,也要添加占位符(特别是录波项目)
|
||||
if (item.code === 'wave_data' || item.code === 'F') {
|
||||
if (matchedDevices.length > 0) {
|
||||
temp.devices.push(...matchedDevices)
|
||||
} else {
|
||||
// 保留之前的状态
|
||||
const previousState = previousStates.get(item.id)
|
||||
if (previousState) {
|
||||
temp.devices = previousState
|
||||
} else {
|
||||
// 如果之前没有状态,则初始化
|
||||
deviceList.forEach(device => {
|
||||
const isDeviceExist = matchedDevices.some((matchedDevice: any) => matchedDevice.deviceId === device.deviceId)
|
||||
if (!isDeviceExist) {
|
||||
// 对于录波项目或未匹配到的设备,添加默认状态
|
||||
temp.devices.push({
|
||||
deviceId: device.deviceId,
|
||||
deviceName: device.deviceName,
|
||||
chnResult: new Array(checkStore.chnNumList.length).fill(
|
||||
item.code === 'wave_data' || item.code === 'F' ?
|
||||
CheckData.ChnCheckResultEnum.UNKNOWN :
|
||||
CheckData.ChnCheckResultEnum.UNKNOWN
|
||||
)
|
||||
})
|
||||
}
|
||||
temp.devices.push({
|
||||
deviceId: device.deviceId,
|
||||
deviceName: device.deviceName,
|
||||
chnResult: new Array(checkStore.chnNumList.length).fill(
|
||||
CheckData.ChnCheckResultEnum.UNKNOWN
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
result.push(temp)
|
||||
})
|
||||
|
||||
Object.assign(checkResult, result)
|
||||
|
||||
if (newValue.code == 25001) {
|
||||
setLogList('info', '检测完成!')
|
||||
stopTimeCount()
|
||||
|
||||
Reference in New Issue
Block a user