预见测代码

This commit is contained in:
2024-12-23 21:02:00 +08:00
parent f17f5c9925
commit 24f12a3590
4 changed files with 232 additions and 78 deletions

View File

@@ -13,12 +13,12 @@
<div class="test-dialog">
<div class="dialog-left">
<el-steps direction="vertical" :active="activeIndex" :process-status="currentStepStatus"
finish-status="success">
<el-step title="源通讯校验" />
<el-step title="设备通讯校验" />
<el-step title="协议校验" />
<el-step title="相序校验" />
<el-step title="检测完成" />
finish-status="success">
<el-step :status="step1" title="源通讯校验" />
<el-step :status="step2" title="设备通讯校验" />
<el-step :status="step3" title="协议校验" />
<el-step :status="step4" title="相序校验" />
<el-step :status="step5" title="检测完成" />
</el-steps>
</div>
<div class="dialog-right">
@@ -63,7 +63,7 @@
</template>
<script lang="tsx" setup name="preTest">
import {ElMessage} from "element-plus";
import { defineExpose } from 'vue';
const step1InitLog = ref([
{
type: 'info',
@@ -160,6 +160,12 @@ const step4Log = ref([
const collapseActiveName = ref('1')
const activeIndex = ref(0)
const activeTotalNum = ref(5)
const step1 = ref('wait')
const step2 = ref('wait')
const step3 = ref('wait')
const step4 = ref('wait')
const step5 = ref('wait')
//定义与预检测配置数组
const detectionOptions = ref([
{
@@ -224,7 +230,7 @@ const webMsgSend = toRef(props, 'webMsgSend');
const ts = ref('');
watch(webMsgSend,function (newValue,oldValue){
console.log(newValue)
// console.log(newValue)
switch (newValue.requestId){
case 'yjc_ytxjy':
@@ -235,14 +241,19 @@ watch(webMsgSend,function (newValue,oldValue){
type: 'info',
log: '源校验成功!',
})
activeIndex.value++
activeIndex.value = 1
step1.value = 'success'
step2.value = 'process'
}else if(newValue.code == 10201){
step1.value = 'process'
step1InitLog.value = [{
type: 'wait',
log: '正在进行源校验!',
}];
}else if(newValue.code == 10552){
ElMessage.error(newValue.code)
step1.value = 'error'
ts.value = 'error'
}
break;
@@ -262,14 +273,23 @@ watch(webMsgSend,function (newValue,oldValue){
})
} else if (newValue.code == 10201) {
step2.value = 'process'
step2InitLog.value = [{
type: 'wait',
log: '正在进行设备通讯校验.....',
}];
} else if (newValue.code == 10552) {
ElMessage.error(newValue.code)
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
step2InitLog.value = [{
type: 'wait',
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
}];
step2.value = 'error'
ts.value = 'error'
} else if (newValue.code == 25001) {
activeIndex.value++
activeIndex.value = 2
step2.value = 'success'
step3.value = 'process'
}
break;
}
@@ -277,6 +297,29 @@ watch(webMsgSend,function (newValue,oldValue){
break;
case 'yjc_xyjy':
switch (newValue.operateCode) {
case 'INIT_GATHER$01':
if (newValue.code == 10200) {
step3InitLog.value.push({
type: 'info',
log: '统计数据协议校验:'+newValue.data+'通讯协议校验成功!',
})
} else if (newValue.code == 10201) {
step3.value = 'process'
step3InitLog.value = [{
type: 'wait',
log: '正在进行通讯协议校验.....',
}];
} else if (newValue.code == 10552) {
step3.value = 'error'
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
step3InitLog.value = [{
type: 'wait',
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
}];
ts.value = 'error'
}
break;
case 'INIT_GATHER$02':
if (newValue.code == 10200) {
step3InitLog.value.push({
@@ -285,12 +328,19 @@ watch(webMsgSend,function (newValue,oldValue){
})
} else if (newValue.code == 10201) {
step3.value = 'process'
step3InitLog.value = [{
type: 'wait',
log: '正在进行通讯协议校验.....',
}];
} else if (newValue.code == 10552) {
ElMessage.error(newValue.code)
step3.value = 'error'
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
step3InitLog.value = [{
type: 'wait',
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
}];
ts.value = 'error'
}
break;
case 'INIT_GATHER$03':
@@ -301,19 +351,105 @@ watch(webMsgSend,function (newValue,oldValue){
})
} else if (newValue.code == 10201) {
step3.value = 'process'
} else if (newValue.code == 10552) {
ElMessage.error(newValue.code)
//ElMessage.error("当前步骤已经初始化,执行自动关闭,请重新发起检测!")
step3.value = 'error'
step3InitLog.value = [{
type: 'wait',
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
}];
ts.value = 'error'
} else if (newValue.code == 25001) {
activeIndex.value++
activeIndex.value = 3
step3.value = 'success'
step4.value = 'process'
}
break;
}
break;
case 'YJC_xujy':
switch (newValue.operateCode) {
case 'OPER_GATHER':
if (newValue.code == 10200) {
step4InitLog.value.push({
type: 'info',
log: '源已接通!',
})
} else if (newValue.code == 10201) {
step4.value = 'process'
step4InitLog.value = [{
type: 'wait',
log: '正在接通源.....',
}];
} else if (newValue.code == 10552) {
ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
step4.value = 'error'
ts.value = 'error'
} else if (newValue.code == 10520) {
step4.value = 'error'
step4InitLog.value.push({
type: 'error',
log: '解析报文异常',
})
ts.value = 'error'
}
break;
case 'DATA_REQUEST$02':
if (newValue.code == 10200) {
step4InitLog.value.push({
type: 'info',
log: '相序校验:'+newValue.data,
})
} else if (newValue.code == 10201) {
step4.value = 'process'
step4InitLog.value = [{
type: 'wait',
log: '获取数据相序校验数据!',
}];
}
else if (newValue.code == 25001) {
step4.value = 'success'
step5.value = 'success'
step4InitLog.value.push({
type: 'wait',
log: '相序校验成功!',
})
}
activeIndex.value = 5
ts.value = 'success'
break
}
break;
case 'quit':
break;
case 'connect':
switch (newValue.operateCode){
case "Source":
step1.value = 'error'
step1InitLog.value = [{
type: 'error',
log: '源服务端连接失败!',
}];
ts.value = 'error'
break;
case "Dev":
step2.value = 'error'
step2InitLog.value = [{
type: 'error',
log: '设备服务端连接失败!',
}];
ts.value = 'error'
break;
}
break;
}
@@ -322,45 +458,19 @@ watch(webMsgSend,function (newValue,oldValue){
})
watch(activeIndex, function (newValue, oldValue) {
if (newValue <= activeTotalNum.value - 2)
console.log(activeIndex.value)
if (activeIndex.value === 1) {
}
if (activeIndex.value === 2) {
}
if (activeIndex.value === 3) {
}
if (activeIndex.value > 3) {
}
if (activeIndex.value < activeTotalNum.value - 2)
collapseActiveName.value = (newValue + 1).toString()
collapseActiveName.value = (newValue+1).toString()
else
collapseActiveName.value = (activeTotalNum.value - 1).toString()
collapseActiveName.value = (newValue - 1).toString()
})
//监听goods_sn的变化
watch(testStatus, function (newValue, oldValue) {
ts.value = props.testStatus;
if (ts.value === 'start') {
ts.value = 'process'
/*let timer = setInterval(() => {
if (activeIndex.value < activeTotalNum.value - 2)
activeIndex.value++
else if (activeIndex.value === activeTotalNum.value - 2) {
activeIndex.value++
activeIndex.value++
}
else {
clearInterval(timer)
ts.value = 'success'
}
}, 1500);*/
}else if(ts.value === 'waiting'){
activeIndex.value = 0
step1InitLog.value = [
@@ -369,6 +479,11 @@ watch(testStatus, function (newValue, oldValue) {
log: '暂无数据,等待检测开始',
},
]
step1.value = 'finish'
step2.value = 'wait'
step3.value = 'wait'
step4.value = 'wait'
step5.value = 'wait'
}
})
@@ -379,6 +494,52 @@ watch(ts, function (newValue, oldValue) {
emit('update:testStatus', ts.value)
})
// 定义一个初始化参数的方法
function initializeParameters() {
activeIndex.value = 0
step1.value = 'process'
step2.value = 'wait'
step3.value = 'wait'
step4.value = 'wait'
step5.value = 'wait'
step1InitLog.value = [
{
type: 'info',
log: '暂无数据,等待检测开始',
},
]
step2InitLog.value = [
{
type: 'info',
log: '暂无数据,等待检测开始',
},
]
step3InitLog.value = [
{
type: 'info',
log: '暂无数据,等待检测开始',
},
]
step4InitLog.value = [
{
type: 'info',
log: '暂无数据,等待检测开始',
},
]
}
defineExpose({
initializeParameters,
});
</script>
<style scoped lang="scss">
.test-dialog {