合并frontend/src/views/home/components/testPopup.vue

This commit is contained in:
sjl
2025-02-26 10:54:43 +08:00
2 changed files with 46 additions and 39 deletions

View File

@@ -9,11 +9,11 @@
<span>检测用时{{ timeView }}</span> <span>检测用时{{ timeView }}</span>
</div> </div>
<el-progress <el-progress
style="width: 50%; margin-right: 15px;" style="width: 60%; margin-right: 4%;"
:percentage="percentage" :percentage="percentage"
:color="customColors"/> :color="customColors"/>
<div style="width: 12%"> <div style="width: 15%">
<el-button type="primary" v-if="testStatus=='test_init'" disabled @click="handlePause()"> <el-button type="primary" v-if="testStatus=='test_init'" disabled @click="handlePause()">
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;"> <el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
<component :is="Refresh"/> <component :is="Refresh"/>
@@ -51,12 +51,12 @@
<!-- :icon="Failed"--> <!-- :icon="Failed"-->
<!-- disabled>连接超时--> <!-- disabled>连接超时-->
<!-- </el-button>--> <!-- </el-button>-->
<el-button <!-- <el-button-->
type="primary" <!-- type="primary"-->
:icon="RefreshLeft" <!-- :icon="RefreshLeft"-->
v-if="testStatus === 'test_recheck'" <!-- v-if="testStatus === 'recheck'"-->
@click="emit('sendReCheck')">重新检测 <!-- @click="emit('sendReCheck')">重新检测-->
</el-button> <!-- </el-button>-->
<el-button type="success" v-if="percentage >= 100" :icon="Check" disabled>检测完成</el-button> <el-button type="success" v-if="percentage >= 100" :icon="Check" disabled>检测完成</el-button>
@@ -328,16 +328,19 @@ watch(testStatus, function (newValue, oldValue) {
showTestLog() showTestLog()
if (oldValue == 'error') { // if (oldValue == 'recheck' || oldValue == 'error' || oldValue == 'test_init_fail' || oldValue == 'connect_timeout' || oldValue == 'pause_timeout' || oldValue == 'error_flow_end') {
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!`}) // handleReCheck()
handleReCheck() // }
}
emit('update:testStatus', 'test_init') emit('update:testStatus', 'test_init')
//startTimer() // todo 可移除 //startTimer() // todo 可移除
startData.value = new Date(); startData.value = new Date();
timeDifference.value = 0; timeDifference.value = 0;
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化开始!`}) testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化开始!`})
} }
if (newValue == 'recheck' || newValue == 'error' || newValue == 'test_init_fail' || newValue == 'connect_timeout' || newValue == 'pause_timeout' || oldValue == 'error_flow_end') {
stopTimeCount()
}
}) })
// 次数 // 次数
@@ -429,7 +432,8 @@ watch(webMsgSend, function (newValue, oldValue) {
type: 'error', type: 'error',
log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!` log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!`
}) })
emit('update:testStatus', 'test_recheck') // emit('update:testStatus', 'recheck')
emit('update:testStatus', 'test_init_fail')
} else { } else {
switch (newValue.requestId) { switch (newValue.requestId) {
case 'server_error': case 'server_error':
@@ -552,7 +556,7 @@ watch(webMsgSend, function (newValue, oldValue) {
case 'Resume_Success': case 'Resume_Success':
ElMessage.success('开始继续检测') ElMessage.success('开始继续检测')
emit('update:testStatus', 'process') emit('update:testStatus', 'process')
handleResumeTest() //handleResumeTest()
break; break;
// case 'Resume_Fail': // case 'Resume_Fail':
// ElMessage.error('无法继续检测') // ElMessage.error('无法继续检测')
@@ -662,7 +666,7 @@ const handleEndItem = (code: string, desc: string | undefined, devices: CheckDat
} else { } else {
let result = getResult(devices) let result = getResult(devices)
if (desc.length > 150) { if (desc.length > 150) {
desc = desc.substring(0, 150) + '...' desc = desc.substring(0,150) + '...'
} }
if (result === 1) { if (result === 1) {
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}${desc}检测结束:符合`}) testLogList.push({type: 'info', log: `${new Date().toLocaleString()}${desc}检测结束:符合`})
@@ -1260,7 +1264,7 @@ const todoItem = (code: string) => {
if (testStatus.value !== 'paused') { if (testStatus.value !== 'paused') {
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: `${code}_Start`, requestId: `${code}_Start`,
desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° '
}) })
} }
}, 1000) }, 1000)
@@ -1268,7 +1272,7 @@ const todoItem = (code: string) => {
if (testStatus.value !== 'paused') { if (testStatus.value !== 'paused') {
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: `${code}_End`, requestId: `${code}_End`,
desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', desc: '输入频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
data: [{ data: [{
chnResult: [1, 1, 1, 1], chnResult: [1, 1, 1, 1],
deviceId: "3250a0ff180845cc8885da4ff628261e", deviceId: "3250a0ff180845cc8885da4ff628261e",
@@ -1281,7 +1285,7 @@ const todoItem = (code: string) => {
if (testStatus.value !== 'paused') { if (testStatus.value !== 'paused') {
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: `${code}_Start`, requestId: `${code}_Start`,
desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° '
}) })
} }
}, 3000) }, 3000)
@@ -1289,7 +1293,7 @@ const todoItem = (code: string) => {
if (testStatus.value !== 'paused') { if (testStatus.value !== 'paused') {
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: `${code}_End`, requestId: `${code}_End`,
desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', desc: '输入频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
data: [{ data: [{
chnResult: [1, 1, 1, 1], chnResult: [1, 1, 1, 1],
deviceId: "3250a0ff180845cc8885da4ff628261e", deviceId: "3250a0ff180845cc8885da4ff628261e",
@@ -1302,7 +1306,7 @@ const todoItem = (code: string) => {
if (testStatus.value !== 'paused') { if (testStatus.value !== 'paused') {
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: `${code}_Start`, requestId: `${code}_Start`,
desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° '
}) })
} }
}, 6000) }, 6000)
@@ -1310,7 +1314,7 @@ const todoItem = (code: string) => {
if (testStatus.value !== 'paused') { if (testStatus.value !== 'paused') {
emit('update:webMsgSend', { emit('update:webMsgSend', {
requestId: `${code}_End`, requestId: `${code}_End`,
desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', desc: '输入频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ',
data: [{ data: [{
chnResult: [1, 1, 1, 1], chnResult: [1, 1, 1, 1],
deviceId: "3250a0ff180845cc8885da4ff628261e", deviceId: "3250a0ff180845cc8885da4ff628261e",
@@ -1336,11 +1340,8 @@ const todoItem = (code: string) => {
const handleResumeTest = () => { const handleResumeTest = () => {
//activeIndex++ //activeIndex++
startData.value = new Date(); startData.value = new Date();
testLogList.push({ testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!`})
type: 'info', startTimer()
log: `${new Date().toLocaleString()}:继续检测`,
})
//startTimer()
resumeTimeCount() resumeTimeCount()
console.log('开始继续检测') console.log('开始继续检测')
}; };
@@ -1353,10 +1354,12 @@ const handleReCheck = () => {
timeView.value = '00:00:00' timeView.value = '00:00:00'
timeDifference.value = 0 timeDifference.value = 0
testLogList.length = 0 testLogList.length = 0
errorCheckItem.length = 0 errorCheckItem.length = 0
count = 0 count = 0
showTestLog() showTestLog()
handleResumeTest()
} }
// 获取当前执行的大测试项序号 // 获取当前执行的大测试项序号
@@ -1382,10 +1385,12 @@ const getNextActiveIndex = (code: string = ''): number => {
return -1 return -1
} }
const startTimeCount = () => { const startTimeCount = () => {
if(!timer){
timer = setInterval(() => { timer = setInterval(() => {
timeCount.value = timeCount.value + 1 timeCount.value = timeCount.value + 1
timeView.value = secondToTime(timeCount.value) timeView.value = secondToTime(timeCount.value)
}, 1000) }, 1000)
}
} }
const stopTimeCount = () => { const stopTimeCount = () => {

View File

@@ -37,7 +37,7 @@
<!-- 检测中--> <!-- 检测中-->
<!-- </el-button>--> <!-- </el-button>-->
<el-button type="warning" :icon="VideoPlay" v-if="TestStatus === 'paused'" @click="handleSubmit">继续检测</el-button> <el-button type="warning" :icon="VideoPlay" v-if="TestStatus === 'paused'" @click="handleSubmit">继续检测</el-button>
<el-button type="primary" :icon="RefreshLeft" v-if="TestStatus === 'test_recheck'" @click="handleSubmit">重新检测</el-button> <!-- <el-button type="primary" :icon="RefreshLeft" v-if="ActiveStatue === 'recheck' || ActiveStatue ==='error' || ActiveStatue ==='test_init_fail' || ActiveStatue === 'pause_timeout' || ActiveStatue === 'connect_timeout'" @click="handleSubmit">重新检测</el-button>-->
<el-button type="primary" v-if="TestStatus === 'test_init'" disabled> <el-button type="primary" v-if="TestStatus === 'test_init'" disabled>
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;"> <el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
<component :is="Refresh"/> <component :is="Refresh"/>
@@ -65,7 +65,7 @@
<script lang="tsx" setup name="testPopup"> <script lang="tsx" setup name="testPopup">
import {reactive, ref, watch} from 'vue'; import {reactive, ref, watch} from 'vue';
import {ElMessage, ElMessageBox} from 'element-plus' import {ElMessage, ElMessageBox} from 'element-plus'
import {Coin, DArrowRight, Edit, Key, Odometer, Refresh, RefreshLeft, Right, SuccessFilled, UploadFilled, VideoPlay} from '@element-plus/icons-vue' import {Coin, DArrowRight, Edit, Key, Odometer, Refresh, Right, SuccessFilled, UploadFilled, VideoPlay} from '@element-plus/icons-vue'
import preTest from './preTest.vue' import preTest from './preTest.vue'
import timeTest from './timeTest.vue' import timeTest from './timeTest.vue'
import factorTest from './factorTest.vue' import factorTest from './factorTest.vue'
@@ -228,10 +228,11 @@ const handleSubmit = () => {
} else if (TestStatus.value == 'paused') { } else if (TestStatus.value == 'paused') {
// 发送继续指令 // 发送继续指令
sendResume() sendResume()
} else if (TestStatus.value == 'test_recheck') {
// 发送重新检测指令
sendReCheck()
} }
// else if (TestStatus.value == 'recheck') {
// // 发送重新检测指令
// sendReCheck()
// }
// else if (TestStatus.value == 'success') { // else if (TestStatus.value == 'success') {
// handleClose() // handleClose()
// } // }
@@ -272,7 +273,7 @@ watch(ActiveStatue, function (newValue, oldValue) {
// stepsActiveIndex.value = stepsTotalNum.value + 2 // stepsActiveIndex.value = stepsTotalNum.value + 2
nextStepText.value = '检测失败' nextStepText.value = '检测失败'
} }
if (newValue === 'success' && stepsActive.value === stepsTotalNum.value-1) { if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
stepsActiveIndex.value += 2 stepsActiveIndex.value += 2
nextStepText.value = '检测完成' nextStepText.value = '检测完成'
} }
@@ -286,7 +287,8 @@ watch(ActiveStatue, function (newValue, oldValue) {
} }
if (newValue === 'pause_timeout' ) { if (newValue === 'pause_timeout' ) {
stepsActiveIndex.value += 2 stepsActiveIndex.value += 2
nextStepText.value = '结束测试' // nextStepText.value = '结束测试'
nextStepText.value = '暂停超时'
} }
if (newValue === 'success' && nextStepText.value === '下一步') { if (newValue === 'success' && nextStepText.value === '下一步') {
nextStep() // 实现自动点击,进入下一个测试内容 nextStep() // 实现自动点击,进入下一个测试内容
@@ -346,7 +348,7 @@ const sendReCheck = () => {
} }
const nextStep = () => { const nextStep = () => {
if (stepsActiveIndex.value == stepsTotalNum.value + 1 || ActiveStatue.value === 'error') { if (stepsActiveIndex.value == stepsTotalNum.value + 1 || ActiveStatue.value === 'error' || ActiveStatue.value === 'test_init_fail' || ActiveStatue.value === 'connect_timeout' || ActiveStatue.value === 'pause_timeout') {
handleClose() handleClose()
return return
} }