1125 lines
32 KiB
Vue
1125 lines
32 KiB
Vue
<template>
|
||
<div class="dialog" v-bind="dialogBig">
|
||
<div class="dialog-title">
|
||
<el-progress
|
||
style="width: 90%"
|
||
:percentage="percentage"
|
||
:color="customColors"/>
|
||
|
||
<el-button
|
||
type="primary"
|
||
v-if="testStatus=='process' && activeIndex < checkTotal"
|
||
:disabled="activeIndex===0"
|
||
:icon="VideoPause"
|
||
@click="handlePauseTest">停止检测
|
||
</el-button>
|
||
|
||
<el-button type="success" v-if="activeIndex >= checkTotal" :icon="Check" disabled>检测完成</el-button>
|
||
|
||
<el-button
|
||
type="warning"
|
||
v-if="testStatus=='paused' && activeIndex < checkTotal"
|
||
:icon="Refresh"
|
||
@click="handleResumeTest"
|
||
>继续检测
|
||
</el-button>
|
||
<el-button type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
|
||
<!-- <el-button
|
||
type="warning"
|
||
v-if="activeIndex >= checkTotal"
|
||
:icon="Refresh"
|
||
@click="handleReCheck"
|
||
>重新检测</el-button
|
||
> -->
|
||
<!-- <el-button type="danger" :icon="Close" @click="handleFinishTest"
|
||
>停止检测</el-button
|
||
> -->
|
||
|
||
</div>
|
||
|
||
<div class="dialog-content">
|
||
<el-table :data="checkResultView" row-key="scriptId" 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">
|
||
</el-table-column>
|
||
|
||
<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.deviceId,chnItem+'',row.scriptId)"
|
||
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.deviceId,'-1',row.scriptId)"
|
||
>
|
||
<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>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="drawer-container">
|
||
<el-drawer v-model="drawer" title="检测项进度">
|
||
<!-- <template #header>-->
|
||
<!-- <div style="background: #003078 !important; color: #fff !important; font-size: 18px;">检测项进度</div>-->
|
||
<!-- </template>-->
|
||
<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"/>
|
||
</template>
|
||
<script lang="tsx" setup name="test">
|
||
import {Check, InfoFilled, Loading, Refresh, VideoPause} from '@element-plus/icons-vue'
|
||
import resultPopup from './resultPopup.vue'
|
||
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||
import {reactive, ref, watch} from "vue";
|
||
import {dialogBig} from "@/utils/elementBind";
|
||
import {CheckData} from "@/api/check/interface"
|
||
import {useCheckStore} from "@/stores/modules/check";
|
||
import {ElMessage, ElMessageBox} from "element-plus";
|
||
import {getBigTestItem} from "@/api/check/test";
|
||
|
||
const checkStore = useCheckStore()
|
||
|
||
// 最大通道数
|
||
const MAX_CHN_SUM = 8
|
||
|
||
// 总测试项数
|
||
let checkTotal = 0
|
||
|
||
const props = defineProps({
|
||
testStatus: {
|
||
type: String,
|
||
default: 'waiting'
|
||
},
|
||
webMsgSend: {
|
||
type: Object,
|
||
default: () => ({})
|
||
}
|
||
})
|
||
|
||
const emit = defineEmits(['update:testStatus', 'update:webMsgSend', 'sendPause', 'sendResume']);
|
||
|
||
// 用来保存测试项进度抽屉是否打开
|
||
const drawer = ref(false)
|
||
// 进度条颜色
|
||
const customColors = [{color: "#5cb87a", percentage: 100}]
|
||
// 检测脚本数据
|
||
let scriptData: CheckData.ScriptItem[] = []
|
||
// 用来保存被检设备
|
||
const deviceList = reactive<CheckData.Device[]>([])
|
||
// 当前进行的测试项索引
|
||
let activeIndex = 1
|
||
// 百分比
|
||
const percentage = ref(0);
|
||
//测试项开始检测时间(或继续检测时间)
|
||
const startData = ref(new Date())
|
||
//测试项检测结束时间(或暂停时的时间)
|
||
const endData = ref(new Date())
|
||
const timeDifference = ref(0)
|
||
// 真正的检测结果(详细到通道)
|
||
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
|
||
// 用来存放检测出现失败的测试项id。只要有一个通道检测不合格,则该检测项的id会被加入该数组。
|
||
let errorCheckItem: Array<{ scriptId: string, type: 'info' | 'warning' | 'error' }> = []
|
||
// 用来存放检测日志
|
||
const testLogList = reactive<CheckData.LogItem[]>([{type: 'info', log: '暂无数据,等待检测开始'}])
|
||
|
||
const testStatus = toRef(props, 'testStatus')
|
||
const webMsgSend = toRef(props, 'webMsgSend')
|
||
|
||
const resultDialogVisible = ref(false)
|
||
const scrollContainerRef = ref();
|
||
const dataCheckSingleChannelSingleTestPopupRef = ref<InstanceType<typeof dataCheckSingleChannelSingleTestPopup>>()
|
||
|
||
|
||
// 总通道数
|
||
const chnSum = computed(() => {
|
||
let sum = 0
|
||
deviceList.forEach((item) => {
|
||
sum += item.chnNum
|
||
})
|
||
return sum
|
||
})
|
||
|
||
// 用来展示的检测结果
|
||
const checkResultView = computed(() => {
|
||
|
||
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
|
||
let temp: CheckData.ScriptChnViewItem = {
|
||
scriptId: item.scriptId,
|
||
scriptName: item.scriptName,
|
||
devices: []
|
||
}
|
||
|
||
item.devices.forEach(device => {
|
||
let tempChnBtnResult: CheckData.ButtonResult[] = []
|
||
|
||
if (chnSum.value <= MAX_CHN_SUM) {
|
||
for (let j = 0; j < device.chnResult.length; j++) {
|
||
switch (device.chnResult[j]) {
|
||
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.UNCONNECTED:
|
||
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'Link'})
|
||
break;
|
||
case CheckData.ChnCheckResultEnum.ERRORDATA:
|
||
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'WarnTriangleFilled'})
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
} else {
|
||
let tempChnResult: CheckData.ChnCheckResultEnum = device.chnResult[0]
|
||
if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.FAIL)) {
|
||
tempChnResult = CheckData.ChnCheckResultEnum.FAIL
|
||
}
|
||
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.UNCONNECTED:
|
||
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'Link'})
|
||
break;
|
||
case CheckData.ChnCheckResultEnum.ERRORDATA:
|
||
tempChnBtnResult.push({color: CheckData.ButtonColorEnum.WARNING, icon: 'WarnTriangleFilled'})
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
temp.devices.push({
|
||
deviceId: device.deviceId,
|
||
deviceName: device.deviceName,
|
||
chnResult: tempChnBtnResult
|
||
})
|
||
})
|
||
return temp
|
||
})
|
||
return result
|
||
})
|
||
|
||
watch(testStatus, function (newValue, oldValue) {
|
||
if (newValue == 'start') {
|
||
//startTimer() // todo 可移除
|
||
emit('update:testStatus', 'process')
|
||
}
|
||
if (newValue == 'paused' && oldValue == 'process') {
|
||
handlePauseOrContinue()
|
||
}
|
||
if (newValue === 'process' && oldValue == 'paused') {
|
||
activeIndex++
|
||
handlePauseOrContinue()
|
||
}
|
||
})
|
||
|
||
watch(webMsgSend, function (newValue, oldValue) {
|
||
if (activeIndex <= checkTotal) {
|
||
switch (newValue.requestId) {
|
||
case 'PreTest_Success':
|
||
ElMessage.success('预检成功!')
|
||
break;
|
||
case 'PreTest_Fail':
|
||
ElMessageBox.alert('预检测失败,请检查设备连接情况', '预检测失败', {
|
||
confirmButtonText: '确定',
|
||
type: 'error',
|
||
}).then(() => {
|
||
emit('update:testStatus', 'success')
|
||
})
|
||
break;
|
||
case 'Pause_Success':
|
||
ElMessage.success('暂停成功')
|
||
emit('update:testStatus', 'paused')
|
||
break;
|
||
case 'Pause_Fail':
|
||
ElMessage.error('暂停失败')
|
||
break;
|
||
case 'Resume_Success':
|
||
ElMessage.success('开始继续检测')
|
||
emit('update:testStatus', 'process')
|
||
break;
|
||
case 'Resume_Fail':
|
||
ElMessage.error('无法继续检测')
|
||
break;
|
||
case 'FREQ_Start':
|
||
updateCheckResultView("FREQ", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'FREQ_End':
|
||
updateCheckResultView("FREQ", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'VOL_Start':
|
||
updateCheckResultView("V", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'VOL_End':
|
||
updateCheckResultView("V", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'Harm_V_Start':
|
||
updateCheckResultView("HV", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'Harm_V_End':
|
||
updateCheckResultView("HV", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'Harm_I_Start':
|
||
updateCheckResultView("HI", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'Harm_I_End':
|
||
updateCheckResultView("HI", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'Harm_P_Start':
|
||
updateCheckResultView("HP", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'Harm_P_End':
|
||
updateCheckResultView("HP", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'InHarm_V_Start':
|
||
updateCheckResultView("HSV", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'InHarm_V_End':
|
||
updateCheckResultView("HSV", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'InHarm_I_Start':
|
||
updateCheckResultView("HSI", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'InHarm_I_End':
|
||
updateCheckResultView("HSI", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'Dip_Start':
|
||
updateCheckResultView("VOLTAGE", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'Dip_End':
|
||
updateCheckResultView("VOLTAGE", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'CUR_Start':
|
||
updateCheckResultView("I", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'CUR_End':
|
||
updateCheckResultView("I", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'MSQI_U_Start':
|
||
updateCheckResultView("IMBV", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'MSQI_U_End':
|
||
updateCheckResultView("IMBV", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'MSQI_I_Start':
|
||
updateCheckResultView("IMBA", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'MSQI_I_End':
|
||
updateCheckResultView("IMBA", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'Flicker_Start':
|
||
updateCheckResultView("F", true)
|
||
updateLog(true)
|
||
break;
|
||
case 'Flicker_End':
|
||
updateCheckResultView("F", false)
|
||
updateLog(false)
|
||
updatePercentage()
|
||
if (testStatus.value != 'paused') {
|
||
activeIndex++;
|
||
startTimer()
|
||
}
|
||
break;
|
||
case 'Quit':
|
||
updateLog(false)
|
||
updatePercentage()
|
||
console.log('检测结束')
|
||
break;
|
||
}
|
||
}
|
||
}, {deep: true})
|
||
|
||
// 更新进度条
|
||
const updatePercentage = () => {
|
||
if (activeIndex < checkTotal) {
|
||
percentage.value = Math.trunc(activeIndex / checkTotal * 100);
|
||
} else {
|
||
percentage.value = 100;
|
||
emit('update:testStatus', 'success')
|
||
|
||
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
|
||
// if you want to disable its autofocus
|
||
// autofocus: false,
|
||
confirmButtonText: '确定',
|
||
})
|
||
clear();
|
||
}
|
||
}
|
||
|
||
// todo 可移除start
|
||
let randomUnConnectedRaw = -1
|
||
let randomUnConnectedDeviceId = -1
|
||
let randomErrorDataRaw = -1
|
||
// todo 可移除end
|
||
|
||
onBeforeMount(async () => {
|
||
await initScriptData()
|
||
initDeviceList()
|
||
initCheckResult()
|
||
|
||
// todo 可移除start
|
||
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
|
||
}
|
||
// todo 可移除end
|
||
})
|
||
|
||
|
||
const showTestLog = () => {
|
||
drawer.value = true
|
||
}
|
||
|
||
// 初始化检测脚本数据
|
||
const initScriptData = async () => {
|
||
|
||
let response: any = await getBigTestItem(checkStore.planId)
|
||
|
||
let temp = response.data.map(item => {
|
||
return {
|
||
...item,
|
||
scriptName: item.scriptName
|
||
}
|
||
})
|
||
|
||
scriptData.push(...temp)
|
||
checkTotal = scriptData.length + 1
|
||
}
|
||
// 初始化设备列表
|
||
const initDeviceList = () => {
|
||
checkStore.devices.forEach(item => {
|
||
deviceList.push({
|
||
deviceId: item.deviceId,
|
||
deviceName: item.deviceName,
|
||
chnNum: item.chnNum,
|
||
})
|
||
})
|
||
}
|
||
|
||
// 初始化检测结果 (详细到通道)
|
||
const initCheckResult = () => {
|
||
scriptData.forEach(item => {
|
||
// 处理当前节点的数据
|
||
let temp: CheckData.ScriptChnItem = {
|
||
scriptId: item.id,
|
||
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)
|
||
}
|
||
temp.devices.push({
|
||
deviceId: deviceList[i].deviceId,
|
||
deviceName: deviceList[i].deviceName,
|
||
chnResult: tempChnResult
|
||
})
|
||
}
|
||
checkResult.push(temp)
|
||
})
|
||
}
|
||
// 更新检测结果(详细到通道)
|
||
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
||
const {scriptId} = {...data}
|
||
|
||
checkResult.forEach(item => {
|
||
if (item.scriptId == scriptId) {
|
||
item.devices.forEach((device, index) => {
|
||
device.chnResult = [...data.devices[index].chnResult]
|
||
})
|
||
}
|
||
})
|
||
}
|
||
|
||
const scrollToBottom = () => {
|
||
if (scrollContainerRef.value) {
|
||
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight;
|
||
}
|
||
};
|
||
|
||
function getRandomInt(max: number): number {
|
||
return Math.floor(Math.random() * max)
|
||
}
|
||
|
||
//判断该检测项(例如 频率准确度检测)是否全部合格(所有设备所有通道所有子检测项目全部合格为合格,否则为不合格)
|
||
function getItemCheckResult(scriptId: string): boolean {
|
||
let items = errorCheckItem.filter((item) => item.scriptId === scriptId)
|
||
if (items.length > 0) {
|
||
return true
|
||
} else {
|
||
return false
|
||
}
|
||
}
|
||
|
||
function getTimeDifference(timeDifference: number): string {
|
||
// 将时间差转换为天、小时、分钟、秒
|
||
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);
|
||
if (days > 0) {
|
||
return `: ${days} 天, ${hours} 小时, ${minutes} 分钟, ${seconds} 秒`
|
||
} else if (hours > 0) {
|
||
return `: ${hours} 小时, ${minutes} 分钟, ${seconds} 秒`
|
||
} else {
|
||
return `: ${minutes} 分钟, ${seconds} 秒`
|
||
}
|
||
}
|
||
|
||
// 更新日志
|
||
const updateLog = (isStart: boolean) => {
|
||
const currentTime = ref(new Date().toLocaleString());
|
||
let timeDifferenceItem = 0
|
||
|
||
if (activeIndex === 1 && isStart) {
|
||
timeDifference.value = 0;
|
||
testLogList.length = 0; // 清空数组
|
||
}
|
||
// debugger
|
||
if (activeIndex < checkTotal) {
|
||
if (isStart) {
|
||
startData.value = new Date();
|
||
testLogList.push({
|
||
type: 'info',
|
||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测:开始`,
|
||
})
|
||
} else {
|
||
endData.value = new Date();
|
||
timeDifferenceItem = endData.value.getTime() - startData.value.getTime();
|
||
timeDifference.value += timeDifferenceItem
|
||
|
||
if (getItemCheckResult(scriptData[activeIndex - 1].id)) {
|
||
testLogList.push({
|
||
type: 'error',
|
||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测结束:不符合,用时` + getTimeDifference(timeDifferenceItem),
|
||
})
|
||
} else {
|
||
testLogList.push({
|
||
type: 'info',
|
||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测结束:符合,用时` + getTimeDifference(timeDifferenceItem),
|
||
})
|
||
}
|
||
}
|
||
} else {
|
||
testLogList.push({
|
||
type: 'info',
|
||
log: currentTime.value + ' :检测结束,总用时' + getTimeDifference(timeDifference.value),
|
||
})
|
||
}
|
||
|
||
scrollToBottom();
|
||
}
|
||
|
||
// 动态获取表格单元格样式
|
||
// function tableCell({row, columnIndex}) {
|
||
// let items = errorCheckItem.filter((item) => item === row.scriptId)
|
||
//
|
||
// if (columnIndex === 0 && items.length > 0) {
|
||
// return 'warning-row'
|
||
// }
|
||
// if (columnIndex === 0) {
|
||
// return 'header-row'
|
||
// }
|
||
// }
|
||
|
||
const updateCheckResultView = (scriptCode: string, isStart: boolean) => {
|
||
// debugger
|
||
let scriptId = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
||
let temp = null
|
||
if (isStart) {
|
||
temp = getLoadingResult(scriptId)
|
||
} else {
|
||
temp = getCheckResult(scriptId)
|
||
}
|
||
updateCheckResult(temp)
|
||
};
|
||
|
||
// 获取loading状态的结果
|
||
const getLoadingResult = (scriptId: string) => {
|
||
let devices = []
|
||
|
||
devices = deviceList.map(item => {
|
||
|
||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||
for (let i = 0; i < item.chnNum; i++) {
|
||
tempChnResult.push(CheckData.ChnCheckResultEnum.LOADING)
|
||
}
|
||
|
||
return {
|
||
deviceId: item.deviceId,
|
||
deviceName: item.deviceName,
|
||
chnResult: tempChnResult,
|
||
}
|
||
})
|
||
|
||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||
scriptId,
|
||
devices,
|
||
}
|
||
|
||
return tempScriptChnItem
|
||
}
|
||
|
||
|
||
// 模拟检测 todo 可移除
|
||
const getCheckResult = (scriptId: string) => {
|
||
// debugger
|
||
let devices = []
|
||
|
||
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++) {
|
||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
|
||
//errorCheckItem.push({scriptId,type:'warning'})
|
||
}
|
||
} else {
|
||
for (let i = 0; i < item.chnNum; i++) {
|
||
tempChnResult.push(CheckData.ChnCheckResultEnum.ERRORDATA)
|
||
//errorCheckItem.push({scriptId,type:'warning'})
|
||
}
|
||
}
|
||
|
||
return {
|
||
deviceId: item.deviceId,
|
||
deviceName: item.deviceName,
|
||
chnResult: tempChnResult,
|
||
}
|
||
})
|
||
} else {
|
||
devices = deviceList.map(item => {
|
||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||
if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
|
||
for (let i = 0; i < item.chnNum; i++) {
|
||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
|
||
//errorCheckItem.push({scriptId,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
|
||
errorCheckItem.push({scriptId, type: 'error'})
|
||
}
|
||
}
|
||
|
||
return {
|
||
deviceId: item.deviceId,
|
||
deviceName: item.deviceName,
|
||
chnResult: tempChnResult,
|
||
}
|
||
})
|
||
}
|
||
|
||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||
scriptId,
|
||
devices,
|
||
}
|
||
|
||
return tempScriptChnItem
|
||
}
|
||
|
||
// 处理暂停、继续按钮点击事件
|
||
const handlePauseOrContinue = () => {
|
||
const currentTime = ref(new Date().toLocaleString());
|
||
|
||
if (testStatus.value == "paused") {
|
||
endData.value = new Date();
|
||
const Pausetime = endData.value.getTime() - startData.value.getTime();
|
||
timeDifference.value += Pausetime
|
||
|
||
testLogList.push({
|
||
type: 'info',
|
||
log: currentTime.value + ':暂停检测',
|
||
})
|
||
console.log('暂停中')
|
||
}
|
||
if (testStatus.value == "process") {
|
||
startData.value = new Date();
|
||
testLogList.push({
|
||
type: 'info',
|
||
log: currentTime.value + ':继续检测',
|
||
})
|
||
startTimer()
|
||
console.log('开始继续检测')
|
||
}
|
||
};
|
||
|
||
// 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道
|
||
const handleClick = (deviceId: string, chnNum: string, scriptType: string) => {
|
||
dataCheckSingleChannelSingleTestPopupRef.value?.open(deviceId, chnNum, scriptType);
|
||
};
|
||
|
||
// todo 可移除
|
||
const startTimer = () => {
|
||
console.log('开始检测第' + activeIndex + '项')
|
||
switch (activeIndex) {
|
||
case 1:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'FREQ_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'FREQ_End',
|
||
params: {}
|
||
})
|
||
}, 2000);
|
||
break;
|
||
case 2:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'VOL_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'VOL_End',
|
||
params: {}
|
||
})
|
||
}, 2000);
|
||
break;
|
||
case 3:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Harm_V_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Harm_V_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 4:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Harm_I_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Harm_I_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 5:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Harm_P_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Harm_P_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 6:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'InHarm_V_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'InHarm_V_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 7:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'InHarm_I_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'InHarm_I_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 8:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Dip_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Dip_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 9:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'CUR_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'CUR_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 10:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'MSQI_U_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'MSQI_U_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 11:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'MSQI_I_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'MSQI_I_End',
|
||
params: {}
|
||
}, 2000)
|
||
})
|
||
break;
|
||
case 12:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Flicker_Start',
|
||
params: {}
|
||
})
|
||
setTimeout(() => {
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Flicker_End',
|
||
params: {}
|
||
})
|
||
}, 2000)
|
||
break;
|
||
case 13:
|
||
emit('update:webMsgSend', {
|
||
requestId: 'Quit',
|
||
params: {}
|
||
})
|
||
break;
|
||
}
|
||
};
|
||
|
||
const handlePauseTest = () => {
|
||
// 发送暂停指令
|
||
emit('sendPause')
|
||
};
|
||
|
||
const handleResumeTest = () => {
|
||
// 发送继续检测指令
|
||
emit('sendResume')
|
||
};
|
||
|
||
//完成检测
|
||
const handleFinishTest = () => {
|
||
resultDialogVisible.value = true
|
||
ElMessage.success("完成检测");
|
||
};
|
||
|
||
const handleReCheck = () => {
|
||
activeIndex = 1;
|
||
percentage.value = 0;
|
||
testLogList.length = 0;
|
||
errorCheckItem.length = 0;
|
||
// resumeTimer()
|
||
};
|
||
|
||
function clear() {
|
||
errorCheckItem.length = 0;
|
||
}
|
||
|
||
defineExpose({
|
||
clear,
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
|
||
:deep(.el-table .header-row) {
|
||
// background-color:var(--el-color-warning-light-9);
|
||
background-color: #f5f7fa;
|
||
// color:red;
|
||
// font-size:30px;
|
||
// --el-table-tr-bg-color: var(--el-color-warning-light-9);
|
||
}
|
||
|
||
:deep(.el-table .warning-row) {
|
||
// background-color:var(--el-color-warning-light-9);
|
||
//background-color:#bed96557;
|
||
color: red;
|
||
// font-size:30px;
|
||
// --el-table-tr-bg-color: var(--el-color-warning-light-9);
|
||
// background-color:#f5f7fa;
|
||
// position: relative;
|
||
}
|
||
|
||
// :deep(.el-table .warning-row::before) {
|
||
// content: '*'; /* 必须设置content属性 */
|
||
// position: absolute;
|
||
// color:red;
|
||
// background-color:#f5f7fa;
|
||
// }
|
||
|
||
.el-table .success-row {
|
||
--el-table-tr-bg-color: var(--el-color-success-light-9);
|
||
}
|
||
|
||
.dialog {
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-y: hidden;
|
||
overflow-x: hidden;
|
||
}
|
||
|
||
.dialog-title {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-right: 10px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.dialog-content {
|
||
max-height: 450px;
|
||
overflow-y: hidden;
|
||
}
|
||
|
||
:deep(.el-collapse-item__header) {
|
||
height: 30px;
|
||
}
|
||
|
||
.dialog-log {
|
||
height: 50px;
|
||
overflow-y: hidden;
|
||
// flex-grow: 1;
|
||
// display: flex;
|
||
// flex-direction: column-reverse;
|
||
|
||
p {
|
||
margin: 5px 0;
|
||
font-size: 14px;
|
||
}
|
||
}
|
||
|
||
.drawer-container {
|
||
:deep(header.el-drawer__header) {
|
||
color: #fff !important;
|
||
background-color: #003078 !important;
|
||
|
||
.el-drawer__close-btn svg:hover {
|
||
color: #ccc !important;
|
||
}
|
||
|
||
.el-drawer__title {
|
||
color: #fff !important;
|
||
}
|
||
}
|
||
}
|
||
|
||
.loading-box {
|
||
animation: loading 1.5s linear infinite;
|
||
}
|
||
|
||
@keyframes loading {
|
||
from {
|
||
transform: rotate(0deg);
|
||
}
|
||
to {
|
||
transform: rotate(360deg);
|
||
}
|
||
}
|
||
|
||
|
||
//:deep(.el-drawer .el-drawer__title){
|
||
// background-color: #003078 !important;
|
||
//}
|
||
|
||
</style>
|
||
|
||
<style lang="scss" scoped>
|
||
:deep(.el-button--small) {
|
||
height: 20px !important;
|
||
width: 20px !important;
|
||
}
|
||
|
||
:deep(.el-table--default td ) {
|
||
padding: 5px 0 !important;
|
||
}
|
||
|
||
|
||
</style>
|