This commit is contained in:
guanj
2025-08-26 18:29:14 +08:00
parent d7f1224df4
commit 8b4c22e959
4 changed files with 97 additions and 213 deletions

View File

@@ -238,27 +238,27 @@ const initScriptData = async (row: any) => {
}
//获取基本信息
const getBasicInformation = async () => {
getContrastFormContent({
planId: checkStore.plan.id,
scriptType: rowList.value.scriptType,
deviceId: formContent.deviceId,
chnNum: formContent.chnNum,
num: formContent.num == '' ? null : parseInt(formContent.num)
}).then((res: any) => {
formContent.dataRule = res.data.dataRule
formContent.deviceName = res.data.deviceName
formContent.errorSysId = res.data.errorSysId
chnMapList.value = res.data.chnMap
formContent.num = res.data.checkNum
let chnMap: string[] = []
for (let key in res.data.chnMap) {
chnMap.push(key)
}
chnList.value = chnMap
formContent.chnNum = formContent.chnNum == null ? chnList.value[0] : formContent.chnNum
// 查询表格数据
getResults()
})
getContrastFormContent({
planId: checkStore.plan.id,
scriptType: rowList.value.scriptType,
deviceId: formContent.deviceId,
chnNum: formContent.chnNum,
num: formContent.num == '' ? null : parseInt(formContent.num)
}).then((res: any) => {
formContent.dataRule = res.data.dataRule
formContent.deviceName = res.data.deviceName
formContent.errorSysId = res.data.errorSysId
chnMapList.value = res.data.chnMap
formContent.num = res.data.checkNum
let chnMap: string[] = []
for (let key in res.data.chnMap) {
chnMap.push(key)
}
chnList.value = chnMap
formContent.chnNum = formContent.chnNum == null ? chnList.value[0] : formContent.chnNum
// 查询表格数据
getResults()
})
}
// 左边树变化
@@ -269,25 +269,25 @@ const handleNodeClick = (data: any) => {
}
// 获取结果
const getResults = async () => {
checkResultData.value = []
rawTableData.value = []
checkResultData.value = []
rawTableData.value = []
getContrastResult({
planId: checkStore.plan.id,
scriptType: rowList.value.scriptType,
deviceId: formContent.deviceId,
chnNum: formContent.chnNum,
num: formContent.num == '' ? null : formContent.num
}).then((res: any) => {
let list: string[] = []
for (let key in res.data.resultMap) {
list.push(key)
}
currentCheckItem.value = list[0]
tesList.value = list
checkResultData.value = res.data.resultMap
rawTableData.value = res.data.rawDataMap
})
getContrastResult({
planId: checkStore.plan.id,
scriptType: rowList.value.scriptType,
deviceId: formContent.deviceId,
chnNum: formContent.chnNum,
num: formContent.num == '' ? null : formContent.num
}).then((res: any) => {
let list: string[] = []
for (let key in res.data.resultMap) {
list.push(key)
}
currentCheckItem.value = list[0]
tesList.value = list
checkResultData.value = res.data.resultMap
rawTableData.value = res.data.rawDataMap
})
}
const close = () => {
@@ -332,7 +332,7 @@ defineExpose({
border: 1px solid #ccc;
overflow-y: auto;
overflow-x: auto;
margin-right: 10px;
.content-tree {
width: 100%;
height: 100%;
@@ -348,7 +348,7 @@ defineExpose({
.content-right {
width: 82%;
margin-left: 10px;
flex: 1;
.content-right-title {

View File

@@ -213,16 +213,14 @@ const chnSum = computed(() => {
// 用来展示的检测结果
const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(() => {
console.log('🚀 ~ tem.devices:', checkResult)
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
let temp: CheckData.ScriptChnViewItem = {
scriptType: item.scriptType,
scriptName: item.scriptName,
devices: []
}
item.devices.forEach(device => {
console.log('🚀 ~ item:', item, CheckData.ChnCheckResultEnum)
let tempChnBtnResult: CheckData.ButtonResult[] = []
if (chnSum.value <= MAX_CHN_SUM) {
@@ -286,6 +284,9 @@ watch(testStatus, function (newValue, oldValue) {
// 开始计时
startTimeCount()
showTestLog()
setTimeout(() => {
initCheckResult(CheckData.ChnCheckResultEnum.LOADING)
}, 500)
//startTimer() // todo 可移除
startData.value = new Date()
timeDifference.value = 0
@@ -301,7 +302,6 @@ watch(
webMsgSend,
function (newValue, oldValue) {
console.log('🚀 ~ newValue:', newValue)
if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') {
if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') {
testLogList.shift()
@@ -534,10 +534,10 @@ const initDeviceList = () => {
}
// 初始化检测结果 (详细到通道)
const initCheckResult = () => {
// 修改函数定义
const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => {
let result: CheckData.ScriptChnItem[] = []
scriptData.forEach(item => {
// 处理当前节点的数据
let temp: CheckData.ScriptChnItem = {
scriptType: item.id,
scriptName: item.scriptName,
@@ -547,7 +547,7 @@ const initCheckResult = () => {
for (let i = 0; i < deviceList?.length; i++) {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let j = 0; j < checkStore.chnNumList.length; j++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
tempChnResult.push(defaultValue)
}
temp.devices.push({
deviceId: deviceList[i].deviceId,
@@ -561,22 +561,6 @@ const initCheckResult = () => {
Object.assign(checkResult, result)
}
// 更新检测结果(详细到通道)
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
const { scriptType } = { ...data }
checkResult.forEach(item => {
if (item.scriptType == scriptType) {
for (let i = 0; i < item.devices.length; i++) {
let targetDevice = data.devices.find(dev => dev.deviceId === item.devices[i].deviceId)
if (targetDevice !== undefined) {
item.devices[i].chnResult = [...targetDevice.chnResult]
}
}
}
})
}
const scrollToBottom = () => {
if (scrollContainerRef.value) {
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight + 70
@@ -591,131 +575,42 @@ watch(
{ deep: true }
)
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
let type = 1
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let i = 0; i < devices.length; i++) {
tempChnResult.push(...devices[i].chnResult)
}
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.ERRORDATA)) {
type = CheckData.ChnCheckResultEnum.ERRORDATA
}
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.FAIL)) {
type = CheckData.ChnCheckResultEnum.FAIL
}
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.TIMEOUT)) {
type = CheckData.ChnCheckResultEnum.TIMEOUT
for (let i = 0; i < devices.length; i++) {
if (devices[i].chnResult.some(item => item === CheckData.ChnCheckResultEnum.TIMEOUT)) {
testLogList.push({
type: 'warning',
log: `${new Date().toLocaleString()} ${devices[i].deviceName}连接超时`
})
ElMessageBox.alert('连接超时!', '连接超时', {
confirmButtonText: '确定',
type: 'error'
})
emit('update:testStatus', 'connect_timeout')
}
}
}
errorCheckItem.push({ scriptType, type: type })
}
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
let temp = null
if (isStart) {
temp = getLoadingResult(scriptType)
} else {
setErrorCheckItem(scriptType, devices)
temp = {
scriptType,
devices
}
}
updateCheckResult(temp)
}
// 获取loading状态的结果
const getLoadingResult = (scriptType: string) => {
let devices = []
devices = deviceList.map(item => {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.LOADING)
}
return {
deviceId: item.deviceId,
deviceName: item.deviceName,
chnResult: tempChnResult
}
})
let tempScriptChnItem: CheckData.ScriptChnItem = {
scriptType,
devices
}
return tempScriptChnItem
}
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
let type = 1
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let i = 0; i < devices.length; i++) {
tempChnResult.push(...devices[i].chnResult)
}
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.ERRORDATA)) {
type = CheckData.ChnCheckResultEnum.ERRORDATA
}
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.FAIL)) {
type = CheckData.ChnCheckResultEnum.FAIL
}
return type
}
// 点击查看设备通道检测详情。参数1设备信息参数2通道号-1代表查看全部通道
const handleClick = (item: any, chnNum: number, scriptType: string) => {
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
let flag = -1
if (checkResultItem) {
let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
if (device) {
let chnResult = device.chnResult
if (chnNum === -1) {
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
flag = 0
}
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
flag = 1
}
} else {
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
flag = 0
}
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
flag = 1
}
let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
if (device) {
let chnResult = device.chnResult
if (chnNum === -1) {
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
flag = 0
}
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
flag = 1
}
} else {
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
flag = 0
}
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
flag = 1
}
}
}
}
}
if (flag === 0) {
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
confirmButtonText: '确定',
type: 'warning',
})
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
confirmButtonText: '确定',
type: 'warning'
})
}
if (flag === -1 || flag === 1) {
checkStore.setShowDetailType(2)
checkStore.setShowDetailType(2)
dataCheckSingleChannelSingleTestPopupRef.value?.open(item, chnNum+'', item.devices[0].deviceId,1)
dataCheckSingleChannelSingleTestPopupRef.value?.open(item, chnNum + '', item.devices[0].deviceId, 1)
}
}
@@ -729,7 +624,7 @@ const handlePause = () => {
const initializeParameters = async () => {
await initScriptData()
initDeviceList()
initCheckResult()
initCheckResult(CheckData.ChnCheckResultEnum.UNKNOWN)
percentage.value = 0
timeCount.value = 0
timeView.value = '00:00:00'
@@ -739,26 +634,6 @@ const initializeParameters = async () => {
})
}
const pauseSuccessCallback = () => {
endData.value = new Date()
let diffTime = endData.value.getTime() - startData.value.getTime()
timeDifference.value += diffTime
testLogList.push({
type: 'info',
log: `${new Date().toLocaleString()}:暂停检测`
})
console.log('暂停中')
}
const handleResumeTest = () => {
//activeIndex++
startData.value = new Date()
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
//startTimer()
console.log('开始继续检测')
}
//
onMounted(() => {
if (!checkStore.selectTestItems.preTest) {

View File

@@ -17,6 +17,7 @@
process-status="finish"
finish-status="success"
>
<!-- <el-step title="通道配对" /> -->
<el-step
v-if="preTestSelected"
title="预检测"
@@ -258,16 +259,21 @@ const open = async (
//预检测-重新检测
const handleSubmitAgain = async () => {
console.log("🚀 ~ handleSubmitAgain ~ stepsActive.value:", stepsActiveIndex.value,stepsActiveView.value , stepsActive.value)
if(checkStore.selectTestItems.preTest){
stepsActiveIndex.value = 1
stepsActiveView.value = 1
stepsActive.value = 1
}else{
stepsActiveIndex.value = 1
stepsActiveView.value = 2
stepsActive.value = 2
}
console.log(
'🚀 ~ handleSubmitAgain ~ stepsActive.value:',
stepsActiveIndex.value,
stepsActiveView.value,
stepsActive.value
)
if (checkStore.selectTestItems.preTest) {
stepsActiveIndex.value = 1
stepsActiveView.value = 1
stepsActive.value = 1
} else {
stepsActiveIndex.value = 1
stepsActiveView.value = 2
stepsActive.value = 2
}
let count = 0
for (let key in checkStore.selectTestItems) {
@@ -326,7 +332,7 @@ const handleSubmitFast = async () => {
})
preTestStatus.value = 'start'
if (checkStore.selectTestItems.test) {
console.log(111111);
console.log(111111)
testRef.value.initializeParameters()
testRef.value.showTestLog()
@@ -378,7 +384,6 @@ watch(TestStatus, function (newValue, oldValue) {
watch(stepsActiveIndex, function (newValue, oldValue) {
if (checkStore.selectTestItems.test && checkStore.selectTestItems.preTest && newValue == 2) {
setTimeout(() => {
testRef.value.initializeParameters()
testRef.value.showTestLog()
testRef.value.startTimeCount()

View File

@@ -1011,7 +1011,11 @@ const openDrawer = async (title: string, row: any) => {
}
if (title === '误差体系更换') {
checkStore.setShowDetailType(1)
dataCheckPopupRef.value?.open(row.id, '-1', null)
if (modeStore.currentMode == '模拟式') {
dataCheckPopupRef.value?.open(row.id, '-1', null)
} else if (modeStore.currentMode == '比对式') {
dataCheckSingleChannelSingleTestPopupRef.value?.open(row, null, row.id, 2)
}
}
if (title === '归档') {