预检测
This commit is contained in:
@@ -3,17 +3,22 @@
|
||||
|
||||
<div class="steps-container">
|
||||
<el-steps v-if="showSteps" class="test-head-steps" simple :active="stepsActiveIndex" process-status="finish" finish-status="success">
|
||||
<el-step v-if="preTestSelected" title="预检测" :icon="stepsActive > 1 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled :Edit" @click="handleStepClick(1)"/>
|
||||
|
||||
<el-step v-if="testSelected" title="正式检测" :icon="stepsActive > 2 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled :Coin" @click="handleStepClick(2)"/>
|
||||
<el-step title="检测完成" :icon="stepsActiveIndex > stepsTotalNum-1 ? SuccessFilled :Key"/>
|
||||
<el-step v-if="preTestSelected" title="预检测" :icon="stepsActive > 1 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled : Edit" @click="handleStepClick(1)"/>
|
||||
|
||||
<el-step v-if="testSelected" title="正式检测" :icon="stepsActive > 2 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled : Coin" @click="handleStepClick(2)"/>
|
||||
<el-step title="检测完成" :icon="stepsActiveIndex > stepsTotalNum - 1 ? SuccessFilled : Key"/>
|
||||
</el-steps>
|
||||
</div>
|
||||
|
||||
<ComparePreTest v-if="showComponent&&preTestSelected" v-show="preTestSelected && stepsActiveView==1" ref="preTestRef" v-model:testStatus="preTestStatus"
|
||||
<keep-alive>
|
||||
<ComparePreTest v-if="preTestSelected && stepsActiveView==1" ref="preTestRef" v-model:testStatus="preTestStatus"
|
||||
:webMsgSend="webMsgSend" :mapping = "channelMapping"/>
|
||||
<CompareTest v-if="showComponent&&testSelected" ref="testRef" v-show="testSelected && stepsActiveView==2" v-model:testStatus="TestStatus"
|
||||
</keep-alive>
|
||||
<keep-alive>
|
||||
<CompareTest v-if="testSelected && stepsActiveView==2" ref="testRef" v-model:testStatus="TestStatus"
|
||||
:stepsActive="stepsActive"/>
|
||||
</keep-alive>
|
||||
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button type="primary" :icon="VideoPlay" v-if="ActiveStatue === 'waiting'" @click="handleSubmitFast">开始检测</el-button>
|
||||
@@ -42,7 +47,10 @@
|
||||
@click="sendResume"
|
||||
>继续检测
|
||||
</el-button>
|
||||
|
||||
<el-button type="warning" :icon="VideoPlay"
|
||||
v-if="nextStepText !== '下一步' && (ActiveStatue === 'success'||ActiveStatue==='error'||ActiveStatue==='test_init_fail'||ActiveStatue==='connect_timeout'||ActiveStatue==='pause_timeout')"
|
||||
@click="handleSubmitAgain">重新检测
|
||||
</el-button>
|
||||
<el-button :type="ActiveStatue==='success'?'primary':'danger'" :icon="Right"
|
||||
v-if="nextStepText !== '下一步' && (ActiveStatue === 'success'||ActiveStatue==='error'||ActiveStatue==='test_init_fail'||ActiveStatue==='connect_timeout'||ActiveStatue==='pause_timeout')"
|
||||
@click="nextStep">
|
||||
@@ -54,12 +62,10 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup name="testPopup">
|
||||
import {reactive, ref, watch} from 'vue';
|
||||
import {nextTick, reactive, ref, watch} from 'vue';
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {Coin, Edit, Key, Odometer, Refresh, Right, SuccessFilled, UploadFilled, VideoPause, VideoPlay} from '@element-plus/icons-vue'
|
||||
import ComparePreTest from './comparePreTest.vue'
|
||||
@@ -79,7 +85,7 @@ const dialogVisible = ref(false)
|
||||
const showSteps = ref(false)
|
||||
const stepsTotalNum = ref(-1);//步骤总数
|
||||
const stepsActiveIndex = ref(1); //当前正在执行的步骤索引
|
||||
const stepsActiveView = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
|
||||
const stepsActiveView = ref(1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
|
||||
const stepsActive = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,实际记录步骤的状态,用于切换步骤
|
||||
const ActiveStatue = ref('waiting');//当前步骤状态
|
||||
const preTestStatus = ref('waiting');//预检测执行状态
|
||||
@@ -89,7 +95,7 @@ const webMsgSend = ref();//webSocket推送的数据
|
||||
|
||||
const dialogTitle = ref('')
|
||||
const showComponent = ref(true)
|
||||
const preTestRef = ref(null)
|
||||
const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
|
||||
const testRef = ref(null)
|
||||
|
||||
const dataSocket = reactive({
|
||||
@@ -97,7 +103,7 @@ const dataSocket = reactive({
|
||||
});
|
||||
|
||||
// 勾选的检测内容
|
||||
const preTestSelected = ref(false)
|
||||
const preTestSelected = ref(true)
|
||||
const testSelected = ref(false)
|
||||
|
||||
const initOperate = () => {
|
||||
@@ -138,7 +144,11 @@ const loginName = ref('')
|
||||
const devIds = ref<[]>()
|
||||
const standardDevIds = ref<[]>()
|
||||
const pairs = ref<any>()
|
||||
const open = (title: string,mapping:any,plan: string,login: string,devIdsArray: [],standardDevIdsArray: [],pair:any) => {
|
||||
const testAgain = ref(false)//重新检测按钮是否显示
|
||||
const open = async (title: string,mapping:any,plan: string,login: string,devIdsArray: [],standardDevIdsArray: [],pair:any) => {
|
||||
if(checkStore.selectTestItems.preTest && !checkStore.selectTestItems.test){
|
||||
testAgain.value = true
|
||||
}
|
||||
channelMapping.value = mapping
|
||||
planId.value = plan
|
||||
loginName.value = login
|
||||
@@ -150,6 +160,9 @@ const open = (title: string,mapping:any,plan: string,login: string,devIdsArray:
|
||||
dialogTitle.value = title;
|
||||
dialogVisible.value = true;
|
||||
|
||||
// 等待组件渲染完成
|
||||
await nextTick();
|
||||
|
||||
if (preTestRef.value) {
|
||||
preTestRef.value.initializeParameters();
|
||||
}
|
||||
@@ -159,7 +172,6 @@ const open = (title: string,mapping:any,plan: string,login: string,devIdsArray:
|
||||
dataSocket.socketServe = socketClient.Instance;
|
||||
dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
|
||||
// 处理来自服务器的消息
|
||||
// console.log('Received message:', res);
|
||||
if (res.code === 20000) {
|
||||
//ElMessage.error(message.message)
|
||||
// loading.close()
|
||||
@@ -169,12 +181,48 @@ const open = (title: string,mapping:any,plan: string,login: string,devIdsArray:
|
||||
});
|
||||
}
|
||||
|
||||
//预检测-重新检测
|
||||
const handleSubmitAgain = async () => {
|
||||
stepsActiveIndex.value = 1
|
||||
stepsActiveView.value = 1
|
||||
stepsActive.value = 1
|
||||
let count = 0
|
||||
for (let key in checkStore.selectTestItems) {
|
||||
if (checkStore.selectTestItems[key]) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
stepsTotalNum.value = count + 1
|
||||
|
||||
// 通知子组件清空并重新初始化
|
||||
if (preTestRef.value) {
|
||||
preTestRef.value.initializeParameters();
|
||||
}
|
||||
|
||||
// 重置状态
|
||||
ActiveStatue.value = 'waiting'
|
||||
preTestStatus.value = 'waiting'
|
||||
|
||||
|
||||
await contrastTest({
|
||||
planId: planId.value,
|
||||
loginName: loginName.value,
|
||||
devIds: devIds.value,
|
||||
standardDevIds: standardDevIds.value,
|
||||
pairs:pairs.value,
|
||||
testItemList:[checkStore.selectTestItems.preTest,false,checkStore.selectTestItems.test]
|
||||
})
|
||||
|
||||
preTestStatus.value = 'start'
|
||||
};
|
||||
|
||||
//开始检测
|
||||
const handleSubmitFast = async () => {
|
||||
if (!dataSocket.socketServe.connected) {
|
||||
ElMessage.error('webSocket连接中断!')
|
||||
return
|
||||
}
|
||||
console.log("handleSubmit", stepsActive.value, TestStatus.value)
|
||||
console.log("handleSubmit", TestStatus.value)
|
||||
switch (stepsActive.value) {
|
||||
case 1:
|
||||
if (preTestStatus.value == 'waiting') {
|
||||
@@ -212,18 +260,24 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
watch(preTestStatus, function (newValue, oldValue) {
|
||||
console.log('预检测',newValue, oldValue);
|
||||
|
||||
console.log('预检测状态',newValue, oldValue);
|
||||
ActiveStatue.value = newValue
|
||||
})
|
||||
|
||||
watch(TestStatus, function (newValue, oldValue) {
|
||||
console.log(newValue, oldValue);
|
||||
console.log('正式检测状态',newValue, oldValue);
|
||||
|
||||
ActiveStatue.value = newValue
|
||||
})
|
||||
|
||||
watch(stepsActiveIndex, function (newValue, oldValue) {
|
||||
console.log('步骤索引',newValue, oldValue);
|
||||
})
|
||||
|
||||
watch(ActiveStatue, function (newValue, oldValue) {
|
||||
console.log('当前步骤状态-----',newValue);
|
||||
console.log('stepsActiveIndex-----',stepsActiveIndex.value);
|
||||
console.log('stepsTotalNum----',stepsTotalNum.value);
|
||||
if (newValue === 'error') {
|
||||
stepsActiveIndex.value = stepsTotalNum.value + 1
|
||||
nextStepText.value = '检测失败'
|
||||
@@ -247,8 +301,7 @@ watch(ActiveStatue, function (newValue, oldValue) {
|
||||
}
|
||||
if (newValue === 'success' && stepsActiveIndex.value < stepsTotalNum.value - 1) {
|
||||
nextStep() // 实现自动点击,进入下一个测试内容
|
||||
//handleSubmit()
|
||||
handleSubmitFast()
|
||||
//handleSubmitFast()
|
||||
}
|
||||
|
||||
})
|
||||
@@ -327,17 +380,21 @@ const nextStep = () => {
|
||||
if (ActiveStatue.value != 'error') {
|
||||
ActiveStatue.value = 'waiting'
|
||||
let tempStep = stepsActiveIndex.value
|
||||
let idx = 1
|
||||
let idx = -1
|
||||
stepsActiveIndex.value++
|
||||
for (let selectTestItemsKey in checkStore.selectTestItems) {
|
||||
if (tempStep == 0 && checkStore.selectTestItems[selectTestItemsKey]) {
|
||||
console.log('selectTestItemsKey1')
|
||||
stepsActiveView.value = idx
|
||||
stepsActive.value = idx
|
||||
console.log('stepsActiveView.value999', stepsActiveView.value)
|
||||
return
|
||||
}
|
||||
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
|
||||
console.log('selectTestItemsKey2')
|
||||
tempStep--
|
||||
}
|
||||
console.log('selectTestItemsKey3',idx)
|
||||
idx++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user