预见测代码
This commit is contained in:
@@ -2,6 +2,11 @@ import type { Device } from '@/api/device/interface/device'
|
||||
import http from '@/api'
|
||||
|
||||
|
||||
export const startTest = (params) => {
|
||||
return http.post(`/prepare/startTest`, params,{ loading: false })
|
||||
export const startProTest = (params) => {
|
||||
return http.post(`/prepare/startPreTest`, params,{ loading: false })
|
||||
}
|
||||
|
||||
|
||||
export const closePreTest = (params) => {
|
||||
return http.post(`/prepare/closePreTest`, params,{ loading: false })
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export default class SocketService {
|
||||
if (message?.type && this.callBackMapping[message.type]) {
|
||||
this.callBackMapping[message.type](message);
|
||||
} else {
|
||||
console.log("抛弃")
|
||||
console.log("抛弃====>"+message)
|
||||
/* 丢弃或继续写你的逻辑 */
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
<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="检测完成" />
|
||||
<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()
|
||||
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 {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<el-step title="检测完成" :icon="stepsActiveIndex > 4 ? SuccessFilled :Key" />
|
||||
</el-steps>
|
||||
</div>
|
||||
<preTest v-if="stepsActiveIndex === 0" v-model:testStatus="preTestStatus" :webMsgSend="webMsgSend"></preTest>
|
||||
<preTest ref="preTestRef" v-if="stepsActiveIndex === 0" v-model:testStatus="preTestStatus" :webMsgSend="webMsgSend"></preTest>
|
||||
<timeTest v-if="stepsActiveIndex === 1 && isTimeCheck" v-model:testStatus="timeTestStatus"></timeTest>
|
||||
<!-- <channelsTest v-if="stepsActiveIndex === 2" v-model:testStatus="channelsTestStatus"></channelsTest> -->
|
||||
<test v-if="stepsActiveIndex >= 2" v-model:testStatus="TestStatus"></test>
|
||||
@@ -57,8 +57,9 @@
|
||||
import channelsTest from './channelsTest.vue'
|
||||
import { Device } from '@/api/device/interface/device';
|
||||
import socketClient from '@/utils/webSocketClient';
|
||||
import {startTest} from '@/api/socket/socket'
|
||||
|
||||
import {startProTest} from '@/api/socket/socket'
|
||||
import channelsTest from './channelsTest.vue'
|
||||
//import SvgIcon from '@/components/SvgIcon.vue';
|
||||
|
||||
// import preTestIcon from '@/assets/icons/preTest.svg'
|
||||
@@ -143,6 +144,7 @@ const detectionOptions = ref([
|
||||
|
||||
const dialogTitle = ref('');
|
||||
const isTimeCheck = ref(false)
|
||||
const preTestRef = ref(null);
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = (selection: Device.ResPqDev[],title: string,time:boolean) => {
|
||||
@@ -167,6 +169,11 @@ const checkStates = selection.map(item => item.checkState);
|
||||
dialogTitle.value = title;
|
||||
dialogVisible.value = true;
|
||||
isTimeCheck.value = time
|
||||
|
||||
if (preTestRef.value) {
|
||||
preTestRef.value.initializeParameters();
|
||||
}
|
||||
|
||||
preTestStatus.value = 'waiting';//预检测执行状态
|
||||
//开始创建webSocket客户端
|
||||
const data = reactive({
|
||||
@@ -189,25 +196,6 @@ const checkStates = selection.map(item => item.checkState);
|
||||
|
||||
|
||||
|
||||
/* else if(res.code === 10200){
|
||||
switch (res.operateCode){
|
||||
case 'INIT_GATHER':
|
||||
|
||||
break
|
||||
|
||||
}
|
||||
|
||||
}else if(res.code === 10201){
|
||||
switch (res.operateCode){
|
||||
case 'INIT_GATHER':
|
||||
//开始进入源初始化检测
|
||||
|
||||
|
||||
break
|
||||
|
||||
}
|
||||
|
||||
}*/
|
||||
});
|
||||
|
||||
|
||||
@@ -227,15 +215,15 @@ const checkStates = selection.map(item => item.checkState);
|
||||
text: '',
|
||||
background: 'rgb(255, 255, 255, 0)',
|
||||
})*/
|
||||
// startTest({
|
||||
// userPageId: "cdf",
|
||||
// devIds:["5eaba83670ff4d9daf892a62a5e13ea3","80b4b4f52a4c4064a18319525f8ac13c"],
|
||||
// //planId:"31cc203f3fa94fa39323ae7cc411cd66"
|
||||
// }).then(res=>{
|
||||
//
|
||||
//
|
||||
//
|
||||
// })
|
||||
startProTest({
|
||||
userPageId: "cdf",
|
||||
devIds:["5eaba83670ff4d9daf892a62a5e13ea3","80b4b4f52a4c4064a18319525f8ac13c"],
|
||||
planId:"31cc203f3fa94fa39323ae7cc411cd66"
|
||||
}).then(res=>{
|
||||
|
||||
|
||||
|
||||
})
|
||||
break;
|
||||
case 1:
|
||||
timeTestStatus.value = 'start'
|
||||
|
||||
Reference in New Issue
Block a user