|
|
@ -1,10 +1,10 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { getDeviceSelfTest } from 'apis/system' |
|
|
|
import { deviceSelfTestFinish, getDeviceSelfTest } from 'apis/system' |
|
|
|
import FtDialog from 'components/common/FTDialog/index.vue' |
|
|
|
import { FtMessage } from 'libs/message' |
|
|
|
import { socket } from 'libs/socket' |
|
|
|
import { sendControl } from 'libs/utils' |
|
|
|
import { nextTick, onMounted, ref } from 'vue' |
|
|
|
import { onMounted, ref, watch } from 'vue' |
|
|
|
|
|
|
|
const emits = defineEmits(['ok', 'cancel']) |
|
|
|
|
|
|
@ -28,9 +28,9 @@ onMounted(async () => { |
|
|
|
|
|
|
|
const change = async () => { |
|
|
|
let num = 0 |
|
|
|
await nextTick(() => { |
|
|
|
buttonCloseRef.value?.setLoading(true) |
|
|
|
}) |
|
|
|
// await nextTick(() => { |
|
|
|
// buttonCloseRef.value?.setLoading(true) |
|
|
|
// }) |
|
|
|
status.value = await getDeviceSelfTest() |
|
|
|
|
|
|
|
const interval = async () => { |
|
|
@ -41,51 +41,62 @@ const change = async () => { |
|
|
|
} |
|
|
|
} |
|
|
|
await interval() |
|
|
|
buttonCloseRef.value?.setLoading(false) |
|
|
|
closeVisible.value = false |
|
|
|
// buttonCloseRef.value?.setLoading(false) |
|
|
|
} |
|
|
|
|
|
|
|
const receiveMessage = (data: any) => { |
|
|
|
if (data.cmdId === cmdId) { |
|
|
|
if (data.status === 'success') { |
|
|
|
for (let i = 0; i < checkList.value.length; i++) { |
|
|
|
checkList.value[i].result = 'padding' |
|
|
|
setTimeout(() => { |
|
|
|
checkList.value[i].result = 'success' |
|
|
|
}, 500) |
|
|
|
if (data.status === 'success') { |
|
|
|
for (const cmdIdsKey in cmdIds) { |
|
|
|
if (data.cmdId === cmdIds[cmdIdsKey]) { |
|
|
|
checkList.value[cmdIdsKey].result = 'success' |
|
|
|
} |
|
|
|
buttonRef.value.setLoading(false) |
|
|
|
closeVisible.value = true |
|
|
|
} |
|
|
|
else if (data.status === 'fail') { |
|
|
|
FtMessage.error('自检失败') |
|
|
|
change() |
|
|
|
buttonRef.value.setLoading(false) |
|
|
|
closeVisible.value = false |
|
|
|
} |
|
|
|
if (data.status === 'finish') { |
|
|
|
for (const cmdIdsKey in cmdIds) { |
|
|
|
if (data.cmdId === cmdIds[cmdIdsKey]) { |
|
|
|
toHomeButtonRefs.value[cmdIdsKey].setLoading(false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const cancel = () => { |
|
|
|
const cancel = async () => { |
|
|
|
await deviceSelfTestFinish() |
|
|
|
emits('cancel') |
|
|
|
} |
|
|
|
|
|
|
|
let cmdId = '' |
|
|
|
const motorXYZOrigin = async () => { |
|
|
|
buttonRef.value.setLoading(true) |
|
|
|
// const motorXYZOrigin = async () => { |
|
|
|
// buttonRef.value.setLoading(true) |
|
|
|
// cmdId = Date.now().toString() |
|
|
|
// const params = { |
|
|
|
// cmdCode: 'device_self_test', |
|
|
|
// cmdId, |
|
|
|
// params: {}, |
|
|
|
// } |
|
|
|
// |
|
|
|
// await sendControl(params) |
|
|
|
// } |
|
|
|
|
|
|
|
const cmdIds: any = {} |
|
|
|
|
|
|
|
const toHomeButtonRefs = ref() |
|
|
|
|
|
|
|
const toHome = async (index: number) => { |
|
|
|
cmdId = Date.now().toString() |
|
|
|
cmdIds[index] = cmdId |
|
|
|
const params = { |
|
|
|
cmdCode: 'device_self_test', |
|
|
|
cmdCode: ['motor_x_to_home', 'motor_y_to_home', 'motor_z_to_home'][index], |
|
|
|
cmdId, |
|
|
|
params: {}, |
|
|
|
} |
|
|
|
|
|
|
|
toHomeButtonRefs.value[index].setLoading(true) |
|
|
|
await sendControl(params) |
|
|
|
} |
|
|
|
|
|
|
|
const checkList = ref<any>([]) |
|
|
|
const buttonRef = ref() |
|
|
|
const buttonCloseRef = ref() |
|
|
|
// const buttonRef = ref() |
|
|
|
|
|
|
|
const closeVisible = ref(true) |
|
|
|
|
|
|
@ -119,11 +130,17 @@ const addTextToCheckList = async (text: string, id: number) => { |
|
|
|
}, Math.random() * 100) // 修改为随机数延时 |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
watch(() => checkList.value, () => { |
|
|
|
if (checkList.value.every(item => item.result === 'success')) { |
|
|
|
closeVisible.value = false |
|
|
|
} |
|
|
|
}, { deep: true }) |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<FtDialog visible title="自检" width="40%" @ok="okHandle" @cancel="cancel"> |
|
|
|
<div v-for="item in checkList" :key="item.id" class="mask-box"> |
|
|
|
<div v-for="(item, index) in checkList" :key="item.id" class="mask-box"> |
|
|
|
<el-tag> {{ item.title }}</el-tag> |
|
|
|
<el-icon v-show="item.result === 'success'" color="green"> |
|
|
|
<SuccessFilled /> |
|
|
@ -134,14 +151,17 @@ const addTextToCheckList = async (text: string, id: number) => { |
|
|
|
<el-icon v-show="item.result === 'padding'" color="gray" class="el-icon--loading"> |
|
|
|
<Loading /> |
|
|
|
</el-icon> |
|
|
|
<ft-button ref="toHomeButtonRefs" class="check-button" type="primary" :disabled="item.result === 'success'" @click="() => toHome(index)"> |
|
|
|
回原点 |
|
|
|
</ft-button> |
|
|
|
</div> |
|
|
|
<template #footer> |
|
|
|
<ft-button v-if="closeVisible" ref="buttonCloseRef" @click="cancel"> |
|
|
|
<ft-button :disabled="closeVisible" @click="cancel"> |
|
|
|
关闭 |
|
|
|
</ft-button> |
|
|
|
<ft-button v-else ref="buttonRef" type="primary" @click="motorXYZOrigin"> |
|
|
|
回原点 |
|
|
|
</ft-button> |
|
|
|
<!-- <ft-button v-else ref="buttonRef" type="primary" @click="motorXYZOrigin"> --> |
|
|
|
<!-- 回原点 --> |
|
|
|
<!-- </ft-button> --> |
|
|
|
</template> |
|
|
|
</FtDialog> |
|
|
|
</template> |
|
|
@ -153,7 +173,7 @@ const addTextToCheckList = async (text: string, id: number) => { |
|
|
|
align-items: center; |
|
|
|
margin-bottom: 40px; |
|
|
|
.el-tag { |
|
|
|
margin-right: 20px; |
|
|
|
margin-right: 20px; |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
} |
|
|
@ -174,4 +194,11 @@ const addTextToCheckList = async (text: string, id: number) => { |
|
|
|
:deep(.el-tag) { |
|
|
|
padding: 30px 0; |
|
|
|
} |
|
|
|
:deep(.check-button) { |
|
|
|
margin-left: 10px; |
|
|
|
.my-button { |
|
|
|
width: 230px; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
</style> |