|
|
@ -2,6 +2,7 @@ |
|
|
|
import { deviceSelfTestFinish, getDeviceSelfTest } from 'apis/system' |
|
|
|
import FtDialog from 'components/common/FTDialog/index.vue' |
|
|
|
import { ElMessageBox } from 'element-plus' |
|
|
|
import { FtMessage } from 'libs/message' |
|
|
|
import { socket } from 'libs/socket' |
|
|
|
import { sendControl } from 'libs/utils' |
|
|
|
import { onMounted, ref, watch } from 'vue' |
|
|
@ -38,7 +39,7 @@ const receiveMessageSelfMove = (data: any) => { |
|
|
|
checkTextList.value.push(data) |
|
|
|
percentage.value = data.schedule |
|
|
|
if (data.type === 'error') { |
|
|
|
selfAgain.value = true |
|
|
|
checkStartBtnDisabled.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
const cmdIds: any = {} |
|
|
@ -89,13 +90,26 @@ const addTextToCheckList = async (text: string, id: number) => { |
|
|
|
const activeStep = ref(0) |
|
|
|
const percentage = ref(0) |
|
|
|
const checkTextList = ref<{ title: string, type: 'success' | 'error' }[]>([]) |
|
|
|
const selfAgain = ref(false) |
|
|
|
const checkStartBtnDisabled = ref(false) |
|
|
|
|
|
|
|
let currentCommandId = '' |
|
|
|
const checkHandle = async () => { |
|
|
|
activeStep.value = 1 |
|
|
|
} |
|
|
|
watch(percentage, (newValue) => { |
|
|
|
if (newValue === 100) { |
|
|
|
const timer = setTimeout(() => { |
|
|
|
FtMessage.success('设备自检已完成') |
|
|
|
onClose() |
|
|
|
clearTimeout(timer) |
|
|
|
}, 1500) |
|
|
|
} |
|
|
|
}) |
|
|
|
const checkAgain = async () => { |
|
|
|
checkStartBtnDisabled.value = true |
|
|
|
checkTextList.value = [] |
|
|
|
await ElMessageBox.confirm( |
|
|
|
'设备即将开始自检', |
|
|
|
'设备即将开始自检,请确认X、Y、Z轴电机行程无异物!', |
|
|
|
'提示', |
|
|
|
{ |
|
|
|
confirmButtonText: '确认', |
|
|
@ -115,39 +129,15 @@ const checkHandle = async () => { |
|
|
|
} |
|
|
|
await sendControl(params) |
|
|
|
} |
|
|
|
watch(percentage, (newValue) => { |
|
|
|
if (newValue === 100) { |
|
|
|
const timer = setTimeout(() => { |
|
|
|
selfAgain.value = true |
|
|
|
clearTimeout(timer) |
|
|
|
}, 300) |
|
|
|
} |
|
|
|
else { |
|
|
|
selfAgain.value = false |
|
|
|
} |
|
|
|
}) |
|
|
|
const checkAgain = async () => { |
|
|
|
checkTextList.value = [] |
|
|
|
currentCommandId = Date.now().toString() |
|
|
|
const params = { |
|
|
|
cmdId: currentCommandId, |
|
|
|
cmdCode: 'move_test', |
|
|
|
params: {}, |
|
|
|
} |
|
|
|
await sendControl(params) |
|
|
|
} |
|
|
|
const onClose = async () => { |
|
|
|
await deviceSelfTestFinish() |
|
|
|
emits('ok') |
|
|
|
checkStartBtnDisabled.value = false |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<FtDialog visible title="设备初始化" width="600px"> |
|
|
|
<el-steps style="max-width: 600px;margin-bottom: 10px" :active="activeStep" finish-status="success" align-left> |
|
|
|
<el-step title="初始化" /> |
|
|
|
<el-step title="自检" /> |
|
|
|
</el-steps> |
|
|
|
<FtDialog visible :title="activeStep === 0 ? '设备初始化' : '设备自检'" width="600px"> |
|
|
|
<div v-if="activeStep === 0" class="check-main"> |
|
|
|
<div v-for="(item, index) in checkList" :key="item.id" class="check-item"> |
|
|
|
<el-tag> {{ item.title }}</el-tag> |
|
|
@ -186,11 +176,11 @@ const onClose = async () => { |
|
|
|
<FtButton v-if="activeStep === 0 && checkList.every((item:any) => ['success', 'ignore'].includes(item.result))" type="primary" :click-handle="checkHandle"> |
|
|
|
下一步 |
|
|
|
</FtButton> |
|
|
|
<FtButton v-if="activeStep === 1 && selfAgain" type="primary" :click-handle="checkAgain"> |
|
|
|
重新自检 |
|
|
|
<FtButton v-if="activeStep === 1" type="primary" :disabled="checkStartBtnDisabled" :click-handle="checkAgain"> |
|
|
|
开始自检 |
|
|
|
</FtButton> |
|
|
|
<FtButton v-if="activeStep === 1 && percentage === 100" :click-handle="onClose"> |
|
|
|
关闭 |
|
|
|
<FtButton v-if="activeStep === 1" :click-handle="onClose" :disabled="checkStartBtnDisabled"> |
|
|
|
跳过自检 |
|
|
|
</FtButton> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|