微调
This commit is contained in:
@@ -213,16 +213,14 @@ const chnSum = computed(() => {
|
||||
|
||||
// 用来展示的检测结果
|
||||
const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(() => {
|
||||
console.log('🚀 ~ tem.devices:', checkResult)
|
||||
|
||||
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
|
||||
let temp: CheckData.ScriptChnViewItem = {
|
||||
scriptType: item.scriptType,
|
||||
scriptName: item.scriptName,
|
||||
devices: []
|
||||
}
|
||||
|
||||
item.devices.forEach(device => {
|
||||
console.log('🚀 ~ item:', item, CheckData.ChnCheckResultEnum)
|
||||
let tempChnBtnResult: CheckData.ButtonResult[] = []
|
||||
|
||||
if (chnSum.value <= MAX_CHN_SUM) {
|
||||
@@ -286,6 +284,9 @@ watch(testStatus, function (newValue, oldValue) {
|
||||
// 开始计时
|
||||
startTimeCount()
|
||||
showTestLog()
|
||||
setTimeout(() => {
|
||||
initCheckResult(CheckData.ChnCheckResultEnum.LOADING)
|
||||
}, 500)
|
||||
//startTimer() // todo 可移除
|
||||
startData.value = new Date()
|
||||
timeDifference.value = 0
|
||||
@@ -301,7 +302,6 @@ watch(
|
||||
webMsgSend,
|
||||
function (newValue, oldValue) {
|
||||
console.log('🚀 ~ newValue:', newValue)
|
||||
|
||||
if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') {
|
||||
if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') {
|
||||
testLogList.shift()
|
||||
@@ -534,10 +534,10 @@ const initDeviceList = () => {
|
||||
}
|
||||
|
||||
// 初始化检测结果 (详细到通道)
|
||||
const initCheckResult = () => {
|
||||
// 修改函数定义
|
||||
const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => {
|
||||
let result: CheckData.ScriptChnItem[] = []
|
||||
scriptData.forEach(item => {
|
||||
// 处理当前节点的数据
|
||||
let temp: CheckData.ScriptChnItem = {
|
||||
scriptType: item.id,
|
||||
scriptName: item.scriptName,
|
||||
@@ -547,7 +547,7 @@ const initCheckResult = () => {
|
||||
for (let i = 0; i < deviceList?.length; i++) {
|
||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||
for (let j = 0; j < checkStore.chnNumList.length; j++) {
|
||||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
|
||||
tempChnResult.push(defaultValue)
|
||||
}
|
||||
temp.devices.push({
|
||||
deviceId: deviceList[i].deviceId,
|
||||
@@ -561,22 +561,6 @@ const initCheckResult = () => {
|
||||
Object.assign(checkResult, result)
|
||||
}
|
||||
|
||||
// 更新检测结果(详细到通道)
|
||||
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
||||
const { scriptType } = { ...data }
|
||||
|
||||
checkResult.forEach(item => {
|
||||
if (item.scriptType == scriptType) {
|
||||
for (let i = 0; i < item.devices.length; i++) {
|
||||
let targetDevice = data.devices.find(dev => dev.deviceId === item.devices[i].deviceId)
|
||||
if (targetDevice !== undefined) {
|
||||
item.devices[i].chnResult = [...targetDevice.chnResult]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
if (scrollContainerRef.value) {
|
||||
scrollContainerRef.value.scrollTop = scrollContainerRef.value.scrollHeight + 70
|
||||
@@ -591,131 +575,42 @@ watch(
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
|
||||
let type = 1
|
||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
tempChnResult.push(...devices[i].chnResult)
|
||||
}
|
||||
|
||||
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.ERRORDATA)) {
|
||||
type = CheckData.ChnCheckResultEnum.ERRORDATA
|
||||
}
|
||||
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.FAIL)) {
|
||||
type = CheckData.ChnCheckResultEnum.FAIL
|
||||
}
|
||||
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.TIMEOUT)) {
|
||||
type = CheckData.ChnCheckResultEnum.TIMEOUT
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
if (devices[i].chnResult.some(item => item === CheckData.ChnCheckResultEnum.TIMEOUT)) {
|
||||
testLogList.push({
|
||||
type: 'warning',
|
||||
log: `${new Date().toLocaleString()} :${devices[i].deviceName}连接超时`
|
||||
})
|
||||
ElMessageBox.alert('连接超时!', '连接超时', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
emit('update:testStatus', 'connect_timeout')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
errorCheckItem.push({ scriptType, type: type })
|
||||
}
|
||||
|
||||
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
|
||||
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
||||
let temp = null
|
||||
if (isStart) {
|
||||
temp = getLoadingResult(scriptType)
|
||||
} else {
|
||||
setErrorCheckItem(scriptType, devices)
|
||||
temp = {
|
||||
scriptType,
|
||||
devices
|
||||
}
|
||||
}
|
||||
updateCheckResult(temp)
|
||||
}
|
||||
|
||||
// 获取loading状态的结果
|
||||
const getLoadingResult = (scriptType: 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 = {
|
||||
scriptType,
|
||||
devices
|
||||
}
|
||||
|
||||
return tempScriptChnItem
|
||||
}
|
||||
|
||||
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
||||
let type = 1
|
||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
tempChnResult.push(...devices[i].chnResult)
|
||||
}
|
||||
|
||||
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.ERRORDATA)) {
|
||||
type = CheckData.ChnCheckResultEnum.ERRORDATA
|
||||
}
|
||||
if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.FAIL)) {
|
||||
type = CheckData.ChnCheckResultEnum.FAIL
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
// 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道
|
||||
const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
||||
let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType)
|
||||
let flag = -1
|
||||
if (checkResultItem) {
|
||||
let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
|
||||
if (device) {
|
||||
let chnResult = device.chnResult
|
||||
if (chnNum === -1) {
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
|
||||
flag = 1
|
||||
}
|
||||
} else {
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
|
||||
flag = 1
|
||||
}
|
||||
let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId)
|
||||
if (device) {
|
||||
let chnResult = device.chnResult
|
||||
if (chnNum === -1) {
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.TIMEOUT) !== -1) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult.findIndex(obj => obj === CheckData.ChnCheckResultEnum.ERRORDATA) !== -1) {
|
||||
flag = 1
|
||||
}
|
||||
} else {
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.TIMEOUT) {
|
||||
flag = 0
|
||||
}
|
||||
if (chnResult[chnNum - 1] === CheckData.ChnCheckResultEnum.ERRORDATA) {
|
||||
flag = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag === 0) {
|
||||
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
})
|
||||
ElMessageBox.alert('连接超时,请检查设备通讯是否正常', '连接超时', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning'
|
||||
})
|
||||
}
|
||||
if (flag === -1 || flag === 1) {
|
||||
checkStore.setShowDetailType(2)
|
||||
checkStore.setShowDetailType(2)
|
||||
|
||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(item, chnNum+'', item.devices[0].deviceId,1)
|
||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(item, chnNum + '', item.devices[0].deviceId, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +624,7 @@ const handlePause = () => {
|
||||
const initializeParameters = async () => {
|
||||
await initScriptData()
|
||||
initDeviceList()
|
||||
initCheckResult()
|
||||
initCheckResult(CheckData.ChnCheckResultEnum.UNKNOWN)
|
||||
percentage.value = 0
|
||||
timeCount.value = 0
|
||||
timeView.value = '00:00:00'
|
||||
@@ -739,26 +634,6 @@ const initializeParameters = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const pauseSuccessCallback = () => {
|
||||
endData.value = new Date()
|
||||
let diffTime = endData.value.getTime() - startData.value.getTime()
|
||||
timeDifference.value += diffTime
|
||||
|
||||
testLogList.push({
|
||||
type: 'info',
|
||||
log: `${new Date().toLocaleString()}:暂停检测`
|
||||
})
|
||||
|
||||
console.log('暂停中')
|
||||
}
|
||||
|
||||
const handleResumeTest = () => {
|
||||
//activeIndex++
|
||||
startData.value = new Date()
|
||||
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
|
||||
//startTimer()
|
||||
console.log('开始继续检测')
|
||||
}
|
||||
//
|
||||
onMounted(() => {
|
||||
if (!checkStore.selectTestItems.preTest) {
|
||||
|
||||
Reference in New Issue
Block a user