暂停检,测弹窗二次确认是否等待小项检测完成
This commit is contained in:
@@ -3,15 +3,19 @@ import { useDetectionLockStore } from '@/stores/modules/detectionLock'
|
|||||||
import type { CheckData } from '@/api/check/interface'
|
import type { CheckData } from '@/api/check/interface'
|
||||||
|
|
||||||
|
|
||||||
export const startPreTest = async (params) => {
|
export const startPreTest = async (params: any) => {
|
||||||
const result = await http.post(`/prepare/startPreTest`, params, {loading: false})
|
const result = await http.post(`/prepare/startPreTest`, params, {loading: false})
|
||||||
// 抢锁成功 → 标记本地为持锁者
|
// 抢锁成功 → 标记本地为持锁者
|
||||||
useDetectionLockStore().setAsHolder()
|
useDetectionLockStore().setAsHolder()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export const closePreTest = (params) => {
|
export interface ClosePreTestParam {
|
||||||
return http.post(`/prepare/closePreTest`, params,{ loading: false })
|
waitCurrentItem: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const closePreTest = (params: ClosePreTestParam) => {
|
||||||
|
return http.post(`/prepare/closePreTest`, params, { loading: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,15 +30,15 @@ export const closePreTest = (params) => {
|
|||||||
* 暂停正式检测
|
* 暂停正式检测
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const pauseTest = () => {
|
export const pauseTest = (waitCurrentItem = true) => {
|
||||||
return http.get(`/prepare/closePreTest`, {loading: false})
|
return closePreTest({ waitCurrentItem })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 继续正式检测
|
* 继续正式检测
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const resumeTest = (params) => {
|
export const resumeTest = (params: any) => {
|
||||||
return http.post(`/prepare/restartTemTest/`, params, {loading: false})
|
return http.post(`/prepare/restartTemTest/`, params, {loading: false})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,15 @@ let errorCheckItem: Array<{ scriptType: string, type: CheckData.ChnCheckResultEn
|
|||||||
// 检测日志列表
|
// 检测日志列表
|
||||||
const testLogList = reactive<CheckData.LogItem[]>([{ type: 'info', log: '暂无数据,等待检测开始' }])
|
const testLogList = reactive<CheckData.LogItem[]>([{ type: 'info', log: '暂无数据,等待检测开始' }])
|
||||||
|
|
||||||
|
interface FormalCurrentItem {
|
||||||
|
type?: string
|
||||||
|
typeName?: string
|
||||||
|
index?: number
|
||||||
|
desc?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentFormalItem = ref<FormalCurrentItem | null>(null)
|
||||||
|
|
||||||
// ========== 响应式引用 ==========
|
// ========== 响应式引用 ==========
|
||||||
// 将props转为ref,便于watch监听
|
// 将props转为ref,便于watch监听
|
||||||
const testStatus = toRef(props, 'testStatus')
|
const testStatus = toRef(props, 'testStatus')
|
||||||
@@ -472,6 +481,11 @@ watch(webMsgSend, function(newValue, oldValue) {
|
|||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case 'formal_current_item':
|
||||||
|
currentFormalItem.value = typeof newValue.data === 'string'
|
||||||
|
? JSON.parse(newValue.data || '{}')
|
||||||
|
: (newValue.data || null)
|
||||||
|
break
|
||||||
// 正式测试相关消息
|
// 正式测试相关消息
|
||||||
case 'formal_real':
|
case 'formal_real':
|
||||||
switch (newValue.operateCode) {
|
switch (newValue.operateCode) {
|
||||||
@@ -1200,13 +1214,17 @@ const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
|||||||
|
|
||||||
// ========== 暂停/继续相关函数 ==========
|
// ========== 暂停/继续相关函数 ==========
|
||||||
// 处理暂停请求
|
// 处理暂停请求
|
||||||
const handlePause = () => {
|
const handlePause = (waitCurrentItem = true) => {
|
||||||
testLogList.push({
|
testLogList.push({
|
||||||
type: 'error',
|
type: waitCurrentItem ? 'error' : 'warning',
|
||||||
log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`,
|
log: waitCurrentItem
|
||||||
|
? `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`
|
||||||
|
: `${new Date().toLocaleString()}:已请求立即暂停,不等待当前小项检测结束`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getCurrentFormalItem = () => currentFormalItem.value
|
||||||
|
|
||||||
// 暂停成功回调
|
// 暂停成功回调
|
||||||
const pauseSuccessCallback = () => {
|
const pauseSuccessCallback = () => {
|
||||||
// 记录暂停时的时间
|
// 记录暂停时的时间
|
||||||
@@ -1371,7 +1389,8 @@ defineExpose({
|
|||||||
handlePause, // 暂停方法
|
handlePause, // 暂停方法
|
||||||
getElapsedSeconds,
|
getElapsedSeconds,
|
||||||
applyFormalProgress,
|
applyFormalProgress,
|
||||||
startFormalTimer
|
startFormalTimer,
|
||||||
|
getCurrentFormalItem
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
|
|
||||||
<!-- 停止检测按钮 - 检测进行中时显示 -->
|
<!-- 停止检测按钮 - 检测进行中时显示 -->
|
||||||
<el-button type="primary" v-if="TestStatus == 'process'" :icon="VideoPause" :disabled="isRestoringFormalProgress" @click="handlePause()">
|
<el-button type="primary" v-if="TestStatus == 'process'" :icon="VideoPause" :disabled="isRestoringFormalProgress" @click="handlePause()">
|
||||||
停止检测
|
暂停检测
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
<!-- 暂停中按钮 - 禁用状态,显示加载动画 -->
|
<!-- 暂停中按钮 - 禁用状态,显示加载动画 -->
|
||||||
@@ -168,11 +168,37 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
v-model="pauseConfirmVisible"
|
||||||
|
title="确认暂停检测"
|
||||||
|
width="520px"
|
||||||
|
align-center
|
||||||
|
:close-on-click-modal="!pauseConfirmLoading"
|
||||||
|
:close-on-press-escape="!pauseConfirmLoading"
|
||||||
|
:show-close="!pauseConfirmLoading"
|
||||||
|
>
|
||||||
|
<div class="pause-confirm-content">
|
||||||
|
<p>当前正在进行:{{ pauseCurrentItemText }}...</p>
|
||||||
|
<p>是否等待该小项检测完成</p>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" :loading="pauseConfirmLoading" :disabled="pauseConfirmLoading" @click="confirmPause(true)">
|
||||||
|
等待
|
||||||
|
</el-button>
|
||||||
|
<el-button type="warning" :loading="pauseConfirmLoading" :disabled="pauseConfirmLoading" @click="confirmPause(false)">
|
||||||
|
不等待
|
||||||
|
</el-button>
|
||||||
|
<el-button :disabled="pauseConfirmLoading" @click="pauseConfirmVisible = false">
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="tsx" setup name="testPopup">
|
<script lang="tsx" setup name="testPopup">
|
||||||
// ====================== 导入依赖 ======================
|
// ====================== 导入依赖 ======================
|
||||||
import { onBeforeUnmount, reactive, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, reactive, ref, watch } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
Coin,
|
Coin,
|
||||||
@@ -212,12 +238,24 @@ const dialogTitle = ref('') // 弹窗标题
|
|||||||
const showComponent = ref(true) // 是否显示检测组件
|
const showComponent = ref(true) // 是否显示检测组件
|
||||||
const preTestRef = ref<{ initializeParameters: () => void } | null>(null) // 预检测组件引用
|
const preTestRef = ref<{ initializeParameters: () => void } | null>(null) // 预检测组件引用
|
||||||
const testRef = ref<{
|
const testRef = ref<{
|
||||||
handlePause: () => void
|
handlePause: (waitCurrentItem?: boolean) => void
|
||||||
|
getCurrentFormalItem: () => { typeName?: string; desc?: string } | null
|
||||||
getElapsedSeconds: () => number
|
getElapsedSeconds: () => number
|
||||||
applyFormalProgress: (snapshot: CheckData.FormalProgressVO) => void
|
applyFormalProgress: (snapshot: CheckData.FormalProgressVO) => void
|
||||||
startFormalTimer: () => void
|
startFormalTimer: () => void
|
||||||
} | null>(null) // 正式检测组件引用
|
} | null>(null) // 正式检测组件引用
|
||||||
const isRestoringFormalProgress = ref(false)
|
const isRestoringFormalProgress = ref(false)
|
||||||
|
const pauseConfirmVisible = ref(false)
|
||||||
|
const pauseConfirmLoading = ref(false)
|
||||||
|
const pauseCurrentItem = ref<{ typeName?: string; desc?: string } | null>(null)
|
||||||
|
const pauseCurrentItemText = computed(() => {
|
||||||
|
const item = pauseCurrentItem.value
|
||||||
|
if (!item) {
|
||||||
|
return '当前检测小项'
|
||||||
|
}
|
||||||
|
const parts = [item.typeName, item.desc].filter(Boolean)
|
||||||
|
return parts.length > 0 ? parts.join(' - ') : '当前检测小项'
|
||||||
|
})
|
||||||
|
|
||||||
// ====================== 步骤控制相关变量 ======================
|
// ====================== 步骤控制相关变量 ======================
|
||||||
const showSteps = ref(false) // 是否显示步骤条
|
const showSteps = ref(false) // 是否显示步骤条
|
||||||
@@ -626,18 +664,49 @@ const handleQuit = () => {
|
|||||||
* 处理暂停检测
|
* 处理暂停检测
|
||||||
*/
|
*/
|
||||||
const handlePause = () => {
|
const handlePause = () => {
|
||||||
sendPause() // 发送暂停指令
|
pauseCurrentItem.value = testRef.value?.getCurrentFormalItem() ?? null
|
||||||
testRef.value?.handlePause() // 调用正式检测组件的暂停方法
|
pauseConfirmVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送暂停指令
|
* 发送暂停指令
|
||||||
*/
|
*/
|
||||||
const sendPause = () => {
|
const confirmPause = async (waitCurrentItem: boolean) => {
|
||||||
|
pauseConfirmLoading.value = true
|
||||||
|
try {
|
||||||
|
const success = await sendPause(waitCurrentItem)
|
||||||
|
if (!success) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pauseConfirmVisible.value = false
|
||||||
|
testRef.value?.handlePause(waitCurrentItem)
|
||||||
|
} finally {
|
||||||
|
pauseConfirmLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendPause = async (waitCurrentItem = true) => {
|
||||||
TestStatus.value = 'paused_ing' // 设置为暂停中状态
|
try {
|
||||||
pauseTest() // 调用暂停API
|
TestStatus.value = 'paused_ing' // 设置为暂停中状态
|
||||||
|
const res: any = await pauseTest(waitCurrentItem)
|
||||||
|
if (res.code !== 'A0000') {
|
||||||
|
if (TestStatus.value === 'paused_ing') {
|
||||||
|
TestStatus.value = 'process'
|
||||||
|
}
|
||||||
|
ElMessage.error(res.message || '暂停检测失败')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (TestStatus.value !== 'paused') {
|
||||||
|
TestStatus.value = 'paused_ing'
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} catch (error: any) {
|
||||||
|
if (TestStatus.value === 'paused_ing') {
|
||||||
|
TestStatus.value = 'process'
|
||||||
|
}
|
||||||
|
ElMessage.error(error?.message || '暂停检测失败')
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -926,6 +995,15 @@ defineExpose({ open }) // 只暴露open方法供父组件调用
|
|||||||
animation: loading 1.5s linear infinite;
|
animation: loading 1.5s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pause-confirm-content {
|
||||||
|
line-height: 28px;
|
||||||
|
color: #303133;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes loading {
|
@keyframes loading {
|
||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
|
|||||||
Reference in New Issue
Block a user