前端优化调整
This commit is contained in:
@@ -685,31 +685,34 @@ const updatePercentage = async () => {
|
||||
} else {
|
||||
// 所有检测项完成
|
||||
percentage.value = 100
|
||||
emit('update:testStatus', 'success')
|
||||
|
||||
// 检查是否需要自动生成报告
|
||||
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,
|
||||
// 先完成所有后续操作,再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: '确定',
|
||||
})
|
||||
// 关闭WebSocket连接
|
||||
emit('closeWebSocket')
|
||||
} finally {
|
||||
// 最后才emit success,避免中断后续操作
|
||||
emit('update:testStatus', 'success')
|
||||
}
|
||||
// 提示检测完成
|
||||
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
|
||||
confirmButtonText: '确定',
|
||||
})
|
||||
// 关闭WebSocket连接
|
||||
emit('closeWebSocket')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,12 +1179,25 @@ const secondToTime = (second: number) => {
|
||||
return h + ':' + m + ':' + s
|
||||
}
|
||||
|
||||
// 组件卸载前清理定时器
|
||||
// 组件卸载前清理定时器和响应式引用
|
||||
onBeforeUnmount(() => {
|
||||
// 清理定时器
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
|
||||
// 清理响应式数组引用,防止内存泄漏
|
||||
deviceList.splice(0)
|
||||
checkResult.splice(0)
|
||||
testLogList.splice(0)
|
||||
errorCheckItem.splice(0)
|
||||
|
||||
// 重置其他状态
|
||||
scriptData.splice(0)
|
||||
activeIndex = 0
|
||||
checkTotal = 0
|
||||
count = 0
|
||||
})
|
||||
|
||||
// 暴露给父组件的方法
|
||||
|
||||
Reference in New Issue
Block a user