Files
pqs-9100_client/frontend/src/views/home/components/test.vue

1557 lines
51 KiB
Vue
Raw Normal View History

<template>
<div>
<div class="dialog" v-bind="dialogBig">
<div class="dialog-title">
<div class="timeView">
<el-icon style="margin: 0px 5px;">
<Clock/>
2025-02-19 13:17:19 +08:00
</el-icon>
<span>检测用时{{ timeView }}</span>
</div>
<el-progress
2025-02-25 16:18:22 +08:00
style="width: 60%; margin-right: 4%;"
:percentage="percentage"
:color="customColors"/>
2025-02-25 16:18:22 +08:00
<div style="width: 15%">
<el-button type="primary" v-if="testStatus=='test_init'" disabled @click="handlePause()">
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
<component :is="Refresh"/>
</el-icon>
初始化中
</el-button>
<el-button
type="primary"
v-if="testStatus=='process' && percentage < 100"
:icon="VideoPause"
@click="handlePause()">停止检测
</el-button>
<el-button type="warning" v-if="testStatus === 'paused_ing' && percentage < 100" disabled>
<el-icon class="loading-box" style="margin-right: 8px;">
<component :is="Refresh"/>
</el-icon>
暂停中
</el-button>
<!-- <el-button-->
<!-- type="primary"-->
<!-- v-if="testStatus=='test_init'"-->
<!-- :icon="VideoPause"-->
<!-- disabled>初始化中-->
<!-- </el-button>-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- v-if="testStatus=='test_init_fail'"-->
<!-- :icon="Failed"-->
<!-- disabled>初始化失败-->
<!-- </el-button>-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- v-if="testStatus=='connect_timeout'"-->
<!-- :icon="Failed"-->
<!-- disabled>连接超时-->
<!-- </el-button>-->
2025-02-26 10:00:44 +08:00
<!-- <el-button-->
<!-- type="primary"-->
<!-- :icon="RefreshLeft"-->
<!-- v-if="testStatus === 'recheck'"-->
<!-- @click="emit('sendReCheck')">重新检测-->
<!-- </el-button>-->
<el-button type="success" v-if="percentage >= 100" :icon="Check" disabled>检测完成</el-button>
<el-button
type="warning"
v-if="(testStatus=='paused' || testStatus === 'pause_timeout') && percentage < 100"
:icon="VideoPlay"
:disabled="testStatus === 'pause_timeout'"
@click="emit('sendResume')"
>继续检测
</el-button>
</div>
<el-button style="width: 10%" type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
2025-02-19 13:17:19 +08:00
</div>
2024-11-20 21:30:05 +08:00
<div class="dialog-content">
<el-table :data="checkResultView" row-key="scriptType" height="450px"
:header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " style="width: 100%"
border>
<el-table-column fixed prop="scriptName" label="检测项目" width="150px" align="center">
2024-12-18 18:53:55 +08:00
</el-table-column>
2024-12-20 20:14:52 +08:00
<template v-if="chnSum<=MAX_CHN_SUM">
<el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName"
:min-width="110" align="center">
<el-table-column v-for="(chnItem,index2) in item.chnNum" :key="`${item.deviceId}${chnItem}`"
:label="'通道'+chnItem" align="center">
<template #default="{row}">
<el-tooltip
:content="row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.INFO ? '暂无数据' : '点击查看详情'"
placement="top">
<el-button
:disabled="row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.INFO || row.devices[index1].chnResult[index2].color===CheckData.ButtonColorEnum.LOADING"
:color="row.devices[index1].chnResult[index2].color"
size="small"
@click="handleClick(item,chnItem,row.scriptType)"
style="align-self: center;"
>
<el-icon v-if="row.devices[index1].chnResult[index2].icon==='Loading'" class="loading-box"
style="color: #fff">
<component :is="Loading"/>
</el-icon>
<el-icon v-else style="color: #fff">
<component :is="row.devices[index1].chnResult[index2].icon"/>
</el-icon>
</el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table-column>
</template>
<!-- <template v-else>-->
<!-- <el-table-column v-for="(item,index1) in deviceList" :key="item.deviceId" :label="item.deviceName" :min-width="110" align="center">-->
<!-- <template #default="{row}">-->
<!-- <el-tooltip-->
<!-- :content="row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.INFO ? '暂无数据' : '点击查看详情'"-->
<!-- placement="top">-->
<!-- <el-button-->
<!-- :disabled="row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.INFO || row.devices[index1].chnResult[0].color===CheckData.ButtonColorEnum.LOADING"-->
<!-- :color="row.devices[index1].chnResult[0].color"-->
<!-- size="small"-->
<!-- @click="handleClick(item,-1,row.scriptType)"-->
<!-- >-->
<!-- <el-icon v-if="row.devices[index1].chnResult[0].icon==='Loading'" class="loading-box"-->
<!-- style="color: #fff">-->
<!-- <component :is="Loading"/>-->
<!-- </el-icon>-->
<!-- <el-icon v-else style="color: #fff">-->
<!-- <component :is="row.devices[index1].chnResult[0].icon"/>-->
<!-- </el-icon>-->
<!-- </el-button>-->
<!-- </el-tooltip>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </template>-->
</el-table>
2024-12-24 19:21:43 +08:00
</div>
2024-12-20 10:21:36 +08:00
</div>
<div class="drawer-container">
<el-drawer v-model="drawer" title="检测项进度" direction="btt">
<div ref="scrollContainerRef" style="height: 100%; overflow-y: auto;">
<p v-for="(item, index) in testLogList"
:key="index"
:style="{color:item.type==='error'?'#F56C6C': item.type==='warning'?'#e6a23c':'var(--el-text-color-regular)'}">
{{ item.log }}<br/>
</p>
</div>
</el-drawer>
</div>
<resultPopup
:visible="resultDialogVisible"
@update:visible="resultDialogVisible = $event"
></resultPopup>
<dataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
</div>
</template>
<script lang="tsx" setup name="test">
2025-02-19 13:17:19 +08:00
import {Check, Failed, InfoFilled, Loading, Timer, Refresh, RefreshLeft, VideoPause, VideoPlay} from '@element-plus/icons-vue'
import resultPopup from './resultPopup.vue'
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
2025-01-02 09:02:46 +08:00
import {computed, reactive, ref, toRef, watch} from "vue";
2024-12-18 20:26:18 +08:00
import {dialogBig} from "@/utils/elementBind";
import {CheckData} from "@/api/check/interface"
import {useCheckStore} from "@/stores/modules/check";
2024-12-30 14:41:34 +08:00
import {ElMessage, ElMessageBox} from "element-plus";
import {getBigTestItem} from "@/api/check/test";
const checkStore = useCheckStore()
// 最大通道数
2025-02-11 09:10:50 +08:00
const MAX_CHN_SUM = 12
2024-12-24 19:21:43 +08:00
// 总测试项数
2024-12-27 10:31:15 +08:00
let checkTotal = 0
2024-12-24 19:21:43 +08:00
2024-12-24 11:29:31 +08:00
const props = defineProps({
testStatus: {
type: String,
default: 'waiting'
},
webMsgSend: {
type: Object,
default: () => ({})
}
})
const emit = defineEmits(['update:testStatus', 'update:webMsgSend', 'sendPause', 'sendResume', 'sendReCheck']);
2024-12-24 11:29:31 +08:00
// 用来保存测试项进度抽屉是否打开
const drawer = ref(false)
// 进度条颜色
2025-02-19 13:17:19 +08:00
const customColors = [{color: "#67c23a", percentage: 100}]
2024-12-24 19:21:43 +08:00
// 检测脚本数据
let scriptData: CheckData.ScriptItem[] = []
2024-12-24 11:29:31 +08:00
// 用来保存被检设备
const deviceList = reactive<CheckData.Device[]>([])
// 当前进行的测试项索引
2025-01-03 18:57:35 +08:00
let activeIndex = 0
2024-12-24 11:29:31 +08:00
// 百分比
const percentage = ref(0);
2025-02-17 10:16:48 +08:00
// 时间计数器
let timer: any = null
const timeCount = ref(0)
const timeView = ref('00:00:00')
2024-12-24 11:29:31 +08:00
//测试项开始检测时间(或继续检测时间)
const startData = ref(new Date())
//测试项检测结束时间(或暂停时的时间)
const endData = ref(new Date())
const timeDifference = ref(0)
2024-12-24 19:21:43 +08:00
// 真正的检测结果(详细到通道)
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
2024-12-24 11:29:31 +08:00
// 用来存放检测出现失败的测试项id。只要有一个通道检测不合格则该检测项的id会被加入该数组。
2025-01-09 11:13:34 +08:00
let errorCheckItem: Array<{ scriptType: string, type: CheckData.ChnCheckResultEnum }> = []
2024-12-24 11:29:31 +08:00
// 用来存放检测日志
2024-12-27 10:31:15 +08:00
const testLogList = reactive<CheckData.LogItem[]>([{type: 'info', log: '暂无数据,等待检测开始'}])
2024-12-24 11:29:31 +08:00
const testStatus = toRef(props, 'testStatus')
const webMsgSend = toRef(props, 'webMsgSend')
2024-12-24 11:29:31 +08:00
const resultDialogVisible = ref(false)
2024-12-27 13:36:20 +08:00
const scrollContainerRef = ref();
2024-12-24 19:21:43 +08:00
const dataCheckSingleChannelSingleTestPopupRef = ref<InstanceType<typeof dataCheckSingleChannelSingleTestPopup>>()
2024-12-18 15:56:59 +08:00
// 总通道数
const chnSum = computed(() => {
let sum = 0
deviceList.forEach((item) => {
2024-12-18 15:56:59 +08:00
sum += item.chnNum
})
return sum
})
2024-12-24 19:21:43 +08:00
// 用来展示的检测结果
2025-01-03 18:57:35 +08:00
const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(() => {
2024-12-24 19:21:43 +08:00
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
let temp: CheckData.ScriptChnViewItem = {
scriptType: item.scriptType,
2024-12-25 18:04:16 +08:00
scriptName: item.scriptName,
2024-12-24 19:21:43 +08:00
devices: []
}
item.devices.forEach(device => {
let tempChnBtnResult: CheckData.ButtonResult[] = []
if (chnSum.value <= MAX_CHN_SUM) {
for (let j = 0; j < device.chnResult.length; j++) {
2024-12-26 10:49:55 +08:00
switch (device.chnResult[j]) {
case CheckData.ChnCheckResultEnum.UNKNOWN:
2024-12-27 10:31:15 +08:00
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.INFO, icon: 'Minus'})
2024-12-26 10:49:55 +08:00
break;
case CheckData.ChnCheckResultEnum.LOADING:
2024-12-27 13:36:20 +08:00
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.LOADING, icon: 'Loading'})
2024-12-26 10:49:55 +08:00
break;
case CheckData.ChnCheckResultEnum.SUCCESS:
2024-12-27 10:31:15 +08:00
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.SUCCESS, icon: 'CircleCheckFilled'})
break;
case CheckData.ChnCheckResultEnum.FAIL:
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.DANGER, icon: 'Close'})
2024-12-26 10:49:55 +08:00
break;
2025-01-08 20:57:11 +08:00
case CheckData.ChnCheckResultEnum.TIMEOUT:
2024-12-27 10:31:15 +08:00
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'Link'})
break;
case CheckData.ChnCheckResultEnum.ERRORDATA:
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'WarnTriangleFilled'})
2024-12-26 10:49:55 +08:00
break;
default:
break;
2024-12-24 19:21:43 +08:00
}
}
}
2025-02-21 09:05:06 +08:00
// else {
// let tempChnResult: CheckData.ChnCheckResultEnum = device.chnResult[0]
// if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.ERRORDATA)) {
// tempChnResult = CheckData.ChnCheckResultEnum.ERRORDATA
// }
// if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.FAIL)) {
// tempChnResult = CheckData.ChnCheckResultEnum.FAIL
// }
// if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.TIMEOUT)) {
// tempChnResult = CheckData.ChnCheckResultEnum.TIMEOUT
// }
// switch (tempChnResult) {
// case CheckData.ChnCheckResultEnum.UNKNOWN:
// tempChnBtnResult.push({color: CheckData.ButtonColorEnum.INFO, icon: 'Minus'})
// break;
// case CheckData.ChnCheckResultEnum.LOADING:
// tempChnBtnResult.push({color: CheckData.ButtonColorEnum.LOADING, icon: 'Loading'})
// break;
// case CheckData.ChnCheckResultEnum.SUCCESS:
// tempChnBtnResult.push({color: CheckData.ButtonColorEnum.SUCCESS, icon: 'CircleCheckFilled'})
// break;
// case CheckData.ChnCheckResultEnum.FAIL:
// tempChnBtnResult.push({color: CheckData.ButtonColorEnum.DANGER, icon: 'Close'})
// break;
// case CheckData.ChnCheckResultEnum.TIMEOUT:
// tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'Link'})
// break;
// case CheckData.ChnCheckResultEnum.ERRORDATA:
// tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'WarnTriangleFilled'})
// break;
// default:
// break;
// }
// }
2024-12-24 19:21:43 +08:00
temp.devices.push({
deviceId: device.deviceId,
deviceName: device.deviceName,
chnResult: tempChnBtnResult
})
})
return temp
})
2025-01-09 14:18:50 +08:00
2024-12-24 19:21:43 +08:00
return result
})
2024-12-24 11:29:31 +08:00
watch(testStatus, function (newValue, oldValue) {
if (newValue == 'start') {
2025-01-07 19:03:00 +08:00
ElMessage.success('初始化开始!')
2025-02-17 10:16:48 +08:00
startTimeCount()
2025-01-08 20:57:11 +08:00
showTestLog()
2025-02-26 10:00:44 +08:00
// if (oldValue == 'recheck' || oldValue == 'error' || oldValue == 'test_init_fail' || oldValue == 'connect_timeout' || oldValue == 'pause_timeout' || oldValue == 'error_flow_end') {
// handleReCheck()
// }
2025-01-07 19:03:00 +08:00
emit('update:testStatus', 'test_init')
2025-02-25 15:11:23 +08:00
//startTimer() // todo 可移除
2025-01-15 08:53:45 +08:00
startData.value = new Date();
timeDifference.value = 0;
2025-01-07 19:03:00 +08:00
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化开始!`})
2024-12-24 11:29:31 +08:00
}
2025-02-26 10:00:44 +08:00
if (newValue == 'recheck' || newValue == 'error' || newValue == 'test_init_fail' || newValue == 'connect_timeout' || newValue == 'pause_timeout' || oldValue == 'error_flow_end') {
stopTimeCount()
}
2024-12-24 11:29:31 +08:00
})
// 次数
let count = 0
2024-12-24 11:29:31 +08:00
watch(webMsgSend, function (newValue, oldValue) {
if (newValue.code == 10520) {
ElMessageBox.alert('报文解析异常!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:报文解析异常!`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10521) {
ElMessageBox.alert('程控源參数有误!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:程控源參数有误!`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10522) {
ElMessageBox.alert('测试项解析有误!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:测试项解析有误!`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10523) {
if (count === 0) {
ElMessageBox.alert('源连接失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源连接失败!`})
emit('update:testStatus', 'test_init_fail')
count++
}
} else if (newValue.code == 10524) {
ElMessageBox.alert('获取源控制权失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:获取源控制权失败!`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10525) {
ElMessageBox.alert('重置源失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:重置源失败!`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10527) {
ElMessageBox.alert('源未进行初始化!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源未进行初始化!`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10528) {
ElMessageBox.alert('目标源有误(该用户已控制其他源,在关闭前无法操作新的源)', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:目标源有误(该用户已控制其他源,在关闭前无法操作新的源)`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10529) {
ElMessageBox.alert('源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
2025-01-22 14:31:53 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)`})
emit('update:testStatus', 'test_init_fail')
} else if (newValue.code == 10550) {
2025-01-09 14:18:50 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}${newValue.data}设备连接异常!`})
2025-01-22 14:31:53 +08:00
emit('update:testStatus', 'test_init_fail')
2025-01-07 14:54:44 +08:00
} else if (newValue.code == 10551) {
2025-01-07 19:03:00 +08:00
ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '初始化失败', {
2025-01-07 14:54:44 +08:00
confirmButtonText: '确定',
type: 'error',
})
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}${newValue.data}设备触发报告异常!`})
2025-01-07 19:03:00 +08:00
emit('update:testStatus', 'test_init_fail')
2025-01-07 14:54:44 +08:00
} else if (newValue.code == 10552) { //todo 10552之后还会发送消息吗
2025-01-07 19:03:00 +08:00
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
testLogList.push({
type: 'error',
log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!`
})
2025-02-26 10:00:44 +08:00
// emit('update:testStatus', 'recheck')
emit('update:testStatus', 'test_init_fail')
} else {
2024-12-24 11:29:31 +08:00
switch (newValue.requestId) {
2025-01-22 14:31:53 +08:00
case 'server_error':
if (newValue.operateCode === 'server_error' && count === 0) {
2025-01-22 14:31:53 +08:00
ElMessageBox.alert('源连接失败!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源连接失败!`})
emit('update:testStatus', 'test_init_fail')
count++
2025-01-22 14:31:53 +08:00
}
break;
2025-01-16 08:51:47 +08:00
case 'formal_real': // 正式测试
switch (newValue.operateCode) {
case "stop_timeout":
ElMessageBox.alert(`暂停时间已过10分钟本次检测已失效请重新发起检测`, '暂停时间过长', {
confirmButtonText: '确定',
type: 'error',
})
emit('update:testStatus', 'pause_timeout')
break;
}
break;
2025-01-09 14:18:50 +08:00
case 'error_flow_end':
ElMessageBox.alert(`设备连接异常,请检查设备连接情况!`, '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
emit('update:testStatus', 'test_init_fail')
break
2025-01-07 19:03:00 +08:00
case 'socket_timeout':
switch (newValue.operateCode) {
case "VOLTAGE":
2025-01-08 20:57:11 +08:00
// todo 超时处理 页面按钮更新
2025-01-07 19:03:00 +08:00
ElMessageBox.alert('连接超时!', '连接超时', {
confirmButtonText: '确定',
type: 'error',
})
emit('update:testStatus', 'connect_timeout')
break;
}
break;
2025-02-26 13:22:01 +08:00
// case 'connect':
// switch (newValue.operateCode) {
// case "Source":
// ElMessageBox.alert('源通讯失败,请检查源连接情况!', '初始化失败', {
// confirmButtonText: '确定',
// type: 'error',
// })
// testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源通讯失败!`})
// break;
// case "Dev":
// ElMessageBox.alert('设备通讯失败,请检查设备连接情况!', '初始化失败', {
// confirmButtonText: '确定',
// type: 'error',
// })
// testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:设备通讯失败!`})
// break;
// }
// emit('update:testStatus', 'test_init_fail')
// break;
2025-01-07 19:03:00 +08:00
case 'yjc_ytxjy':
switch (newValue.operateCode) {
case 'INIT_GATHER':
if (newValue.code == 10200) {
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:源初始化成功!`})
2025-01-08 20:57:11 +08:00
percentage.value = 1
2025-01-07 19:03:00 +08:00
}
if (newValue.code == -1) {
ElMessageBox.alert('源未知异常!', '初始化失败', {
confirmButtonText: '确定',
type: 'error',
})
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源未知异常!`})
emit('update:testStatus', 'test_init_fail')
}
2025-01-07 19:03:00 +08:00
break;
}
break;
case 'yjc_sbtxjy':
switch (newValue.operateCode) {
case 'INIT_GATHER$01':
if (newValue.code == 25001) {
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:设备通讯校验成功!`})
2025-01-08 20:57:11 +08:00
percentage.value = 2
2025-01-07 19:03:00 +08:00
}
break
}
break;
2025-01-07 17:34:15 +08:00
case 'yjc_xyjy':
switch (newValue.operateCode) {
2025-01-07 14:54:44 +08:00
case 'INIT_GATHER$03':
if (newValue.code == 25001) {
2025-01-07 19:03:00 +08:00
ElMessage.success('初始化成功!')
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:协议校验成功!`})
timeDifference.value = +new Date().getTime() - startData.value.getTime();
2025-01-07 19:03:00 +08:00
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化成功!`})
2025-01-08 20:57:11 +08:00
percentage.value = 3
2025-01-09 14:18:50 +08:00
2025-01-15 08:53:45 +08:00
2025-01-07 14:54:44 +08:00
activeIndex = getNextActiveIndex() + 2
2025-02-25 15:11:23 +08:00
//startTimer()
2025-01-03 18:57:35 +08:00
2025-01-07 14:54:44 +08:00
emit('update:testStatus', 'process')
}
break;
}
2024-12-30 14:41:34 +08:00
break;
2025-01-14 16:21:50 +08:00
case 'preStopTest':
if (newValue.operateCode == 'stop') {
2025-01-14 16:21:50 +08:00
ElMessage.success('暂停成功')
emit('update:testStatus', 'paused')
2025-01-14 21:07:52 +08:00
pauseSuccessCallback()
2025-01-14 16:21:50 +08:00
}
2024-12-30 14:41:34 +08:00
break;
2025-01-10 09:20:32 +08:00
// case 'Pause_Fail':
// ElMessage.error('暂停失败')
// break;
case 'Resume_Success':
2024-12-30 14:41:34 +08:00
ElMessage.success('开始继续检测')
2025-01-14 14:17:05 +08:00
emit('update:testStatus', 'process')
2025-02-26 15:56:03 +08:00
handleResumeTest()
2024-12-30 14:41:34 +08:00
break;
2025-01-10 09:20:32 +08:00
// case 'Resume_Fail':
// ElMessage.error('无法继续检测')
// break;
case 'FREQ_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('FREQ', newValue.desc)
2024-12-26 10:49:55 +08:00
break;
case 'FREQ_End':
2025-01-15 08:59:47 +08:00
handleEndItem('FREQ', newValue.desc, newValue.data)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'V_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('V', newValue.desc)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'V_End':
2025-01-15 08:59:47 +08:00
handleEndItem('V', newValue.desc, newValue.data)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HV_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('HV', newValue.desc)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HV_End':
2025-01-15 08:59:47 +08:00
handleEndItem('HV', newValue.desc, newValue.data)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HI_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('HI', newValue.desc)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HI_End':
2025-01-15 08:59:47 +08:00
handleEndItem('HI', newValue.desc, newValue.data)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HP_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('HP', newValue.desc)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HP_End':
2025-01-15 08:59:47 +08:00
handleEndItem('HP', newValue.desc, newValue.data)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HSV_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('HSV', newValue.desc)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HSV_End':
2025-01-15 08:59:47 +08:00
handleEndItem('HSV', newValue.desc, newValue.data)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HSI_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('HSI', newValue.desc)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'HSI_End':
2025-01-15 08:59:47 +08:00
handleEndItem('HSI', newValue.desc, newValue.data)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'VOLTAGE_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('VOLTAGE', newValue.desc)
2024-12-26 10:49:55 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'VOLTAGE_End':
2025-01-15 08:59:47 +08:00
handleEndItem('VOLTAGE', newValue.desc, newValue.data)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'I_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('I', newValue.desc)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'I_End':
2025-01-15 08:59:47 +08:00
handleEndItem('I', newValue.desc, newValue.data)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'IMBV_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('IMBV', newValue.desc)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'IMBV_End':
2025-01-15 08:59:47 +08:00
handleEndItem('IMBV', newValue.desc, newValue.data)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'IMBA_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('IMBA', newValue.desc)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'IMBA_End':
2025-01-15 08:59:47 +08:00
handleEndItem('IMBA', newValue.desc, newValue.data)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'F_Start':
2025-01-15 08:59:47 +08:00
handleStartItem('F', newValue.desc)
2024-12-24 11:29:31 +08:00
break;
2025-01-02 20:27:36 +08:00
case 'F_End':
2025-01-15 08:59:47 +08:00
handleEndItem('F', newValue.desc, newValue.data)
2024-12-24 11:29:31 +08:00
break;
case 'Quit':
2024-12-24 11:29:31 +08:00
console.log('检测结束')
break;
}
2024-12-27 10:31:15 +08:00
}
2024-12-27 10:31:15 +08:00
}, {deep: true})
2024-12-24 11:29:31 +08:00
const handleStartItem = (code: string, desc: string | undefined) => {
2025-01-15 08:59:47 +08:00
if (desc === undefined) {
activeIndex = getActiveIndex(code)
updateCheckResultView(code, true)
updateLog(true)
} else {
2025-02-25 15:11:23 +08:00
if (desc.length > 150) {
desc = desc.substring(0, 150) + '...'
2025-01-15 08:59:47 +08:00
}
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}${desc}准确度检测:开始`})
}
}
const handleEndItem = (code: string, desc: string | undefined, devices: CheckData.DeviceCheckResult[] = []) => {
2025-01-15 08:59:47 +08:00
if (desc === undefined) {
updatePercentage()
updateCheckResultView(code, false, devices)
updateLog(false)
if (testStatus.value != 'paused') {
activeIndex = getNextActiveIndex(code)
2025-02-25 15:11:23 +08:00
//startTimer()
2025-01-15 08:59:47 +08:00
}
} else {
let result = getResult(devices)
2025-02-25 15:11:23 +08:00
if (desc.length > 150) {
2025-02-25 16:18:22 +08:00
desc = desc.substring(0,150) + '...'
2025-01-15 08:59:47 +08:00
}
if (result === 1) {
2025-01-15 08:59:47 +08:00
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}${desc}检测结束:符合`})
}
if (result === 2) {
2025-01-15 08:59:47 +08:00
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}${desc}检测结束:不符合`})
}
if (result === 4) {
2025-01-15 08:59:47 +08:00
testLogList.push({type: 'warning', log: `${new Date().toLocaleString()}${desc}检测结束:数据异常`})
}
}
}
2025-01-13 21:06:24 +08:00
2024-12-27 10:31:15 +08:00
// 更新进度条
const updatePercentage = () => {
if (activeIndex < checkTotal) {
percentage.value = Math.trunc(activeIndex / checkTotal * 100);
2024-12-24 11:29:31 +08:00
} else {
2024-12-27 10:31:15 +08:00
percentage.value = 100;
2024-12-24 11:29:31 +08:00
emit('update:testStatus', 'success')
2024-12-27 10:31:15 +08:00
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
confirmButtonText: '确定',
})
2025-02-08 15:36:56 +08:00
//clear();
2024-12-24 11:29:31 +08:00
}
2024-12-27 10:31:15 +08:00
}
// todo 可移除start
2025-01-07 11:19:33 +08:00
// let randomUnConnectedRaw = -1
// let randomUnConnectedDeviceId = -1
// let randomErrorDataRaw = -1
2024-12-27 10:31:15 +08:00
// todo 可移除end
2024-12-24 11:29:31 +08:00
onBeforeMount(async () => {
await initScriptData()
initDeviceList()
initCheckResult()
2024-12-27 10:31:15 +08:00
// todo 可移除start
2025-01-07 11:19:33 +08:00
// let a = getRandomInt(scriptData.length) + 4
// randomUnConnectedRaw = a < scriptData.length ? a : scriptData.length
// randomUnConnectedDeviceId = deviceList[getRandomInt(deviceList.length)].deviceId
// randomErrorDataRaw = getRandomInt(scriptData.length) + 1
// while (randomErrorDataRaw === randomUnConnectedRaw) {
// randomErrorDataRaw = getRandomInt(scriptData.length) + 1
// }
2024-12-27 10:31:15 +08:00
// todo 可移除end
})
2024-12-13 08:56:42 +08:00
2024-12-24 11:29:31 +08:00
const showTestLog = () => {
drawer.value = true
}
// 初始化检测脚本数据
const initScriptData = async () => {
let response: any = await getBigTestItem(checkStore.plan.id)
let temp = response.data.map(item => {
2024-12-24 11:29:31 +08:00
return {
...item,
scriptName: item.scriptName
2024-12-24 11:29:31 +08:00
}
})
2024-12-24 11:29:31 +08:00
scriptData.push(...temp)
2025-01-04 16:33:23 +08:00
checkTotal = scriptData.length
}
// 初始化设备列表
const initDeviceList = () => {
2025-01-08 11:02:16 +08:00
Object.assign(deviceList, checkStore.devices)
}
2024-12-24 19:21:43 +08:00
// 初始化检测结果 (详细到通道)
const initCheckResult = () => {
let result: CheckData.ScriptChnItem[] = []
scriptData.forEach(item => {
// 处理当前节点的数据
let temp: CheckData.ScriptChnItem = {
scriptType: item.id,
2024-12-25 18:04:16 +08:00
scriptName: item.scriptName,
devices: []
}
for (let i = 0; i < deviceList?.length; i++) {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let j = 0; j < deviceList[i].chnNum; j++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
2024-11-21 23:02:43 +08:00
}
temp.devices.push({
2024-12-21 12:41:06 +08:00
deviceId: deviceList[i].deviceId,
deviceName: deviceList[i].deviceName,
chnResult: tempChnResult
})
}
result.push(temp)
})
Object.assign(checkResult, result)
}
2025-01-08 11:02:16 +08:00
// 更新检测结果(详细到通道)
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
const {scriptType} = {...data}
checkResult.forEach(item => {
if (item.scriptType == scriptType) {
2025-01-15 08:53:45 +08:00
for (let i = 0; i < item.devices.length; i++) {
let targetDevice = data.devices.find(dev => dev.deviceId === item.devices[i].deviceId)
2025-01-10 09:20:32 +08:00
if (targetDevice !== undefined) {
2025-01-15 08:53:45 +08:00
item.devices[i].chnResult = [...targetDevice.chnResult]
2025-01-09 15:49:32 +08:00
}
2025-01-15 08:53:45 +08:00
}
// item.devices.forEach((device, index) => {
// let targetDevice = data.devices.find(dev => dev.deviceId === device.deviceId)
// if (targetDevice !== undefined) {
// device.chnResult = [...targetDevice.chnResult]
// }
// })
}
})
}
2024-11-21 23:02:43 +08:00
const scrollToBottom = () => {
2024-12-27 13:36:20 +08:00
if (scrollContainerRef.value) {
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight + 70;
2024-12-18 18:53:55 +08:00
}
};
2024-11-21 23:02:43 +08:00
function getRandomInt(max: number): number {
return Math.floor(Math.random() * max)
2024-11-21 23:02:43 +08:00
}
2024-12-11 17:46:59 +08:00
2024-12-18 18:53:55 +08:00
function getTimeDifference(timeDifference: number): string {
2024-12-11 17:46:59 +08:00
// 将时间差转换为天、小时、分钟、秒
const millisecondsPerDay = 1000 * 60 * 60 * 24;
const millisecondsPerHour = 1000 * 60 * 60;
const millisecondsPerMinute = 1000 * 60;
const millisecondsPerSecond = 1000;
const days = Math.floor(timeDifference / millisecondsPerDay);
const hours = Math.floor((timeDifference % millisecondsPerDay) / millisecondsPerHour);
const minutes = Math.floor((timeDifference % millisecondsPerHour) / millisecondsPerMinute);
const seconds = Math.floor((timeDifference % millisecondsPerMinute) / millisecondsPerSecond);
2024-12-18 18:53:55 +08:00
if (days > 0) {
2024-12-11 18:48:54 +08:00
return `: ${days} 天, ${hours} 小时, ${minutes} 分钟, ${seconds}`
2024-12-18 18:53:55 +08:00
} else if (hours > 0) {
2024-12-11 18:48:54 +08:00
return `: ${hours} 小时, ${minutes} 分钟, ${seconds}`
2024-12-18 18:53:55 +08:00
} else {
2024-12-11 18:48:54 +08:00
return `: ${minutes} 分钟, ${seconds}`
}
2024-12-11 17:46:59 +08:00
}
2025-01-14 14:17:05 +08:00
watch(testLogList, () => {
scrollToBottom();
}, {deep: true})
2024-12-11 17:46:59 +08:00
// 更新日志
2024-12-27 10:31:15 +08:00
const updateLog = (isStart: boolean) => {
2024-11-21 23:02:43 +08:00
const currentTime = ref(new Date().toLocaleString());
let timeDifferenceItem = 0
2024-11-21 23:02:43 +08:00
2024-12-27 10:31:15 +08:00
if (activeIndex === 1 && isStart) {
2025-01-15 08:53:45 +08:00
// timeDifference.value = 0;
//testLogList.length = 0; // 清空数组
2024-12-27 10:31:15 +08:00
}
// debugger
2025-01-04 16:33:23 +08:00
if (activeIndex <= checkTotal) {
2024-12-27 10:31:15 +08:00
if (isStart) {
2025-01-15 08:53:45 +08:00
startData.value = new Date();
2024-12-27 10:31:15 +08:00
testLogList.push({
2024-11-21 23:02:43 +08:00
type: 'info',
2024-12-27 10:31:15 +08:00
log: currentTime.value + ` ${scriptData[activeIndex - 1].scriptName}准确度检测:开始`,
2024-11-21 23:02:43 +08:00
})
2024-12-27 10:31:15 +08:00
} else {
2024-12-11 18:48:54 +08:00
endData.value = new Date();
timeDifferenceItem = endData.value.getTime() - startData.value.getTime();
timeDifference.value += timeDifferenceItem
2024-12-27 10:31:15 +08:00
2025-01-09 11:13:34 +08:00
let errorItem = getErrorCheckItem(scriptData[activeIndex - 1].id)
switch (errorItem?.type) {
case CheckData.ChnCheckResultEnum.SUCCESS:
testLogList.push({
type: 'info',
log: currentTime.value + ` ${scriptData[activeIndex - 1].scriptName}准确度检测结束:符合,用时` + getTimeDifference(timeDifferenceItem),
})
break
case CheckData.ChnCheckResultEnum.FAIL:
testLogList.push({
type: 'error',
log: currentTime.value + ` ${scriptData[activeIndex - 1].scriptName}准确度检测结束:不符合,用时` + getTimeDifference(timeDifferenceItem),
})
break
case CheckData.ChnCheckResultEnum.TIMEOUT:
testLogList.push({
type: 'warning',
log: currentTime.value + ` ${scriptData[activeIndex - 1].scriptName}准确度检测结束:连接超时,用时` + getTimeDifference(timeDifferenceItem),
})
break
case CheckData.ChnCheckResultEnum.ERRORDATA:
testLogList.push({
type: 'warning',
log: currentTime.value + ` ${scriptData[activeIndex - 1].scriptName}准确度检测结束:数据异常,用时` + getTimeDifference(timeDifferenceItem),
})
break
2024-12-11 18:48:54 +08:00
}
2025-01-04 16:33:23 +08:00
2025-02-19 13:17:19 +08:00
timeView.value = secondToTime(timeDifference.value / 1000)
2025-01-07 14:54:44 +08:00
if (activeIndex === checkTotal) {
2025-01-04 16:33:23 +08:00
testLogList.push({
type: 'info',
log: currentTime.value + ' :检测结束,总用时' + getTimeDifference(timeDifference.value),
})
2025-02-17 10:16:48 +08:00
stopTimeCount()
2025-01-04 16:33:23 +08:00
}
2024-12-27 10:31:15 +08:00
}
2024-12-18 18:53:55 +08:00
}
2024-11-21 23:02:43 +08:00
}
// 动态获取表格单元格样式
2024-12-27 10:31:15 +08:00
// function tableCell({row, columnIndex}) {
// let items = errorCheckItem.filter((item) => item === row.scriptType)
2024-12-27 10:31:15 +08:00
//
// if (columnIndex === 0 && items.length > 0) {
// return 'warning-row'
// }
// if (columnIndex === 0) {
// return 'header-row'
// }
// }
2024-11-20 21:30:05 +08:00
2025-01-09 11:13:34 +08:00
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
let type = 1
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
2025-01-07 17:44:25 +08:00
for (let i = 0; i < devices.length; i++) {
2025-01-09 11:13:34 +08:00
tempChnResult.push(...devices[i].chnResult)
}
2025-01-14 10:36:42 +08:00
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.ERRORDATA)) {
type = CheckData.ChnCheckResultEnum.ERRORDATA
}
2025-01-10 10:47:08 +08:00
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.FAIL)) {
type = CheckData.ChnCheckResultEnum.FAIL
}
2025-01-09 11:13:34 +08:00
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}连接超时`,
})
2025-02-25 14:13:59 +08:00
ElMessageBox.alert('连接超时!', '连接超时', {
confirmButtonText: '确定',
type: 'error',
})
emit('update:testStatus', 'connect_timeout')
2025-01-07 17:44:25 +08:00
}
}
2025-01-09 11:13:34 +08:00
}
errorCheckItem.push({scriptType, type: type})
}
//判断该检测项(例如 频率准确度检测)是否全部合格(所有设备所有通道所有子检测项目全部合格为合格,否则为不合格)
function getErrorCheckItem(scriptType: string) {
let results = errorCheckItem.filter((item) => item.scriptType === scriptType)
if (results.length > 0) {
return results[0]
} else {
return null
2025-01-07 17:44:25 +08:00
}
}
2025-01-09 11:13:34 +08:00
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
2025-02-25 15:11:23 +08:00
// devices = [
// {
// chnResult: [1, 1, 1, 1],
2025-02-26 19:02:43 +08:00
// deviceId: "e90c09c0905248ad912e19e17a8672aa",
// deviceName: "250226001"
2025-02-25 15:11:23 +08:00
// },
2025-02-25 14:13:59 +08:00
// {
// chnResult: [1, 1, 1, 1],
// deviceId: "df23a4178d194467a432ddf45e835e48",
// deviceName: "240003"
// },
// {
// chnResult: [1, 1, 1, 1],
// deviceId: "ae5a7628260349c0a5e7c86c81fbd417",
// deviceName: "240004"
// },
// {
// chnResult: [1, 1, 1, 1],
// deviceId: "461813a4f30f4a34a1a273ecd0379458",
// deviceName: "25011407"
// }
2025-02-25 15:11:23 +08:00
// ]
2024-12-26 10:49:55 +08:00
let temp = null
if (isStart) {
temp = getLoadingResult(scriptType)
2024-12-26 10:49:55 +08:00
} else {
2025-01-08 09:46:47 +08:00
setErrorCheckItem(scriptType, devices)
2025-01-07 14:54:44 +08:00
temp = {
scriptType,
2025-01-07 19:03:00 +08:00
devices
2025-01-07 14:54:44 +08:00
}
2024-12-26 10:49:55 +08:00
}
updateCheckResult(temp)
};
2024-12-26 10:49:55 +08:00
// 获取loading状态的结果
const getLoadingResult = (scriptType: string) => {
2024-12-26 10:49:55 +08:00
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,
2024-12-26 10:49:55 +08:00
devices,
}
return tempScriptChnItem
}
2024-12-27 10:31:15 +08:00
// 模拟检测 todo 可移除
const getCheckResult = (scriptType: string) => {
2024-12-27 10:31:15 +08:00
// debugger
let devices = []
2025-01-07 11:19:33 +08:00
// if (activeIndex === randomErrorDataRaw) {
// devices = deviceList.map(item => {
// let tempChnResult: CheckData.ChnCheckResultEnum[] = []
// if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
// for (let i = 0; i < item.chnNum; i++) {
2025-01-08 21:02:36 +08:00
// tempChnResult.push(CheckData.ChnCheckResultEnum.TIMEOUT)
2025-01-07 11:19:33 +08:00
// //errorCheckItem.push({scriptType,type:'warning'})
// }
// } else {
// for (let i = 0; i < item.chnNum; i++) {
// tempChnResult.push(CheckData.ChnCheckResultEnum.ERRORDATA)
// //errorCheckItem.push({scriptType,type:'warning'})
// }
// }
//
// return {
// deviceId: item.deviceId,
// deviceName: item.deviceName,
// chnResult: tempChnResult,
// }
// })
// } else {
2025-01-07 14:54:44 +08:00
devices = deviceList.map(item => {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
// if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
// for (let i = 0; i < item.chnNum; i++) {
2025-01-08 21:02:36 +08:00
// tempChnResult.push(CheckData.ChnCheckResultEnum.TIMEOUT)
2025-01-07 14:54:44 +08:00
// //errorCheckItem.push({scriptType,type:'warning'})
// }
// } else {
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.SUCCESS)
}
let randomNum = getRandomInt(item.chnNum * 2)
if (randomNum < item.chnNum && activeIndex >= 4 && activeIndex <= 8) {
tempChnResult[randomNum] = CheckData.ChnCheckResultEnum.FAIL
2025-01-09 11:13:34 +08:00
errorCheckItem.push({scriptType, type: CheckData.ChnCheckResultEnum.FAIL})
2025-01-07 14:54:44 +08:00
}
// }
2025-01-07 14:54:44 +08:00
return {
deviceId: item.deviceId,
deviceName: item.deviceName,
chnResult: tempChnResult,
}
})
2025-01-07 11:19:33 +08:00
// }
2024-11-20 21:30:05 +08:00
let tempScriptChnItem: CheckData.ScriptChnItem = {
scriptType,
devices,
}
return tempScriptChnItem
}
2024-11-20 21:30:05 +08:00
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
2025-01-15 08:59:47 +08:00
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
}
2024-12-18 15:56:59 +08:00
// 点击查看设备通道检测详情。参数1设备信息参数2通道号-1代表查看全部通道
2025-01-08 09:46:47 +08:00
const handleClick = (item: any, chnNum: number, scriptType: string) => {
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
let flag = -1
2025-01-08 09:46:47 +08:00
if (checkResultItem) {
let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
if (device) {
let chnResult = device.chnResult
if (chnNum === -1) {
2025-01-08 21:02:36 +08:00
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
2025-01-08 09:46:47 +08:00
flag = 0
}
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
flag = 1
}
} else {
2025-01-08 21:02:36 +08:00
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
2025-01-08 09:46:47 +08:00
flag = 0
}
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
flag = 1
}
}
}
}
2025-01-08 09:46:47 +08:00
if (flag === 0) {
2025-01-08 20:57:11 +08:00
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
confirmButtonText: '确定',
type: 'warning',
})
}
2025-01-10 09:20:32 +08:00
if (flag === -1 || flag === 1) {
2025-01-08 09:46:47 +08:00
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum + '', scriptType);
}
};
2024-12-26 10:49:55 +08:00
// todo 可移除
2024-11-25 21:11:10 +08:00
const startTimer = () => {
2024-12-27 10:31:15 +08:00
console.log('开始检测第' + activeIndex + '项')
switch (activeIndex) {
2025-01-03 18:57:35 +08:00
case 0:
setTimeout(() => {
2025-01-03 11:27:36 +08:00
emit('update:webMsgSend', {
requestId: 'yjc_ytxjy',
operateCode: "INIT_GATHER",
2025-01-07 19:03:00 +08:00
code: 10200
2025-01-03 11:27:36 +08:00
})
}, 2000)
2025-01-09 14:18:50 +08:00
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'yjc_sbtxjy',
// operateCode: 'INIT_GATHER$01',
// code: 10550,
// data: '240001'
// })
// }, 4000)
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'yjc_sbtxjy',
// operateCode: 'INIT_GATHER$01',
// code: 10550,
// data: '240004'
// })
// }, 6000)
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'error_flow_end',
// })
// }, 8000)
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'yjc_sbtxjy',
operateCode: "INIT_GATHER$01",
2025-01-07 19:03:00 +08:00
code: 25001
})
}, 4000);
setTimeout(() => {
emit('update:webMsgSend', {
2025-01-07 17:34:15 +08:00
requestId: 'yjc_xyjy',
2025-01-07 14:54:44 +08:00
operateCode: "INIT_GATHER$03",
2025-01-07 19:03:00 +08:00
code: 25001
})
2025-01-03 11:27:36 +08:00
}, 6000)
2025-01-03 18:57:35 +08:00
break;
case 1:
2025-01-15 08:59:47 +08:00
todoItem('V')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 2:
2025-01-15 08:59:47 +08:00
todoItem('I')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 3:
2025-01-15 08:59:47 +08:00
todoItem('IMBV')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 4:
2025-01-15 08:59:47 +08:00
todoItem('FREQ')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 5:
2025-01-15 08:59:47 +08:00
todoItem('HV')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 6:
2025-01-15 08:59:47 +08:00
todoItem('HI')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 7:
2025-01-15 08:59:47 +08:00
todoItem('HSV')
2024-12-26 10:49:55 +08:00
break;
2025-01-13 22:50:55 +08:00
case 8:
2025-01-15 08:59:47 +08:00
todoItem('HSI')
2024-12-26 10:49:55 +08:00
break;
// case 9:
// emit('update:webMsgSend', {
// requestId: 'I_Start'
// })
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'I_End'
// })
// }, 2000)
// break;
// case 10:
// emit('update:webMsgSend', {
// requestId: 'IMBV_Start'
// })
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'IMBV_End'
// })
// }, 2000)
// break;
// case 11:
// emit('update:webMsgSend', {
// requestId: 'IMBA_Start'
// })
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'IMBA_End'
// })
// }, 2000)
// break;
// case 12:
// emit('update:webMsgSend', {
// requestId: 'F_Start'
// })
// setTimeout(() => {
// emit('update:webMsgSend', {
// requestId: 'F_End'
// })
// }, 2000)
// break;
2025-01-15 08:59:47 +08:00
case 9:
2024-12-26 10:49:55 +08:00
emit('update:webMsgSend', {
requestId: 'Quit'
2024-12-26 10:49:55 +08:00
})
break;
2024-11-25 21:11:10 +08:00
}
};
2025-01-14 21:07:52 +08:00
const handlePause = () => {
emit('sendPause')
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`})
}
2024-11-25 21:11:10 +08:00
2025-01-14 21:07:52 +08:00
const pauseSuccessCallback = () => {
2025-01-03 11:27:36 +08:00
endData.value = new Date();
let diffTime = endData.value.getTime() - startData.value.getTime();
timeDifference.value += diffTime
testLogList.push({
type: 'info',
log: `${new Date().toLocaleString()}:暂停检测`,
})
2025-02-17 10:16:48 +08:00
stopTimeCount()
2025-01-03 11:27:36 +08:00
console.log('暂停中')
2024-12-30 14:41:34 +08:00
};
2024-12-26 10:49:55 +08:00
const todoItem = (code: string) => {
2025-01-15 08:59:47 +08:00
emit('update:webMsgSend', {
requestId: `${code}_Start`
})
setTimeout(() => {
if (testStatus.value !== 'paused') {
2025-01-15 08:59:47 +08:00
emit('update:webMsgSend', {
requestId: `${code}_Start`,
2025-02-25 16:18:22 +08:00
desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° '
2025-01-15 08:59:47 +08:00
})
}
}, 1000)
setTimeout(() => {
if (testStatus.value !== 'paused') {
emit('update:webMsgSend', {
requestId: `${code}_End`,
2025-02-25 16:18:22 +08:00
desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
2025-01-15 08:59:47 +08:00
data: [{
chnResult: [1, 1, 1, 1],
2025-02-26 19:02:43 +08:00
deviceId: "e90c09c0905248ad912e19e17a8672aa",
deviceName: "250226001"
2025-01-15 08:59:47 +08:00
}]
})
}
}, 2000)
setTimeout(() => {
if (testStatus.value !== 'paused') {
emit('update:webMsgSend', {
requestId: `${code}_Start`,
2025-02-25 16:18:22 +08:00
desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° '
2025-01-15 08:59:47 +08:00
})
}
}, 3000)
setTimeout(() => {
if (testStatus.value !== 'paused') {
emit('update:webMsgSend', {
requestId: `${code}_End`,
2025-02-25 16:18:22 +08:00
desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
2025-01-15 08:59:47 +08:00
data: [{
chnResult: [1, 1, 1, 1],
2025-02-26 19:02:43 +08:00
deviceId: "e90c09c0905248ad912e19e17a8672aa",
deviceName: "250226001"
2025-01-15 08:59:47 +08:00
}]
})
}
}, 5000)
setTimeout(() => {
if (testStatus.value !== 'paused') {
2025-01-15 08:59:47 +08:00
emit('update:webMsgSend', {
requestId: `${code}_Start`,
2025-02-25 16:18:22 +08:00
desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° '
2025-01-15 08:59:47 +08:00
})
}
}, 6000)
setTimeout(() => {
if (testStatus.value !== 'paused') {
2025-01-15 08:59:47 +08:00
emit('update:webMsgSend', {
requestId: `${code}_End`,
2025-02-25 16:18:22 +08:00
desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
2025-01-15 08:59:47 +08:00
data: [{
chnResult: [1, 1, 1, 1],
2025-02-26 19:02:43 +08:00
deviceId: "e90c09c0905248ad912e19e17a8672aa",
deviceName: "250226001"
2025-01-15 08:59:47 +08:00
}]
})
}
}, 8000)
setTimeout(() => {
if (testStatus.value !== 'paused') {
2025-01-15 08:59:47 +08:00
emit('update:webMsgSend', {
requestId: `${code}_End`,
data: [{
chnResult: [1, 2, 1, 1],
2025-02-26 19:02:43 +08:00
deviceId: "e90c09c0905248ad912e19e17a8672aa",
deviceName: "250226001"
2025-01-15 08:59:47 +08:00
}]
})
}
}, 9000)
}
2024-12-30 14:41:34 +08:00
const handleResumeTest = () => {
2025-01-14 16:21:50 +08:00
//activeIndex++
2025-01-03 11:27:36 +08:00
startData.value = new Date();
2025-02-26 10:00:44 +08:00
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!`})
2025-02-26 19:02:43 +08:00
//startTimer()
2025-02-17 10:16:48 +08:00
resumeTimeCount()
2025-01-03 11:27:36 +08:00
console.log('开始继续检测')
2024-12-30 14:41:34 +08:00
};
2024-11-25 21:11:10 +08:00
2024-12-24 11:29:31 +08:00
const handleReCheck = () => {
initCheckResult()
activeIndex = 0
percentage.value = 0
timeCount.value = 0
timeView.value = '00:00:00'
timeDifference.value = 0
testLogList.length = 0
2025-02-26 10:00:44 +08:00
errorCheckItem.length = 0
count = 0
showTestLog()
2025-02-26 15:56:03 +08:00
//handleResumeTest()
}
2024-12-24 11:29:31 +08:00
2025-01-09 14:18:50 +08:00
// 获取当前执行的大测试项序号
const getActiveIndex = (code: string): number => {
for (let i = 0; i < scriptData.length; i++) {
if (scriptData[i].code === code) {
return i + 1
}
}
return -1
}
2025-01-03 18:57:35 +08:00
// 获取当前执行的大测试项序 的 下一个大测试项序号
const getNextActiveIndex = (code: string = ''): number => {
if (code === '') {
return -1
}
for (let i = 0; i < scriptData.length; i++) {
if (scriptData[i].code === code) {
return i + 2
}
}
return -1
}
2025-02-17 10:16:48 +08:00
const startTimeCount = () => {
2025-02-26 10:00:44 +08:00
if(!timer){
timer = setInterval(() => {
timeCount.value = timeCount.value + 1
timeView.value = secondToTime(timeCount.value)
}, 1000)
}
2025-02-17 10:16:48 +08:00
}
const stopTimeCount = () => {
if (timer) {
clearInterval(timer)
}
}
2025-01-03 18:57:35 +08:00
2025-02-17 10:16:48 +08:00
const resumeTimeCount = () => {
timer = setInterval(() => {
timeCount.value = timeCount.value + 1
timeView.value = secondToTime(timeCount.value)
}, 1000)
}
const secondToTime = (second: number) => {
//将秒数转换成时分秒
let h: string | number = Math.floor(second / 3600)
let m: string | number = Math.floor((second - h * 3600) / 60)
let s: string | number = Math.floor(second % 60);
h = h < 10 ? '0' + h : h;
m = m < 10 ? '0' + m : m;
s = s < 10 ? '0' + s : s;
return h + ':' + m + ':' + s;
}
onBeforeUnmount(() => {
if (timer) {
clearInterval(timer)
}
})
2024-11-25 21:11:10 +08:00
</script>
2024-11-25 21:11:10 +08:00
<style scoped lang="scss">
2024-12-18 15:56:59 +08:00
2024-12-05 21:33:52 +08:00
:deep(.el-table .header-row) {
2024-11-25 21:11:10 +08:00
// background-color:var(--el-color-warning-light-9);
2024-12-18 18:53:55 +08:00
background-color: #f5f7fa;
2024-11-25 21:11:10 +08:00
// color:red;
// font-size:30px;
// --el-table-tr-bg-color: var(--el-color-warning-light-9);
}
2024-12-18 18:53:55 +08:00
2024-12-05 21:33:52 +08:00
:deep(.el-table .warning-row) {
// background-color:var(--el-color-warning-light-9);
//background-color:#bed96557;
2024-12-18 18:53:55 +08:00
color: red;
2024-12-05 21:33:52 +08:00
// font-size:30px;
// --el-table-tr-bg-color: var(--el-color-warning-light-9);
2024-12-06 15:06:38 +08:00
// background-color:#f5f7fa;
// position: relative;
2024-12-05 21:33:52 +08:00
}
2024-12-06 15:06:38 +08:00
// :deep(.el-table .warning-row::before) {
// content: '*'; /* 必须设置content属性 */
// position: absolute;
// color:red;
// background-color:#f5f7fa;
// }
2024-11-25 21:11:10 +08:00
.el-table .success-row {
--el-table-tr-bg-color: var(--el-color-success-light-9);
}
2024-12-18 18:53:55 +08:00
.dialog {
display: flex;
flex-direction: column;
2024-12-18 20:26:18 +08:00
overflow-y: hidden;
overflow-x: hidden;
2024-11-25 21:11:10 +08:00
}
2024-12-18 18:53:55 +08:00
.dialog-title {
2025-02-19 13:17:19 +08:00
2024-12-18 18:53:55 +08:00
display: flex;
justify-content: space-between;
align-items: center;
margin-right: 10px;
margin-bottom: 10px;
2025-02-19 13:17:19 +08:00
.timeView {
2025-02-20 15:01:15 +08:00
display: flex;
align-items: center;
2025-02-19 13:17:19 +08:00
color: #67c23a;;
2025-02-20 15:01:15 +08:00
width: 28%;
2025-02-19 13:17:19 +08:00
margin-right: 0px;
text-align: left;
font-size: 26px;
font-weight: bold;
}
2024-11-25 21:11:10 +08:00
}
2024-12-11 19:12:04 +08:00
2024-12-18 18:53:55 +08:00
.dialog-content {
2024-12-05 15:22:46 +08:00
max-height: 450px;
2024-12-18 20:26:18 +08:00
overflow-y: hidden;
2024-11-25 21:11:10 +08:00
}
2024-12-18 18:53:55 +08:00
:deep(.el-collapse-item__header) {
height: 30px;
}
2024-12-11 19:12:04 +08:00
2024-12-18 18:53:55 +08:00
.dialog-log {
2024-12-11 19:12:04 +08:00
height: 50px;
2024-12-18 20:26:18 +08:00
overflow-y: hidden;
2024-11-25 21:11:10 +08:00
// flex-grow: 1;
// display: flex;
// flex-direction: column-reverse;
2024-12-11 19:12:04 +08:00
p {
margin: 5px 0;
font-size: 14px;
}
}
2024-12-26 10:49:55 +08:00
.drawer-container {
:deep(header.el-drawer__header) {
2024-12-24 19:21:43 +08:00
color: #fff !important;
background-color: #003078 !important;
.el-drawer__close-btn svg:hover {
color: #ccc !important;
}
2024-12-26 10:49:55 +08:00
.el-drawer__title {
2024-12-24 19:21:43 +08:00
color: #fff !important;
}
}
}
2024-12-27 10:31:15 +08:00
.loading-box {
animation: loading 1.5s linear infinite;
2024-12-26 10:49:55 +08:00
}
2024-12-27 10:31:15 +08:00
@keyframes loading {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
2024-12-24 19:21:43 +08:00
//:deep(.el-drawer .el-drawer__title){
// background-color: #003078 !important;
//}
2024-11-21 23:02:43 +08:00
</style>
2024-12-18 20:26:18 +08:00
2024-12-05 15:22:46 +08:00
<style lang="scss" scoped>
:deep(.el-button--small) {
2024-12-18 18:53:55 +08:00
height: 20px !important;
width: 20px !important;
2024-12-05 15:22:46 +08:00
}
2024-12-18 18:53:55 +08:00
:deep(.el-table--default td ) {
2024-12-05 15:22:46 +08:00
padding: 5px 0 !important;
}
2024-12-20 10:21:36 +08:00
2024-12-24 19:21:43 +08:00
2024-12-05 15:22:46 +08:00
</style>