正式检测-预检测提示及日志功能
This commit is contained in:
@@ -13,6 +13,19 @@
|
||||
:icon="VideoPause"
|
||||
@click="handlePauseTest">停止检测
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
v-if="testStatus=='preTest_process' && activeIndex < checkTotal"
|
||||
:icon="VideoPause"
|
||||
disabled>预检测中
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
v-if="testStatus=='preTest_fail'"
|
||||
:icon="Failed"
|
||||
disabled>预检测失败
|
||||
</el-button>
|
||||
|
||||
|
||||
<el-button type="success" v-if="activeIndex >= checkTotal" :icon="Check" disabled>检测完成</el-button>
|
||||
|
||||
@@ -38,7 +51,7 @@
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
<el-table :data="checkResultView" row-key="scriptId" height="450px"
|
||||
<el-table :data="checkResultView" row-key="scriptType" height="450px"
|
||||
:header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " style="width: 100%"
|
||||
border>
|
||||
<el-table-column fixed prop="scriptName" label="检测项目" width="150px" align="center">
|
||||
@@ -57,7 +70,7 @@
|
||||
: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)"
|
||||
@click="handleClick(item,chnItem+'',row.scriptType)"
|
||||
style="align-self: center;"
|
||||
>
|
||||
<el-icon v-if="row.devices[index1].chnResult[index2].icon==='Loading'" class="loading-box"
|
||||
@@ -86,7 +99,7 @@
|
||||
: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)"
|
||||
@click="handleClick(item,'-1',row.scriptType)"
|
||||
>
|
||||
<el-icon v-if="row.devices[index1].chnResult[0].icon==='Loading'" class="loading-box"
|
||||
style="color: #fff">
|
||||
@@ -127,7 +140,7 @@
|
||||
<dataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
|
||||
</template>
|
||||
<script lang="tsx" setup name="test">
|
||||
import {Check, InfoFilled, Loading, Refresh, VideoPause} from '@element-plus/icons-vue'
|
||||
import {Check, InfoFilled, Loading, Refresh, VideoPause, Failed} from '@element-plus/icons-vue'
|
||||
import resultPopup from './resultPopup.vue'
|
||||
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||||
import {computed, reactive, ref, toRef, watch} from "vue";
|
||||
@@ -178,7 +191,7 @@ const timeDifference = ref(0)
|
||||
// 真正的检测结果(详细到通道)
|
||||
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
|
||||
// 用来存放检测出现失败的测试项id。只要有一个通道检测不合格,则该检测项的id会被加入该数组。
|
||||
let errorCheckItem: Array<{ scriptId: string, type: 'info' | 'warning' | 'error' }> = []
|
||||
let errorCheckItem: Array<{ scriptType: string, type: 'info' | 'warning' | 'error' }> = []
|
||||
// 用来存放检测日志
|
||||
const testLogList = reactive<CheckData.LogItem[]>([{type: 'info', log: '暂无数据,等待检测开始'}])
|
||||
|
||||
@@ -200,11 +213,11 @@ const chnSum = computed(() => {
|
||||
})
|
||||
|
||||
// 用来展示的检测结果
|
||||
const checkResultView = computed(() => {
|
||||
const checkResultView: any[] = computed(() => {
|
||||
|
||||
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
|
||||
let temp: CheckData.ScriptChnViewItem = {
|
||||
scriptId: item.scriptId,
|
||||
scriptType: item.scriptType,
|
||||
scriptName: item.scriptName,
|
||||
devices: []
|
||||
}
|
||||
@@ -279,8 +292,11 @@ const checkResultView = computed(() => {
|
||||
|
||||
watch(testStatus, function (newValue, oldValue) {
|
||||
if (newValue == 'start') {
|
||||
//startTimer() // todo 可移除
|
||||
emit('update:testStatus', 'process')
|
||||
ElMessage.success('预检测开始!')
|
||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:预检测开始!`})
|
||||
emit('update:testStatus', 'preTest_process')
|
||||
startTimer() // todo 可移除
|
||||
//emit('update:testStatus', 'process') // todo 可移除
|
||||
}
|
||||
if (newValue == 'paused' && oldValue == 'process') {
|
||||
handlePauseOrContinue()
|
||||
@@ -294,16 +310,80 @@ watch(testStatus, function (newValue, oldValue) {
|
||||
watch(webMsgSend, function (newValue, oldValue) {
|
||||
if (activeIndex <= checkTotal) {
|
||||
switch (newValue.requestId) {
|
||||
case 'PreTest_Success':
|
||||
ElMessage.success('预检成功!')
|
||||
// case 'connect':
|
||||
// switch (newValue.operateCode) {
|
||||
// case "Source":
|
||||
// ElMessageBox.alert('源通讯失败,请检查源连接情况!', '预检测失败', {
|
||||
// confirmButtonText: '确定',
|
||||
// type: 'error',
|
||||
// })
|
||||
// testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源通讯失败!`})
|
||||
// break;
|
||||
// case "Dev":
|
||||
// ElMessageBox.alert('设备通讯失败,请检查设备连接情况!', '预检测失败', {
|
||||
// confirmButtonText: '确定',
|
||||
// type: 'error',
|
||||
// })
|
||||
// testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:设备通讯失败!`})
|
||||
// break;
|
||||
// }
|
||||
// emit('update:testStatus', 'preTest_fail')
|
||||
// break;
|
||||
case 'yjc_ytxjy':
|
||||
switch (newValue.operateCode) {
|
||||
case 'INIT_GATHER':
|
||||
if (newValue.code == 10552) {
|
||||
ElMessageBox.alert('源通讯中断,请检查源连接情况!', '预检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源通讯中断!`})
|
||||
emit('update:testStatus', 'preTest_fail')
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'PreTest_Fail':
|
||||
ElMessageBox.alert('预检测失败,请检查设备连接情况', '预检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
}).then(() => {
|
||||
emit('update:testStatus', 'success')
|
||||
})
|
||||
case 'yjc_sbtxjy':
|
||||
switch (newValue.operateCode) {
|
||||
case 'INIT_GATHER$01':
|
||||
if (newValue.code == 10550) {
|
||||
ElMessageBox.alert(`${newValue.data}设备通讯失败,请检查设备连接情况!`, '预检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:${newValue.data}设备通讯中断!`})
|
||||
emit('update:testStatus', 'preTest_fail')
|
||||
}
|
||||
if (newValue.code == 10551) {
|
||||
ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '预检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:${newValue.data}设备触发报告异常!`})
|
||||
emit('update:testStatus', 'preTest_fail')
|
||||
}
|
||||
if (newValue.code == 10552) {
|
||||
ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '预检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
testLogList.push({
|
||||
type: 'error',
|
||||
log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!`
|
||||
})
|
||||
emit('update:testStatus', 'preTest_fail')
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'YJC_xujy':
|
||||
switch (newValue.operateCode) {
|
||||
case 'DATA_REQUEST$02':
|
||||
ElMessage.success('预检测成功!')
|
||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:预检测成功!`})
|
||||
emit('update:testStatus', 'process')
|
||||
break
|
||||
}
|
||||
break;
|
||||
case 'Pause_Success':
|
||||
ElMessage.success('暂停成功')
|
||||
@@ -559,7 +639,7 @@ const initCheckResult = () => {
|
||||
scriptData.forEach(item => {
|
||||
// 处理当前节点的数据
|
||||
let temp: CheckData.ScriptChnItem = {
|
||||
scriptId: item.id,
|
||||
scriptType: item.id,
|
||||
scriptName: item.scriptName,
|
||||
devices: []
|
||||
}
|
||||
@@ -579,10 +659,10 @@ const initCheckResult = () => {
|
||||
}
|
||||
// 更新检测结果(详细到通道)
|
||||
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
||||
const {scriptId} = {...data}
|
||||
const {scriptType} = {...data}
|
||||
|
||||
checkResult.forEach(item => {
|
||||
if (item.scriptId == scriptId) {
|
||||
if (item.scriptType == scriptType) {
|
||||
item.devices.forEach((device, index) => {
|
||||
device.chnResult = [...data.devices[index].chnResult]
|
||||
})
|
||||
@@ -601,8 +681,8 @@ function getRandomInt(max: number): number {
|
||||
}
|
||||
|
||||
//判断该检测项(例如 频率准确度检测)是否全部合格(所有设备所有通道所有子检测项目全部合格为合格,否则为不合格)
|
||||
function getItemCheckResult(scriptId: string): boolean {
|
||||
let items = errorCheckItem.filter((item) => item.scriptId === scriptId)
|
||||
function getItemCheckResult(scriptType: string): boolean {
|
||||
let items = errorCheckItem.filter((item) => item.scriptType === scriptType)
|
||||
if (items.length > 0) {
|
||||
return true
|
||||
} else {
|
||||
@@ -637,7 +717,7 @@ const updateLog = (isStart: boolean) => {
|
||||
|
||||
if (activeIndex === 1 && isStart) {
|
||||
timeDifference.value = 0;
|
||||
testLogList.length = 0; // 清空数组
|
||||
//testLogList.length = 0; // 清空数组
|
||||
}
|
||||
// debugger
|
||||
if (activeIndex < checkTotal) {
|
||||
@@ -676,7 +756,7 @@ const updateLog = (isStart: boolean) => {
|
||||
|
||||
// 动态获取表格单元格样式
|
||||
// function tableCell({row, columnIndex}) {
|
||||
// let items = errorCheckItem.filter((item) => item === row.scriptId)
|
||||
// let items = errorCheckItem.filter((item) => item === row.scriptType)
|
||||
//
|
||||
// if (columnIndex === 0 && items.length > 0) {
|
||||
// return 'warning-row'
|
||||
@@ -688,18 +768,18 @@ const updateLog = (isStart: boolean) => {
|
||||
|
||||
const updateCheckResultView = (scriptCode: string, isStart: boolean) => {
|
||||
// debugger
|
||||
let scriptId = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
||||
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
||||
let temp = null
|
||||
if (isStart) {
|
||||
temp = getLoadingResult(scriptId)
|
||||
temp = getLoadingResult(scriptType)
|
||||
} else {
|
||||
temp = getCheckResult(scriptId)
|
||||
temp = getCheckResult(scriptType)
|
||||
}
|
||||
updateCheckResult(temp)
|
||||
};
|
||||
|
||||
// 获取loading状态的结果
|
||||
const getLoadingResult = (scriptId: string) => {
|
||||
const getLoadingResult = (scriptType: string) => {
|
||||
let devices = []
|
||||
|
||||
devices = deviceList.map(item => {
|
||||
@@ -717,7 +797,7 @@ const getLoadingResult = (scriptId: string) => {
|
||||
})
|
||||
|
||||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||||
scriptId,
|
||||
scriptType,
|
||||
devices,
|
||||
}
|
||||
|
||||
@@ -726,7 +806,7 @@ const getLoadingResult = (scriptId: string) => {
|
||||
|
||||
|
||||
// 模拟检测 todo 可移除
|
||||
const getCheckResult = (scriptId: string) => {
|
||||
const getCheckResult = (scriptType: string) => {
|
||||
// debugger
|
||||
let devices = []
|
||||
|
||||
@@ -736,12 +816,12 @@ const getCheckResult = (scriptId: string) => {
|
||||
if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
|
||||
for (let i = 0; i < item.chnNum; i++) {
|
||||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
|
||||
//errorCheckItem.push({scriptId,type:'warning'})
|
||||
//errorCheckItem.push({scriptType,type:'warning'})
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < item.chnNum; i++) {
|
||||
tempChnResult.push(CheckData.ChnCheckResultEnum.ERRORDATA)
|
||||
//errorCheckItem.push({scriptId,type:'warning'})
|
||||
//errorCheckItem.push({scriptType,type:'warning'})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,7 +837,7 @@ const getCheckResult = (scriptId: string) => {
|
||||
if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
|
||||
for (let i = 0; i < item.chnNum; i++) {
|
||||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
|
||||
//errorCheckItem.push({scriptId,type:'warning'})
|
||||
//errorCheckItem.push({scriptType,type:'warning'})
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < item.chnNum; i++) {
|
||||
@@ -766,7 +846,7 @@ const getCheckResult = (scriptId: string) => {
|
||||
let randomNum = getRandomInt(item.chnNum * 2)
|
||||
if (randomNum < item.chnNum && activeIndex >= 4 && activeIndex <= 8) {
|
||||
tempChnResult[randomNum] = CheckData.ChnCheckResultEnum.FAIL
|
||||
errorCheckItem.push({scriptId, type: 'error'})
|
||||
errorCheckItem.push({scriptType, type: 'error'})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,7 +859,7 @@ const getCheckResult = (scriptId: string) => {
|
||||
}
|
||||
|
||||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||||
scriptId,
|
||||
scriptType,
|
||||
devices,
|
||||
}
|
||||
|
||||
@@ -813,8 +893,40 @@ const handlePauseOrContinue = () => {
|
||||
};
|
||||
|
||||
// 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道
|
||||
const handleClick = (deviceId: string, chnNum: string, scriptType: string) => {
|
||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(deviceId, chnNum, scriptType);
|
||||
const handleClick = (item: any, chnNum: string, scriptType: string) => {
|
||||
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
||||
let chnResult = checkResultItem?.devices.find(obj => obj.deviceId === item.deviceId)?.chnResult
|
||||
let flag = -1
|
||||
if (chnNum === '-1') {
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.UNCONNECTED) !== -1) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
|
||||
flag = 1
|
||||
}
|
||||
} else {
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.UNCONNECTED) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
|
||||
flag = 1
|
||||
}
|
||||
}
|
||||
if (flag === 0) {
|
||||
ElMessageBox.alert('设备通讯中断,请检查设备通讯是否正常', '通讯中断', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
if (flag === 1) {
|
||||
ElMessageBox.alert('该测试项数据异常', '数据异常', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
if (flag === -1) {
|
||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum, scriptType);
|
||||
}
|
||||
};
|
||||
|
||||
// todo 可移除
|
||||
@@ -822,16 +934,38 @@ const startTimer = () => {
|
||||
console.log('开始检测第' + activeIndex + '项')
|
||||
switch (activeIndex) {
|
||||
case 1:
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'FREQ_Start',
|
||||
params: {}
|
||||
})
|
||||
requestId: 'yjc_ytxjy',
|
||||
operateCode: "INIT_GATHER",
|
||||
code: "2222"
|
||||
})},2000)
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'yjc_sbtxjy',
|
||||
operateCode: "INIT_GATHER$01",
|
||||
code: "2222",
|
||||
data:'240003'
|
||||
})
|
||||
}, 4000);
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'YJC_xujy',
|
||||
operateCode: "DATA_REQUEST$02"
|
||||
})
|
||||
},6000)
|
||||
setTimeout(()=>{
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'FREQ_Start',
|
||||
params: {}
|
||||
})
|
||||
},9000)
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'FREQ_End',
|
||||
params: {}
|
||||
})
|
||||
}, 2000);
|
||||
}, 12000);
|
||||
break;
|
||||
case 2:
|
||||
emit('update:webMsgSend', {
|
||||
|
||||
Reference in New Issue
Block a user