@@ -16,8 +16,6 @@
< el-button type = "success" v-if = "activeIndex >= TEST_TOTAL" :icon="Check" disabled > 检测完成 < / el-button >
< el-button type = "text" :icon = "InfoFilled" @click ="showTestLog" > 检测项进度 < / el -button >
< el-button
type = "warning"
v-if = "isPause && activeIndex < TEST_TOTAL"
@@ -25,6 +23,7 @@
@click ="handlePauseOrContinue"
> 继续检测
< / el-button >
< el-button type = "text" :icon = "InfoFilled" @click ="showTestLog" > 检测项进度 < / el -button >
<!-- < el-button
type = "warning"
v-if = "activeIndex >= TEST_TOTAL"
@@ -46,9 +45,9 @@
< / el-table-column >
< template v-if = "chnSum<=MAX_CHN_SUM" >
< el -table -column v-for = "(item,index1) in monitor List" :key="item.deviceID" :label="item.deviceName"
< el -table -column v-for = "(item,index1) in device List" :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"
< el-table-column v-for = "(chnItem,index2) in item.chnNum" :key="`${ item.deviceID}${ chnItem}` "
:label = "'通道'+chnItem" align = "center" >
< template # default = "{row}" >
< el-tooltip
@@ -69,7 +68,7 @@
< / template >
< template v-else >
< el -table -column v-for = "(item,index) in monitor List" :key="item.deviceID" :label="item.deviceName"
< el -table -column v-for = "(item,index) in device List" :key="item.deviceID" :label="item.deviceName"
:min-width = "110" align = "center" >
< template # default = "{row}" >
< el-tooltip : content = "row.devices[index].chnResult[0].resultType==='info' ? '暂无数据' : '点击查看详情'"
@@ -108,19 +107,15 @@
< dataCheckSingleChannelSingleTestPopup ref = "dataCheckSingleChannelSingleTestPopupRef" / >
< / template >
< script lang = "tsx" setup name = "test" >
import { Check , Refresh , VideoPause } from '@element-plus/icons-vue'
import { Check , Refresh , VideoPause , InfoFilled } from '@element-plus/icons-vue'
import resultPopup from './resultPopup.vue'
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
import { reactive , ref } from "vue" ;
import { dialogBig } from "@/utils/elementBind" ;
import {
ButtonResult ,
ChnCheckResultEnum ,
LogItem ,
ScriptChnItem ,
ScriptChnViewItem ,
ScriptItem
} from "@/api/check/interface"
import { CheckData } from "@/api/check/interface"
import { useCheckStore } from "@/stores/modules/check" ;
const checkStore = useCheckStore ( )
const drawer = ref ( false )
const showTestLog = ( ) => {
@@ -128,7 +123,6 @@ const showTestLog = () =>{
}
// 总测试项数
const TEST _TOTAL = 12
// 最大通道数
@@ -149,46 +143,45 @@ const dataCheckSingleChannelSingleTestPopupRef = ref();
// const currentRow = ref(null); // 用于存储当前选中的行
const monitorList = reactive ( [
{
deviceID : '1' ,
deviceName : '240001' ,
chnNum : 1 ,
monitorIdx : 1 ,
label : '240001' ,
prop : 'Result1' ,
} ,
{
deviceID : '2' ,
deviceName : '240002' ,
chnNum : 1 ,
monitorIdx : 2 ,
label : '240002' ,
prop : 'Result2' ,
} ,
{
deviceID : '3' ,
deviceName : '240003' ,
chnNum : 2 ,
monitorIdx : 1 ,
label : '240003' ,
prop : 'Result3' ,
} ,
{
deviceID : '4' ,
deviceName : '240004' ,
chnNum : 4 ,
monitorIdx : 2 ,
label : '240004' ,
prop : 'Result4' ,
}
const deviceList = reactive < CheckData .Device [ ] > ( [
// {
// deviceID: '1',
// deviceName: '240001',
// chnNum: 1,
// monitorIdx: 1,
// label: '240001',
// prop: 'Result1',
// },
// {
// deviceID: '2',
// deviceName: '240002',
// chnNum: 1,
// monitorIdx: 2,
// label: '240002',
// prop: 'Result2',
// },
// {
// deviceID: '3',
// deviceName: '240003',
// chnNum: 2,
// monitorIdx: 1,
// label: '240003',
// prop: 'Result3',
// },
// {
// deviceID: '4',
// deviceName: '240004',
// chnNum: 4,
// monitorIdx: 2,
// label: '240004',
// prop: 'Result4',
// }
] )
// 总通道数
const chnSum = computed ( ( ) => {
let sum = 0
monitor List. forEach ( ( item ) => {
device List. forEach ( ( item ) => {
sum += item . chnNum
} )
return sum
@@ -196,11 +189,12 @@ const chnSum = computed(() => {
onBeforeMount ( ( ) => {
initScriptData ( )
initDeviceList ( )
initCheckResult ( )
} )
// 检测脚本数据
const scriptData = reactive < ScriptItem [ ] > ( [ ] )
const scriptData = reactive < CheckData . ScriptItem[ ] > ( [ ] )
// 初始化检测脚本数据
const initScriptData = ( ) => {
Object . assign ( scriptData , [
@@ -393,26 +387,35 @@ const initScriptData = () => {
// },
// ])
}
// 初始化设备列表
const initDeviceList = ( ) => {
checkStore . devices . forEach ( item => {
deviceList . push ( {
deviceID : item . deviceID ,
deviceName : item . deviceName ,
chnNum : item . chnNum ,
} )
} )
}
// 真正的检测结果(详细到通道)
const checkResult = reactive < ScriptChnItem [ ] > ( [ ] )
const checkResult = reactive < CheckData . ScriptChnItem[ ] > ( [ ] )
// 初始化检测结果 (详细到通道)
const initCheckResult = ( ) => {
scriptData . forEach ( item => {
// 处理当前节点的数据
let temp : ScriptChnItem = {
let temp : CheckData . ScriptChnItem = {
scriptID : item . id ,
scriptItemName : item . scriptItemName ,
devices : [ ]
}
for ( let i = 0 ; i < monitor List? . length ; i ++ ) {
let tempChnResult : ChnCheckResultEnum [ ] = [ ]
for ( let j = 0 ; j < monitor List[ i ] . chnNum ; j ++ ) {
tempChnResult . push ( ChnCheckResultEnum . UNKNOWN )
for ( let i = 0 ; i < device List? . length ; i ++ ) {
let tempChnResult : CheckData . ChnCheckResultEnum[ ] = [ ]
for ( let j = 0 ; j < device List[ i ] . chnNum ; j ++ ) {
tempChnResult . push ( CheckData . ChnCheckResultEnum. UNKNOWN )
}
temp . devices . push ( {
deviceID : monitor List[ i ] . deviceID ,
deviceName : monitor List[ i ] . deviceName ,
deviceID : device List[ i ] . deviceID ,
deviceName : device List[ i ] . deviceName ,
chnResult : tempChnResult
} )
}
@@ -420,7 +423,7 @@ const initCheckResult = () => {
} )
}
// 更新检测结果(详细到通道)
const updateCheckResult = ( data : ScriptChnItem ) => {
const updateCheckResult = ( data : CheckData . ScriptChnItem) => {
const { scriptID } = { ... data }
checkResult . forEach ( item => {
@@ -435,34 +438,34 @@ const updateCheckResult = (data: ScriptChnItem) => {
// 用来展示的检测结果
const checkResultView = computed ( ( ) => {
let result : ScriptChnViewItem [ ] = checkResult . map ( item => {
let temp : ScriptChnViewItem = {
let result : CheckData . ScriptChnViewItem[ ] = checkResult . map ( item => {
let temp : CheckData . ScriptChnViewItem = {
scriptID : item . scriptID ,
scriptItemName : item . scriptItemName ,
devices : [ ]
}
item . devices . forEach ( device => {
let tempChnBtnResult : ButtonResult [ ] = [ ]
let tempChnBtnResult : CheckData . ButtonResult[ ] = [ ]
if ( chnSum . value <= MAX _CHN _SUM ) {
for ( let j = 0 ; j < device . chnResult . length ; j ++ ) {
if ( device . chnResult [ j ] == ChnCheckResultEnum . UNKNOWN ) {
if ( device . chnResult [ j ] == CheckData . ChnCheckResultEnum. UNKNOWN ) {
tempChnBtnResult . push ( { resultType : 'info' , resultValue : '-' } )
} else if ( device . chnResult [ j ] == ChnCheckResultEnum . FAIL ) {
} else if ( device . chnResult [ j ] == CheckData . ChnCheckResultEnum. FAIL ) {
tempChnBtnResult . push ( { resultType : 'danger' , resultValue : '× ' } )
} else {
tempChnBtnResult . push ( { resultType : 'success' , resultValue : '√' } )
}
}
} else {
let tempChnResult : ChnCheckResultEnum = device . chnResult [ 0 ]
if ( device . chnResult . some ( item => item == ChnCheckResultEnum . FAIL ) ) {
tempChnResult = ChnCheckResultEnum . FAIL
let tempChnResult : CheckData . ChnCheckResultEnum = device . chnResult [ 0 ]
if ( device . chnResult . some ( item => item == CheckData . ChnCheckResultEnum. FAIL ) ) {
tempChnResult = CheckData . ChnCheckResultEnum. FAIL
}
if ( tempChnResult == ChnCheckResultEnum . UNKNOWN ) {
if ( tempChnResult == CheckData . ChnCheckResultEnum. UNKNOWN ) {
tempChnBtnResult . push ( { resultType : 'info' , resultValue : '-' } )
} else if ( tempChnResult == ChnCheckResultEnum . FAIL ) {
} else if ( tempChnResult == CheckData . ChnCheckResultEnum. FAIL ) {
tempChnBtnResult . push ( { resultType : 'danger' , resultValue : '× ' } )
} else {
tempChnBtnResult . push ( { resultType : 'success' , resultValue : '√' } )
@@ -529,7 +532,7 @@ function getTimeDifference(timeDifference: number): string {
}
// 用来存放检测日志
const testLogList = ref < LogItem [ ] > ( [ { type : 'info' , log : '暂无数据,等待检测开始' } ] )
const testLogList = ref < CheckData . LogItem[ ] > ( [ { type : 'info' , log : '暂无数据,等待检测开始' } ] )
// 更新日志
const updateLog = ( ) => {
@@ -797,17 +800,17 @@ const updateCheckResultView = (scriptID: string) => {
const simulateCheck = ( scriptID : string ) => {
let devices = [ ]
devices = monitor List. map ( item => {
devices = device List. map ( item => {
let tempChnResult : ChnCheckResultEnum [ ] = [ ]
let tempChnResult : CheckData . ChnCheckResultEnum[ ] = [ ]
for ( let i = 0 ; i < item . chnNum ; i ++ ) {
tempChnResult . push ( ChnCheckResultEnum . SUCCESS )
tempChnResult . push ( CheckData . ChnCheckResultEnum. SUCCESS )
}
let randomNum = getRandomInt ( item . chnNum * 2 )
if ( activeIndex . value >= 4 && activeIndex . value <= 6 ) {
if ( randomNum <= item . chnNum ) {
tempChnResult [ randomNum ] = ChnCheckResultEnum . FAIL
tempChnResult [ randomNum ] = CheckData . ChnCheckResultEnum. FAIL
errorCheckItem . push ( scriptID )
}
@@ -820,7 +823,7 @@ const simulateCheck = (scriptID: string) => {
}
} )
let tempScriptChnItem : ScriptChnItem = {
let tempScriptChnItem : CheckData . ScriptChnItem = {
scriptID ,
devices ,
}
@@ -839,7 +842,7 @@ const handleReCheck = () => {
} ;
// 用来保存定时器
const timer = ref ( "" ) ;
const timer : any = ref ( "" ) ;
// 处理暂停、继续按钮点击事件
const handlePauseOrContinue = ( ) => {