2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 检测测试主界面组件 -->
|
2024-11-18 22:04:59 +08:00
|
|
|
|
<template>
|
2025-02-25 10:17:33 +08:00
|
|
|
|
<div>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 主检测界面 -->
|
|
|
|
|
|
<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>
|
2025-02-25 10:17:33 +08:00
|
|
|
|
<span>检测用时:{{ timeView }}</span>
|
|
|
|
|
|
</div>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 检测进度条 -->
|
2025-02-25 10:17:33 +08:00
|
|
|
|
<el-progress
|
2025-08-11 16:30:53 +08:00
|
|
|
|
style='width: 82%; margin-right: 3%;'
|
|
|
|
|
|
:percentage='percentage'
|
|
|
|
|
|
:color='customColors' />
|
|
|
|
|
|
<!-- 检测项进度按钮 -->
|
|
|
|
|
|
<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
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 检测结果表格内容区 -->
|
|
|
|
|
|
<div class='dialog-content'>
|
|
|
|
|
|
<!-- 检测结果表格 -->
|
|
|
|
|
|
<el-table :data='checkResultView' row-key='scriptType' height='450px'
|
|
|
|
|
|
:header-cell-style="{ background: 'var(--el-color-primary)', color: '#eee', textAlign: 'center' } "
|
|
|
|
|
|
style='width: 100%'
|
2025-02-25 10:17:33 +08:00
|
|
|
|
border>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 固定列:检测项目名称 -->
|
|
|
|
|
|
<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
|
|
|
|
|
2025-08-11 16:30:53 +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}'>
|
|
|
|
|
|
<!-- 通道状态提示 -->
|
2025-05-23 10:15:05 +08:00
|
|
|
|
<el-tooltip
|
2025-08-11 16:30:53 +08:00
|
|
|
|
:content="row.devices[index1].chnResult[index2].icon==='More'?'暂无数据'
|
|
|
|
|
|
:row.devices[index1].chnResult[index2].icon==='CircleCheckFilled'?'符合'
|
|
|
|
|
|
:row.devices[index1].chnResult[index2].icon==='Close'?'不符合'
|
|
|
|
|
|
:row.devices[index1].chnResult[index2].icon==='WarnTriangleFilled'?'数据异常'
|
|
|
|
|
|
:row.devices[index1].chnResult[index2].icon==='Loading'?'检测中':'连接中断'"
|
|
|
|
|
|
placement='right'>
|
|
|
|
|
|
<!-- 通道状态按钮 -->
|
2025-02-25 10:17:33 +08:00
|
|
|
|
<el-button
|
2025-08-11 16:30:53 +08:00
|
|
|
|
: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;'
|
2025-02-25 10:17:33 +08:00
|
|
|
|
>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 加载状态图标 -->
|
|
|
|
|
|
<el-icon v-if="row.devices[index1].chnResult[index2].icon==='Loading'" class='loading-box'
|
|
|
|
|
|
style='color: #fff'>
|
|
|
|
|
|
<component :is='Loading' />
|
2025-02-25 10:17:33 +08:00
|
|
|
|
</el-icon>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 其他状态图标 -->
|
|
|
|
|
|
<el-icon v-else style='color: #fff'>
|
|
|
|
|
|
<component :is='row.devices[index1].chnResult[index2].icon' />
|
2025-02-25 10:17:33 +08:00
|
|
|
|
</el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
2025-05-23 10:15:05 +08:00
|
|
|
|
</el-tooltip>
|
2025-02-25 10:17:33 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</el-table>
|
2024-12-24 19:21:43 +08:00
|
|
|
|
</div>
|
2024-12-20 10:21:36 +08:00
|
|
|
|
|
2025-02-25 10:17:33 +08:00
|
|
|
|
</div>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 检测日志抽屉容器 -->
|
|
|
|
|
|
<div class='drawer-container'>
|
|
|
|
|
|
<!-- 从下往上弹出的检测日志抽屉 -->
|
|
|
|
|
|
<el-drawer v-model='drawer' title='检测项进度' direction='btt' :size="'38%'">
|
|
|
|
|
|
<!-- 日志内容滚动容器 -->
|
|
|
|
|
|
<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 />
|
2025-02-25 10:17:33 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-drawer>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- 单通道单测试项详情弹窗 -->
|
|
|
|
|
|
<dataCheckSingleChannelSingleTestPopup ref='dataCheckSingleChannelSingleTestPopupRef' />
|
2025-02-25 10:17:33 +08:00
|
|
|
|
</div>
|
2024-11-18 22:04:59 +08:00
|
|
|
|
</template>
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<script lang='tsx' setup name='test'>
|
|
|
|
|
|
// Element Plus 图标导入
|
|
|
|
|
|
import { InfoFilled, Loading } from '@element-plus/icons-vue'
|
|
|
|
|
|
// 单通道单测试项详情弹窗组件
|
2024-11-19 19:34:00 +08:00
|
|
|
|
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// Vue 3 Composition API
|
|
|
|
|
|
import { computed, reactive, ref, toRef, watch } from 'vue'
|
|
|
|
|
|
// 对话框大小绑定工具
|
|
|
|
|
|
import { dialogBig } from '@/utils/elementBind'
|
|
|
|
|
|
// 检测数据类型定义
|
|
|
|
|
|
import { CheckData } from '@/api/check/interface'
|
|
|
|
|
|
// 检测相关状态管理
|
|
|
|
|
|
import { useCheckStore } from '@/stores/modules/check'
|
|
|
|
|
|
// Element Plus 消息组件
|
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
|
// 检测相关API
|
|
|
|
|
|
import { getBigTestItem } from '@/api/check/test'
|
|
|
|
|
|
import { getAutoGenerate } from '@/api/user/login'
|
|
|
|
|
|
import { generateDevReport } from '@/api/plan/plan'
|
2025-08-15 08:37:35 +08:00
|
|
|
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
|
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取检测状态管理实例
|
2024-12-20 18:19:18 +08:00
|
|
|
|
const checkStore = useCheckStore()
|
2025-08-15 08:37:35 +08:00
|
|
|
|
const modeStore = useModeStore()
|
|
|
|
|
|
const dictStore = useDictStore()
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 最大通道数限制,超过此数量将使用汇总显示
|
2025-02-11 09:10:50 +08:00
|
|
|
|
const MAX_CHN_SUM = 12
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
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
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 组件属性定义
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const props = defineProps({
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 测试状态:waiting/start/process/paused/success等
|
2024-12-24 11:29:31 +08:00
|
|
|
|
testStatus: {
|
|
|
|
|
|
type: String,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
default: 'waiting',
|
2024-12-24 11:29:31 +08:00
|
|
|
|
},
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 当前步骤索引
|
2025-02-26 19:31:34 +08:00
|
|
|
|
stepsActive: {
|
|
|
|
|
|
type: Number,
|
|
|
|
|
|
},
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// WebSocket消息数据
|
2024-12-24 11:29:31 +08:00
|
|
|
|
webMsgSend: {
|
|
|
|
|
|
type: Object,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
default: () => ({}),
|
|
|
|
|
|
},
|
2024-12-24 11:29:31 +08:00
|
|
|
|
})
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 定义向父组件发送的事件
|
|
|
|
|
|
const emit = defineEmits(['update:testStatus', 'update:webMsgSend', 'sendPause', 'sendResume', 'closeWebSocket'])
|
2024-12-24 11:29:31 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 界面状态相关 ==========
|
|
|
|
|
|
// 测试项进度抽屉是否打开
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const drawer = ref(false)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 进度条颜色配置
|
|
|
|
|
|
const customColors = [{ color: '#91cc75', percentage: 100 }]
|
|
|
|
|
|
|
|
|
|
|
|
// ========== 检测数据相关 ==========
|
|
|
|
|
|
// 检测脚本配置数据
|
2024-12-30 20:55:11 +08:00
|
|
|
|
let scriptData: CheckData.ScriptItem[] = []
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 被检测的设备列表
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const deviceList = reactive<CheckData.Device[]>([])
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 当前正在执行的测试项索引
|
2025-01-03 18:57:35 +08:00
|
|
|
|
let activeIndex = 0
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 检测进度百分比
|
|
|
|
|
|
const percentage = ref(0)
|
|
|
|
|
|
|
|
|
|
|
|
// ========== 时间计算相关 ==========
|
|
|
|
|
|
// 定时器实例
|
2025-02-17 10:16:48 +08:00
|
|
|
|
let timer: any = null
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 总计时秒数
|
2025-02-17 10:16:48 +08:00
|
|
|
|
const timeCount = ref(0)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 格式化的时间显示(HH:MM:SS)
|
2025-02-17 10:16:48 +08:00
|
|
|
|
const timeView = ref('00:00:00')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 测试项开始检测时间(或继续检测时间)
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const startData = ref(new Date())
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 测试项检测结束时间(或暂停时的时间)
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const endData = ref(new Date())
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 累计时间差(毫秒)
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const timeDifference = ref(0)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// ========== 检测结果相关 ==========
|
|
|
|
|
|
// 详细检测结果数据(详细到每个设备的每个通道)
|
2024-12-24 19:21:43 +08:00
|
|
|
|
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 存储检测失败的测试项信息(只要有一个通道不合格,该测试项就被记录)
|
2025-01-09 11:13:34 +08:00
|
|
|
|
let errorCheckItem: Array<{ scriptType: string, type: CheckData.ChnCheckResultEnum }> = []
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 检测日志列表
|
|
|
|
|
|
const testLogList = reactive<CheckData.LogItem[]>([{ type: 'info', log: '暂无数据,等待检测开始' }])
|
2024-11-18 22:04:59 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 响应式引用 ==========
|
|
|
|
|
|
// 将props转为ref,便于watch监听
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const testStatus = toRef(props, 'testStatus')
|
|
|
|
|
|
const webMsgSend = toRef(props, 'webMsgSend')
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== DOM引用 ==========
|
|
|
|
|
|
// 日志滚动容器引用
|
|
|
|
|
|
const scrollContainerRef = ref()
|
|
|
|
|
|
// 单通道单测试项详情弹窗组件引用
|
2024-12-24 19:21:43 +08:00
|
|
|
|
const dataCheckSingleChannelSingleTestPopupRef = ref<InstanceType<typeof dataCheckSingleChannelSingleTestPopup>>()
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 计算属性 ==========
|
|
|
|
|
|
// 计算所有设备的总通道数
|
2024-12-18 15:56:59 +08:00
|
|
|
|
const chnSum = computed(() => {
|
|
|
|
|
|
let sum = 0
|
2024-12-20 18:19:18 +08:00
|
|
|
|
deviceList.forEach((item) => {
|
2024-12-18 15:56:59 +08:00
|
|
|
|
sum += item.chnNum
|
|
|
|
|
|
})
|
|
|
|
|
|
return sum
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-11 16:30:53 +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 = {
|
2025-01-02 18:00:58 +08:00
|
|
|
|
scriptType: item.scriptType,
|
2024-12-25 18:04:16 +08:00
|
|
|
|
scriptName: item.scriptName,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
devices: [],
|
2024-12-24 19:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 遍历每个设备,生成对应的按钮显示数据
|
2024-12-24 19:21:43 +08:00
|
|
|
|
item.devices.forEach(device => {
|
|
|
|
|
|
let tempChnBtnResult: CheckData.ButtonResult[] = []
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 只有在总通道数不超过最大限制时,才显示详细通道
|
2024-12-24 19:21:43 +08:00
|
|
|
|
if (chnSum.value <= MAX_CHN_SUM) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 为每个通道生成对应的按钮配置(颜色+图标)
|
2024-12-24 19:21:43 +08:00
|
|
|
|
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:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.INFO, icon: 'More' })
|
|
|
|
|
|
break
|
2024-12-26 10:49:55 +08:00
|
|
|
|
case CheckData.ChnCheckResultEnum.LOADING:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.LOADING, icon: 'Loading' })
|
|
|
|
|
|
break
|
2024-12-26 10:49:55 +08:00
|
|
|
|
case CheckData.ChnCheckResultEnum.SUCCESS:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.SUCCESS, icon: 'CircleCheckFilled' })
|
|
|
|
|
|
break
|
2024-12-27 10:31:15 +08:00
|
|
|
|
case CheckData.ChnCheckResultEnum.FAIL:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.DANGER, icon: 'Close' })
|
|
|
|
|
|
break
|
2025-01-08 20:57:11 +08:00
|
|
|
|
case CheckData.ChnCheckResultEnum.TIMEOUT:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.WARNING, icon: 'Link' })
|
|
|
|
|
|
break
|
2024-12-27 10:31:15 +08:00
|
|
|
|
case CheckData.ChnCheckResultEnum.ERRORDATA:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.WARNING, icon: 'WarnTriangleFilled' })
|
|
|
|
|
|
break
|
2025-03-24 15:41:53 +08:00
|
|
|
|
case CheckData.ChnCheckResultEnum.NOT_PART_IN_ERROR:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
tempChnBtnResult.push({ color: CheckData.ButtonColorEnum.INFO, icon: 'Minus' })
|
|
|
|
|
|
break
|
2024-12-26 10:49:55 +08:00
|
|
|
|
default:
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2024-12-24 19:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
temp.devices.push({
|
|
|
|
|
|
deviceId: device.deviceId,
|
|
|
|
|
|
deviceName: device.deviceName,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
chnResult: tempChnBtnResult,
|
2024-12-24 19:21:43 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
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
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 监听器 ==========
|
|
|
|
|
|
// 监听测试状态变化
|
|
|
|
|
|
watch(testStatus, function(newValue, oldValue) {
|
|
|
|
|
|
// 开始测试
|
2024-12-24 11:29:31 +08:00
|
|
|
|
if (newValue == 'start') {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 根据测试项配置决定是否需要初始化
|
2025-06-25 09:21:58 +08:00
|
|
|
|
if (!checkStore.selectTestItems.preTest && !checkStore.selectTestItems.channelsTest) {
|
2025-06-24 09:22:36 +08:00
|
|
|
|
ElMessage.success('初始化开始!')
|
|
|
|
|
|
emit('update:testStatus', 'test_init')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:初始化开始!` })
|
2025-06-26 13:17:11 +08:00
|
|
|
|
} else {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 直接进入检测流程
|
2025-06-26 13:17:11 +08:00
|
|
|
|
emit('update:testStatus', 'process')
|
2025-06-24 09:22:36 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 开始计时
|
2025-02-17 10:16:48 +08:00
|
|
|
|
startTimeCount()
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 显示测试日志抽屉
|
2025-01-08 20:57:11 +08:00
|
|
|
|
showTestLog()
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 重置时间记录
|
|
|
|
|
|
startData.value = new Date()
|
|
|
|
|
|
timeDifference.value = 0
|
2024-12-24 11:29:31 +08:00
|
|
|
|
}
|
2025-02-26 10:00:44 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +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
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 防重复处理计数器
|
2025-01-23 09:33:00 +08:00
|
|
|
|
let count = 0
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 监听WebSocket消息变化,处理各种检测状态和错误
|
|
|
|
|
|
watch(webMsgSend, function(newValue, oldValue) {
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 只在非等待状态下处理消息
|
2025-04-14 13:22:46 +08:00
|
|
|
|
if (testStatus.value !== 'waiting') {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 步骤4:正式检测阶段的消息处理
|
2025-04-14 13:22:46 +08:00
|
|
|
|
if (props.stepsActive === 4) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 初始化错误码处理 ==========
|
2025-04-14 13:22:46 +08:00
|
|
|
|
if (newValue.code == 10520) {
|
|
|
|
|
|
ElMessageBox.alert('报文解析异常!', '初始化失败', {
|
2025-01-09 14:18:50 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:报文解析异常!` })
|
2025-01-09 14:18:50 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
2025-04-14 13:22:46 +08:00
|
|
|
|
} else if (newValue.code == 10521) {
|
|
|
|
|
|
ElMessageBox.alert('程控源參数有误!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:程控源參数有误!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10522) {
|
|
|
|
|
|
ElMessageBox.alert('测试项解析有误!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:测试项解析有误!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10523) {
|
|
|
|
|
|
if (count === 0) {
|
|
|
|
|
|
ElMessageBox.alert('源连接失败!', '初始化失败', {
|
2025-02-26 19:31:34 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:源连接失败!` })
|
2025-02-26 19:31:34 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
2025-04-14 13:22:46 +08:00
|
|
|
|
count++
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (newValue.code == 10524) {
|
|
|
|
|
|
ElMessageBox.alert('获取源控制权失败!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:获取源控制权失败!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10525) {
|
|
|
|
|
|
ElMessageBox.alert('重置源失败!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:重置源失败!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10527) {
|
|
|
|
|
|
ElMessageBox.alert('源未进行初始化!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:源未进行初始化!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10528) {
|
|
|
|
|
|
ElMessageBox.alert('目标源有误(该用户已控制其他源,在关闭前无法操作新的源)!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
log: `${new Date().toLocaleString()}:目标源有误(该用户已控制其他源,在关闭前无法操作新的源)!`,
|
|
|
|
|
|
})
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10529) {
|
|
|
|
|
|
ElMessageBox.alert('源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
log: `${new Date().toLocaleString()}:源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)!`,
|
|
|
|
|
|
})
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10550) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:${newValue.data}设备连接异常!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else if (newValue.code == 10551) {
|
|
|
|
|
|
ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:${newValue.data}设备触发报告异常!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
} else if (newValue.code == 10552) {
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'error',
|
2025-08-11 16:30:53 +08:00
|
|
|
|
log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!`,
|
2025-04-14 13:22:46 +08:00
|
|
|
|
})
|
|
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
} else {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 根据请求ID处理不同类型的消息 ==========
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.requestId) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 服务端错误
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'server_error':
|
|
|
|
|
|
if (newValue.operateCode === 'server_error' && count === 0) {
|
2025-05-12 14:38:25 +08:00
|
|
|
|
ElMessageBox.alert('服务端主动关闭连接!', '初始化失败', {
|
2025-02-26 19:31:34 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:服务端主动关闭连接!` })
|
2025-05-26 14:41:06 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
count++
|
|
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 设备端错误
|
2025-05-26 14:41:06 +08:00
|
|
|
|
case 'device_error':
|
|
|
|
|
|
if (newValue.operateCode === 'device_error' && count === 0) {
|
|
|
|
|
|
ElMessageBox.alert('设备端主动关闭连接!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:设备端主动关闭连接!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
count++
|
|
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 正式测试相关消息
|
|
|
|
|
|
case 'formal_real':
|
2025-04-14 13:22:46 +08:00
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
case 'stop_timeout':
|
2025-04-14 13:22:46 +08:00
|
|
|
|
ElMessageBox.alert(`暂停时间已过10分钟,本次检测已失效,请重新发起检测!`, '暂停时间过长', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
emit('update:testStatus', 'pause_timeout')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'error_flow_end':
|
2025-08-15 16:22:58 +08:00
|
|
|
|
ElMessageBox.alert(`当前流程存在异常结束!`, '初始化失败', {
|
2025-04-14 13:22:46 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'socket_timeout':
|
2025-08-11 16:30:53 +08:00
|
|
|
|
ElMessageBox.alert('连接超时!', '连接超时', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
emit('update:testStatus', 'connect_timeout')
|
|
|
|
|
|
break
|
2025-02-27 08:48:13 +08:00
|
|
|
|
case 'connect':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
case 'Source':
|
2025-02-27 08:48:13 +08:00
|
|
|
|
ElMessageBox.alert('源通讯失败,请检查源连接情况!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:源通讯失败!` })
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'Dev':
|
2025-02-27 08:48:13 +08:00
|
|
|
|
ElMessageBox.alert('设备通讯失败,请检查设备连接情况!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:设备通讯失败!` })
|
|
|
|
|
|
break
|
2025-02-27 08:48:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 源通信校验阶段
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'yjc_ytxjy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'INIT_GATHER':
|
|
|
|
|
|
if (newValue.code == 10200) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:源初始化成功!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
percentage.value = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
if (newValue.code == -1) {
|
|
|
|
|
|
ElMessageBox.alert('源未知异常!', '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:源未知异常!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
|
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 设备通信校验阶段
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'yjc_sbtxjy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'INIT_GATHER$01':
|
|
|
|
|
|
if (newValue.code == 25001) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:设备通讯校验成功!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
percentage.value = 2
|
|
|
|
|
|
}
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 协议校验阶段
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'yjc_xyjy':
|
|
|
|
|
|
switch (newValue.operateCode) {
|
|
|
|
|
|
case 'VERIFY_MAPPING$01':
|
|
|
|
|
|
if (newValue.code == 25001) {
|
|
|
|
|
|
ElMessage.success('初始化成功!')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:协议校验成功!` })
|
|
|
|
|
|
timeDifference.value = +new Date().getTime() - startData.value.getTime()
|
|
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:初始化成功!` })
|
2025-04-14 13:22:46 +08:00
|
|
|
|
percentage.value = 3
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 初始化完成,准备开始正式检测
|
2025-04-14 13:22:46 +08:00
|
|
|
|
activeIndex = getNextActiveIndex() + 2
|
|
|
|
|
|
emit('update:testStatus', 'process')
|
2025-08-11 16:30:53 +08:00
|
|
|
|
} else if (newValue.code == 25002) {
|
2025-04-14 13:22:46 +08:00
|
|
|
|
let data = JSON.parse(newValue.data)
|
|
|
|
|
|
ElMessageBox.alert(`脚本与icd校验失败!icd名称:${data['icdType']} -> 校验项:${data['dataType']}`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'error',
|
2025-08-11 16:30:53 +08:00
|
|
|
|
log: `${new Date().toLocaleString()}:脚本与icd校验失败!icd名称:${data['icdType']} -> 校验项:${data['dataType']}`,
|
2025-04-14 13:22:46 +08:00
|
|
|
|
})
|
|
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
2025-05-26 14:41:06 +08:00
|
|
|
|
} else if (newValue.code == 10500) {
|
2025-05-22 18:43:33 +08:00
|
|
|
|
ElMessageBox.alert(`装置中未找到该icd!`, '初始化失败', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'error',
|
2025-08-11 16:30:53 +08:00
|
|
|
|
log: `${new Date().toLocaleString()}:装置中未找到该icd!`,
|
2025-05-22 18:43:33 +08:00
|
|
|
|
})
|
|
|
|
|
|
emit('update:testStatus', 'test_init_fail')
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 暂停测试成功
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'preStopTest':
|
|
|
|
|
|
if (newValue.operateCode == 'stop') {
|
|
|
|
|
|
ElMessage.success('暂停成功')
|
|
|
|
|
|
emit('update:testStatus', 'paused')
|
|
|
|
|
|
pauseSuccessCallback()
|
|
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 继续测试成功
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'Resume_Success':
|
|
|
|
|
|
ElMessage.success('开始继续检测')
|
|
|
|
|
|
emit('update:testStatus', 'process')
|
|
|
|
|
|
handleResumeTest()
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// ========== 各类检测项的开始和结束消息处理 ==========
|
|
|
|
|
|
// 频率检测
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'FREQ_Start':
|
|
|
|
|
|
handleStartItem('FREQ', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'FREQ_End':
|
|
|
|
|
|
handleEndItem('FREQ', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'V_Start':
|
|
|
|
|
|
handleStartItem('V', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'V_End':
|
|
|
|
|
|
handleEndItem('V', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-08-28 10:37:50 +08:00
|
|
|
|
case 'P_Start':
|
|
|
|
|
|
handleStartItem('P', newValue.desc)
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'P_End':
|
|
|
|
|
|
handleEndItem('P', newValue.desc, newValue.data)
|
|
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HV_Start':
|
|
|
|
|
|
handleStartItem('HV', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HV_End':
|
|
|
|
|
|
handleEndItem('HV', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HI_Start':
|
|
|
|
|
|
handleStartItem('HI', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HI_End':
|
|
|
|
|
|
handleEndItem('HI', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HP_Start':
|
|
|
|
|
|
handleStartItem('HP', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HP_End':
|
|
|
|
|
|
handleEndItem('HP', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HSV_Start':
|
|
|
|
|
|
handleStartItem('HSV', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HSV_End':
|
|
|
|
|
|
handleEndItem('HSV', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HSI_Start':
|
|
|
|
|
|
handleStartItem('HSI', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'HSI_End':
|
|
|
|
|
|
handleEndItem('HSI', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'VOLTAGE_Start':
|
|
|
|
|
|
handleStartItem('VOLTAGE', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'VOLTAGE_End':
|
|
|
|
|
|
handleEndItem('VOLTAGE', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'I_Start':
|
|
|
|
|
|
handleStartItem('I', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'I_End':
|
|
|
|
|
|
handleEndItem('I', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'IMBV_Start':
|
|
|
|
|
|
handleStartItem('IMBV', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'IMBV_End':
|
|
|
|
|
|
handleEndItem('IMBV', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'IMBA_Start':
|
|
|
|
|
|
handleStartItem('IMBA', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'IMBA_End':
|
|
|
|
|
|
handleEndItem('IMBA', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'F_Start':
|
|
|
|
|
|
handleStartItem('F', newValue.desc)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'F_End':
|
|
|
|
|
|
handleEndItem('F', newValue.desc, newValue.data)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
|
|
|
|
|
// 检测结束
|
2025-04-14 13:22:46 +08:00
|
|
|
|
case 'Quit':
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
break
|
2025-04-14 13:22:46 +08:00
|
|
|
|
}
|
2025-02-26 19:31:34 +08:00
|
|
|
|
}
|
2024-12-24 11:29:31 +08:00
|
|
|
|
}
|
2024-12-27 10:31:15 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
}, { deep: true })
|
2024-12-24 11:29:31 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 检测项处理函数 ==========
|
|
|
|
|
|
// 处理检测项开始消息
|
2025-01-20 15:24:29 +08:00
|
|
|
|
const handleStartItem = (code: string, desc: string | undefined) => {
|
2025-01-15 08:59:47 +08:00
|
|
|
|
if (desc === undefined) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 大测试项开始
|
2025-01-15 08:59:47 +08:00
|
|
|
|
activeIndex = getActiveIndex(code)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
updateCheckResultView(code, true) // 更新界面为加载状态
|
|
|
|
|
|
updateLog(true) // 记录开始日志
|
2025-01-15 08:59:47 +08:00
|
|
|
|
} else {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 子测试项开始
|
|
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:${desc}准确度检测:开始` })
|
2025-01-15 08:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 处理检测项结束消息
|
2025-01-20 15:24:29 +08:00
|
|
|
|
const handleEndItem = (code: string, desc: string | undefined, devices: CheckData.DeviceCheckResult[] = []) => {
|
2025-01-15 08:59:47 +08:00
|
|
|
|
if (desc === undefined) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 大测试项结束
|
|
|
|
|
|
updatePercentage() // 更新进度
|
|
|
|
|
|
updateCheckResultView(code, false, devices) // 更新检测结果
|
|
|
|
|
|
updateLog(false) // 记录结束日志
|
2025-01-15 08:59:47 +08:00
|
|
|
|
if (testStatus.value != 'paused') {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 如果未暂停,继续下一个测试项
|
2025-01-15 08:59:47 +08:00
|
|
|
|
activeIndex = getNextActiveIndex(code)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 子测试项结束,根据结果记录不同类型的日志
|
2025-01-15 08:59:47 +08:00
|
|
|
|
let result = getResult(devices)
|
2025-01-20 15:24:29 +08:00
|
|
|
|
if (result === 1) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:${desc}检测结束:符合` })
|
2025-01-15 08:59:47 +08:00
|
|
|
|
}
|
2025-01-20 15:24:29 +08:00
|
|
|
|
if (result === 2) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'error', log: `${new Date().toLocaleString()}:${desc}检测结束:不符合` })
|
2025-01-15 08:59:47 +08:00
|
|
|
|
}
|
2025-01-20 15:24:29 +08:00
|
|
|
|
if (result === 4) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({ type: 'warning', log: `${new Date().toLocaleString()}:${desc}检测结束:数据异常` })
|
2025-01-15 08:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-13 21:06:24 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 更新检测进度
|
2025-03-27 15:54:27 +08:00
|
|
|
|
const updatePercentage = async () => {
|
2024-12-27 10:31:15 +08:00
|
|
|
|
if (activeIndex < checkTotal) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 计算并更新进度百分比
|
|
|
|
|
|
percentage.value = Math.trunc(activeIndex / checkTotal * 100)
|
2024-12-24 11:29:31 +08:00
|
|
|
|
} else {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 所有检测项完成
|
|
|
|
|
|
percentage.value = 100
|
2025-08-12 10:26:30 +08:00
|
|
|
|
// 先完成所有后续操作,再emit success
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 检查是否需要自动生成报告
|
|
|
|
|
|
let { data: autoGenerate } = await getAutoGenerate()
|
|
|
|
|
|
if (autoGenerate == 1) {
|
|
|
|
|
|
// 自动生成报告
|
|
|
|
|
|
let devIdList = checkStore.devices.map(item => {
|
|
|
|
|
|
return item.deviceId
|
|
|
|
|
|
})
|
|
|
|
|
|
await generateDevReport({
|
|
|
|
|
|
'planId': checkStore.plan.id,
|
|
|
|
|
|
'devIdList': devIdList,
|
|
|
|
|
|
'scriptId': checkStore.plan.scriptId,
|
|
|
|
|
|
'planCode': checkStore.plan.code + '',
|
|
|
|
|
|
'pageNum': 1,
|
|
|
|
|
|
'pageSize': 999,
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// 提示检测完成
|
|
|
|
|
|
await ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
2025-05-16 10:33:43 +08:00
|
|
|
|
})
|
2025-08-12 10:26:30 +08:00
|
|
|
|
// 关闭WebSocket连接
|
|
|
|
|
|
emit('closeWebSocket')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
// 最后才emit success,避免中断后续操作
|
|
|
|
|
|
emit('update:testStatus', 'success')
|
2025-03-27 15:54:27 +08:00
|
|
|
|
}
|
2024-12-24 11:29:31 +08:00
|
|
|
|
}
|
2024-12-27 10:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 生命周期钩子 ==========
|
|
|
|
|
|
// 组件挂载前初始化数据
|
2024-12-30 20:55:11 +08:00
|
|
|
|
onBeforeMount(async () => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
await initScriptData() // 获取检测脚本配置
|
|
|
|
|
|
initDeviceList() // 初始化设备列表
|
|
|
|
|
|
initCheckResult() // 初始化检测结果数据结构
|
2024-12-20 10:19:58 +08:00
|
|
|
|
})
|
2024-12-13 08:56:42 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 界面交互函数 ==========
|
|
|
|
|
|
// 显示测试日志抽屉
|
2024-12-24 11:29:31 +08:00
|
|
|
|
const showTestLog = () => {
|
|
|
|
|
|
drawer.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 数据初始化函数 ==========
|
|
|
|
|
|
// 从服务器获取检测脚本配置数据
|
2024-12-30 20:55:11 +08:00
|
|
|
|
const initScriptData = async () => {
|
2025-08-15 08:37:35 +08:00
|
|
|
|
const pattern = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '';
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 根据复检类型、计划ID、设备ID列表获取测试项
|
|
|
|
|
|
let response: any = await getBigTestItem({
|
|
|
|
|
|
reCheckType: checkStore.reCheckType,
|
|
|
|
|
|
planId: checkStore.plan.id,
|
|
|
|
|
|
devIds: checkStore.devices.map(item => item.deviceId),
|
2025-08-15 08:37:35 +08:00
|
|
|
|
patternId: pattern
|
2025-08-11 16:30:53 +08:00
|
|
|
|
})
|
2024-12-30 20:55:11 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 格式化脚本数据
|
2025-07-24 16:30:19 +08:00
|
|
|
|
let temp = response.data.map((item: any) => {
|
2024-12-24 11:29:31 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...item,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
scriptName: item.scriptName,
|
2024-12-24 11:29:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 保存脚本数据并设置总数
|
2024-12-24 11:29:31 +08:00
|
|
|
|
scriptData.push(...temp)
|
2025-01-04 16:33:23 +08:00
|
|
|
|
checkTotal = scriptData.length
|
2024-12-20 10:19:58 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 从store中获取设备列表数据
|
2024-12-20 18:19:18 +08:00
|
|
|
|
const initDeviceList = () => {
|
2025-01-08 11:02:16 +08:00
|
|
|
|
Object.assign(deviceList, checkStore.devices)
|
2024-12-20 18:19:18 +08:00
|
|
|
|
}
|
2024-12-24 19:21:43 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 初始化检测结果数据结构(每个测试项的每个设备的每个通道)
|
2024-12-20 10:19:58 +08:00
|
|
|
|
const initCheckResult = () => {
|
2025-01-04 10:49:05 +08:00
|
|
|
|
let result: CheckData.ScriptChnItem[] = []
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 为每个检测脚本创建结果数据结构
|
2024-12-20 10:19:58 +08:00
|
|
|
|
scriptData.forEach(item => {
|
2024-12-20 18:19:18 +08:00
|
|
|
|
let temp: CheckData.ScriptChnItem = {
|
2025-01-02 18:00:58 +08:00
|
|
|
|
scriptType: item.id,
|
2024-12-25 18:04:16 +08:00
|
|
|
|
scriptName: item.scriptName,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
devices: [],
|
2024-12-20 10:19:58 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 为每个设备创建通道结果
|
2024-12-20 18:19:18 +08:00
|
|
|
|
for (let i = 0; i < deviceList?.length; i++) {
|
|
|
|
|
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 初始化所有通道状态为UNKNOWN
|
2024-12-20 18:19:18 +08:00
|
|
|
|
for (let j = 0; j < deviceList[i].chnNum; j++) {
|
|
|
|
|
|
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
|
2024-11-21 23:02:43 +08:00
|
|
|
|
}
|
2024-12-20 10:19:58 +08:00
|
|
|
|
temp.devices.push({
|
2024-12-21 12:41:06 +08:00
|
|
|
|
deviceId: deviceList[i].deviceId,
|
2024-12-20 18:19:18 +08:00
|
|
|
|
deviceName: deviceList[i].deviceName,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
chnResult: tempChnResult,
|
2024-12-20 10:19:58 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-01-04 10:49:05 +08:00
|
|
|
|
result.push(temp)
|
2024-12-20 10:19:58 +08:00
|
|
|
|
})
|
2025-01-04 10:49:05 +08:00
|
|
|
|
Object.assign(checkResult, result)
|
2024-12-20 10:19:58 +08:00
|
|
|
|
}
|
2025-01-08 11:02:16 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 数据更新函数 ==========
|
|
|
|
|
|
// 更新指定测试项的检测结果
|
2024-12-20 18:19:18 +08:00
|
|
|
|
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
const { scriptType } = { ...data }
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 找到对应的测试项并更新其结果
|
2024-12-20 10:19:58 +08:00
|
|
|
|
checkResult.forEach(item => {
|
2025-01-02 18:00:58 +08:00
|
|
|
|
if (item.scriptType == scriptType) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 更新每个设备的通道结果
|
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-08-11 16:30:53 +08:00
|
|
|
|
// 深拷贝结果数据
|
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
|
|
|
|
}
|
2024-12-20 10:19:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 滚动日志到底部
|
2024-11-21 23:02:43 +08:00
|
|
|
|
const scrollToBottom = () => {
|
2024-12-27 13:36:20 +08:00
|
|
|
|
if (scrollContainerRef.value) {
|
2025-08-26 10:37:13 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight + 70
|
|
|
|
|
|
},10)
|
2024-12-18 18:53:55 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
}
|
2024-11-21 23:02:43 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 工具函数 ==========
|
|
|
|
|
|
// 生成随机整数(0到max-1)
|
2024-11-21 23:02:43 +08:00
|
|
|
|
function getRandomInt(max: number): number {
|
2024-12-20 10:19:58 +08:00
|
|
|
|
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
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 将毫秒时间差转换为可读的时间格式
|
2024-12-18 18:53:55 +08:00
|
|
|
|
function getTimeDifference(timeDifference: number): string {
|
2025-08-11 16:30:53 +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-20 15:24:29 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 监听日志列表变化,自动滚动到底部
|
2025-01-14 14:17:05 +08:00
|
|
|
|
watch(testLogList, () => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
scrollToBottom()
|
|
|
|
|
|
}, { deep: true })
|
2024-12-11 17:46:59 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 日志记录函数 ==========
|
|
|
|
|
|
// 更新检测日志(记录检测项的开始和结束)
|
2024-12-27 10:31:15 +08:00
|
|
|
|
const updateLog = (isStart: boolean) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
const currentTime = ref(new Date().toLocaleString())
|
2024-12-20 10:19:58 +08:00
|
|
|
|
let timeDifferenceItem = 0
|
2024-11-21 23:02:43 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 确保在有效的测试项范围内
|
2025-01-04 16:33:23 +08:00
|
|
|
|
if (activeIndex <= checkTotal) {
|
2024-12-27 10:31:15 +08:00
|
|
|
|
if (isStart) {
|
2025-08-11 16:30:53 +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 {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 记录测试项结束
|
|
|
|
|
|
endData.value = new Date()
|
|
|
|
|
|
timeDifferenceItem = endData.value.getTime() - startData.value.getTime()
|
2024-12-20 10:19:58 +08:00
|
|
|
|
timeDifference.value += timeDifferenceItem
|
2024-12-27 10:31:15 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +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-08-11 16:30:53 +08:00
|
|
|
|
// 更新总时间显示
|
2025-02-19 13:17:19 +08:00
|
|
|
|
timeView.value = secondToTime(timeDifference.value / 1000)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 如果是最后一个测试项,记录总结日志
|
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-05 22:15:12 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 错误处理函数 ==========
|
|
|
|
|
|
// 设置测试项错误状态(分析所有通道结果,确定整体状态)
|
2025-01-09 11:13:34 +08:00
|
|
|
|
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
let type = 1 // 默认为成功
|
2025-01-09 11:13:34 +08:00
|
|
|
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 收集所有设备所有通道的结果
|
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-08-11 16:30:53 +08:00
|
|
|
|
// 按优先级确定整体状态(数据异常 > 失败 > 超时)
|
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
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 处理超时情况:记录日志并弹出提示
|
2025-01-09 11:13:34 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 记录测试项的错误状态
|
|
|
|
|
|
errorCheckItem.push({ scriptType, type: type })
|
2025-01-09 11:13:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 获取指定测试项的错误状态
|
|
|
|
|
|
// 判断该检测项是否全部合格(所有设备所有通道所有子检测项目全部合格为合格,否则为不合格)
|
2025-01-09 11:13:34 +08:00
|
|
|
|
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-08-11 16:30:53 +08:00
|
|
|
|
// 更新检测结果视图
|
2025-01-09 11:13:34 +08:00
|
|
|
|
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 根据代码找到对应的测试项ID
|
2025-01-02 18:00:58 +08:00
|
|
|
|
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
2024-12-26 10:49:55 +08:00
|
|
|
|
let temp = null
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
2024-12-26 10:49:55 +08:00
|
|
|
|
if (isStart) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 开始时设置为加载状态
|
2025-01-02 18:00:58 +08:00
|
|
|
|
temp = getLoadingResult(scriptType)
|
2024-12-26 10:49:55 +08:00
|
|
|
|
} else {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 结束时设置实际结果并记录错误状态
|
2025-01-08 09:46:47 +08:00
|
|
|
|
setErrorCheckItem(scriptType, devices)
|
2025-01-07 14:54:44 +08:00
|
|
|
|
temp = {
|
|
|
|
|
|
scriptType,
|
2025-08-11 16:30:53 +08:00
|
|
|
|
devices,
|
2025-01-07 14:54:44 +08:00
|
|
|
|
}
|
2024-12-26 10:49:55 +08:00
|
|
|
|
}
|
2024-12-20 10:19:58 +08:00
|
|
|
|
updateCheckResult(temp)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
}
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 生成加载状态的结果数据(所有通道显示为正在检测)
|
2025-01-02 18:00:58 +08:00
|
|
|
|
const getLoadingResult = (scriptType: string) => {
|
2024-12-26 10:49:55 +08:00
|
|
|
|
let devices = []
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 为每个设备的每个通道设置LOADING状态
|
2024-12-26 10:49:55 +08:00
|
|
|
|
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 = {
|
2025-01-02 18:00:58 +08:00
|
|
|
|
scriptType,
|
2024-12-26 10:49:55 +08:00
|
|
|
|
devices,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return tempScriptChnItem
|
|
|
|
|
|
}
|
2024-12-27 10:31:15 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 分析设备检测结果,返回整体状态
|
2025-01-20 15:24:29 +08:00
|
|
|
|
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
let type = 1 // 默认成功
|
2025-01-15 08:59:47 +08:00
|
|
|
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 收集所有设备的所有通道结果
|
2025-01-15 08:59:47 +08:00
|
|
|
|
for (let i = 0; i < devices.length; i++) {
|
|
|
|
|
|
tempChnResult.push(...devices[i].chnResult)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 按优先级确定结果类型(数据异常 > 失败)
|
2025-01-15 08:59:47 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 事件处理函数 ==========
|
|
|
|
|
|
// 点击通道按钮,查看检测详情
|
|
|
|
|
|
// 参数:设备信息,通道号(-1代表查看全部通道),测试项类型
|
2025-01-08 09:46:47 +08:00
|
|
|
|
const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 查找对应的检测结果
|
2025-01-02 18:00:58 +08:00
|
|
|
|
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
let flag = -1 // -1:正常, 0:超时, 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-08-11 16:30:53 +08:00
|
|
|
|
// 查看全部通道的状态
|
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-08-11 16:30:53 +08:00
|
|
|
|
// 查看特定通道的状态
|
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-02 18:00:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-08 09:46:47 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 根据状态进行不同处理
|
2025-01-02 18:00:58 +08:00
|
|
|
|
if (flag === 0) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 超时状态:显示提示信息
|
2025-01-08 20:57:11 +08:00
|
|
|
|
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
|
2025-01-02 18:00:58 +08:00
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
type: 'warning',
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-01-10 09:20:32 +08:00
|
|
|
|
if (flag === -1 || flag === 1) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 正常或数据异常:打开详情弹窗
|
2025-03-25 15:49:32 +08:00
|
|
|
|
checkStore.setShowDetailType(2)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum + '', scriptType)
|
2025-01-02 18:00:58 +08:00
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ========== 暂停/继续相关函数 ==========
|
|
|
|
|
|
// 处理暂停请求
|
2025-01-14 21:07:52 +08:00
|
|
|
|
const handlePause = () => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`,
|
|
|
|
|
|
})
|
2025-01-14 21:07:52 +08:00
|
|
|
|
}
|
2024-11-25 21:11:10 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 暂停成功回调
|
2025-01-14 21:07:52 +08:00
|
|
|
|
const pauseSuccessCallback = () => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 记录暂停时的时间
|
|
|
|
|
|
endData.value = new Date()
|
|
|
|
|
|
let diffTime = endData.value.getTime() - startData.value.getTime()
|
2025-01-03 11:27:36 +08:00
|
|
|
|
timeDifference.value += diffTime
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 记录暂停日志
|
2025-01-03 11:27:36 +08:00
|
|
|
|
testLogList.push({
|
|
|
|
|
|
type: 'info',
|
|
|
|
|
|
log: `${new Date().toLocaleString()}:暂停检测`,
|
|
|
|
|
|
})
|
2025-02-17 10:16:48 +08:00
|
|
|
|
stopTimeCount()
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-01-15 08:59:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 处理继续检测
|
2024-12-30 14:41:34 +08:00
|
|
|
|
const handleResumeTest = () => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 重新开始计时
|
|
|
|
|
|
startData.value = new Date()
|
|
|
|
|
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
|
2025-02-17 10:16:48 +08:00
|
|
|
|
resumeTimeCount()
|
2025-10-15 08:49:11 +08:00
|
|
|
|
|
2025-01-23 09:33:00 +08:00
|
|
|
|
}
|
2024-12-24 11:29:31 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 测试项索引管理函数 ==========
|
|
|
|
|
|
// 根据测试项代码获取对应的索引号(从1开始)
|
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-08-11 16:30:53 +08:00
|
|
|
|
// 根据当前测试项代码获取下一个测试项的索引号
|
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) {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
return i + 2 // 下一个测试项索引
|
2025-01-03 18:57:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return -1
|
|
|
|
|
|
}
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// ========== 时间计数器管理函数 ==========
|
|
|
|
|
|
// 开始计时
|
2025-02-17 10:16:48 +08:00
|
|
|
|
const startTimeCount = () => {
|
2025-02-26 19:31:34 +08:00
|
|
|
|
if (!timer) {
|
2025-02-26 10:00:44 +08:00
|
|
|
|
timer = setInterval(() => {
|
|
|
|
|
|
timeCount.value = timeCount.value + 1
|
|
|
|
|
|
timeView.value = secondToTime(timeCount.value)
|
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
}
|
2025-02-17 10:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 停止计时
|
2025-02-17 10:16:48 +08:00
|
|
|
|
const stopTimeCount = () => {
|
|
|
|
|
|
if (timer) {
|
|
|
|
|
|
clearInterval(timer)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
timer = null
|
2025-02-17 10:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:57:35 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +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)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 将秒数转换为 HH:MM:SS 格式
|
2025-02-17 10:16:48 +08:00
|
|
|
|
const secondToTime = (second: number) => {
|
2025-08-11 16:30:53 +08:00
|
|
|
|
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
|
2025-02-17 10:16:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-12 10:26:30 +08:00
|
|
|
|
// 组件卸载前清理定时器和响应式引用
|
2025-02-17 10:16:48 +08:00
|
|
|
|
onBeforeUnmount(() => {
|
2025-08-12 10:26:30 +08:00
|
|
|
|
// 清理定时器
|
2025-02-17 10:16:48 +08:00
|
|
|
|
if (timer) {
|
|
|
|
|
|
clearInterval(timer)
|
2025-08-11 16:30:53 +08:00
|
|
|
|
timer = null
|
2025-02-17 10:16:48 +08:00
|
|
|
|
}
|
2025-08-12 10:26:30 +08:00
|
|
|
|
|
|
|
|
|
|
// 清理响应式数组引用,防止内存泄漏
|
|
|
|
|
|
deviceList.splice(0)
|
|
|
|
|
|
checkResult.splice(0)
|
|
|
|
|
|
testLogList.splice(0)
|
|
|
|
|
|
errorCheckItem.splice(0)
|
|
|
|
|
|
|
|
|
|
|
|
// 重置其他状态
|
|
|
|
|
|
scriptData.splice(0)
|
|
|
|
|
|
activeIndex = 0
|
|
|
|
|
|
checkTotal = 0
|
|
|
|
|
|
count = 0
|
2025-02-17 10:16:48 +08:00
|
|
|
|
})
|
2025-03-17 13:24:35 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
// 暴露给父组件的方法
|
2025-03-17 13:24:35 +08:00
|
|
|
|
defineExpose({
|
2025-08-11 16:30:53 +08:00
|
|
|
|
handlePause, // 暂停方法
|
2025-03-17 13:24:35 +08:00
|
|
|
|
})
|
2024-11-25 21:11:10 +08:00
|
|
|
|
</script>
|
2024-12-20 10:19:58 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<!-- ========== 样式定义 ========== -->
|
|
|
|
|
|
<style scoped lang='scss'>
|
2024-12-18 15:56:59 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
/* 表格样式 */
|
2024-12-05 21:33:52 +08:00
|
|
|
|
:deep(.el-table .header-row) {
|
2024-12-18 18:53:55 +08:00
|
|
|
|
background-color: #f5f7fa;
|
2024-11-25 21:11:10 +08:00
|
|
|
|
}
|
2024-12-18 18:53:55 +08:00
|
|
|
|
|
2024-12-05 21:33:52 +08:00
|
|
|
|
:deep(.el-table .warning-row) {
|
2024-12-18 18:53:55 +08:00
|
|
|
|
color: red;
|
2024-12-05 21:33:52 +08:00
|
|
|
|
}
|
2024-12-06 15:06:38 +08:00
|
|
|
|
|
2024-11-25 21:11:10 +08:00
|
|
|
|
.el-table .success-row {
|
|
|
|
|
|
--el-table-tr-bg-color: var(--el-color-success-light-9);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
/* 主对话框容器 */
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
/* 对话框标题栏 */
|
2024-12-18 18:53:55 +08:00
|
|
|
|
.dialog-title {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
margin-bottom: 10px;
|
2025-02-19 13:17:19 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
/* 时间显示区域 */
|
2025-02-19 13:17:19 +08:00
|
|
|
|
.timeView {
|
2025-02-20 15:01:15 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-03-17 15:55:30 +08:00
|
|
|
|
color: #91cc75;
|
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
|
|
|
|
|
2025-08-11 16:30:53 +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
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +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
|
|
|
|
|
2025-08-11 16:30:53 +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
|
|
|
|
|
2024-12-11 19:12:04 +08:00
|
|
|
|
p {
|
|
|
|
|
|
margin: 5px 0;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-26 10:49:55 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
/* 抽屉容器样式 */
|
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;
|
2025-03-17 15:55:30 +08:00
|
|
|
|
background-color: var(--el-color-primary) !important;
|
2025-05-26 14:41:06 +08:00
|
|
|
|
|
2024-12-24 19:21:43 +08:00
|
|
|
|
.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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
/* 加载动画样式 */
|
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-11-18 22:04:59 +08:00
|
|
|
|
</style>
|
2024-12-18 20:26:18 +08:00
|
|
|
|
|
2025-08-11 16:30:53 +08:00
|
|
|
|
<style lang='scss' scoped>
|
|
|
|
|
|
/* 表格按钮样式 */
|
2024-12-05 15:22:46 +08:00
|
|
|
|
: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
|
|
|
|
|
2025-08-11 16:30:53 +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-05 15:22:46 +08:00
|
|
|
|
</style>
|