Browse Source

修改设备自检

master
王梦远 3 weeks ago
parent
commit
4601e3d24d
  1. 56
      src/components/home/Check/index.vue
  2. 4
      src/views/main/index.vue

56
src/components/home/Check/index.vue

@ -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>

4
src/views/main/index.vue

@ -26,7 +26,7 @@ const getStatus = async () => {
await getDeviceStatus().then((res: any) => {
systemStore.updateSystemStatus(res)
if (!systemStore.systemStatus.selfTestCompleted && import.meta.env.FT_NODE_ENV !== 'test') {
ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
ElMessageBox.confirm('检测到设备未完成初始化及自检,是否开始?', '提示', {
type: 'warning',
confirmButtonText: '确定',
showCancelButton: false,
@ -221,7 +221,7 @@ const nozzleSwitch = async () => {
})
}
else {
FtMessage.warning('喷头加热已关闭')
FtMessage.warning('喷头加热已关闭')
}
}

Loading…
Cancel
Save