Browse Source

fix:添加自检状态

master
guoapeng 5 months ago
parent
commit
5a04b3e16a
  1. 2
      src/components/home/Check/index.vue
  2. 14
      src/libs/utils.ts
  3. 4
      src/views/home/index.vue

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

@ -54,7 +54,7 @@ const motorXYZOrigin = async () => {
buttonRef.value.setLoading(true)
const cmdId = Date.now().toString()
const params = {
cmdCode: 'motor_xyz_origin',
cmdCode: 'device_self_test',
cmdId,
params: {},
}

14
src/libs/utils.ts

@ -1,5 +1,6 @@
import { control, debugControl } from 'apis/system'
import { FtMessage } from 'libs/message'
import { socket } from 'libs/socket'
import { useSystemStore } from 'stores/useSystemStore'
export const sendControl = async (params: any, type?: string) => {
@ -29,9 +30,16 @@ export const sendControl = async (params: any, type?: string) => {
}
systemStore.systemList = []
// const cmdName = cmdNameMap[params.cmdCode as keyof typeof cmdNameMap] || params.cmdCode
const res = await (type ? control(params) : debugControl(params))
console.log(res)
const cmdName = cmdNameMap[params.cmdCode as keyof typeof cmdNameMap] || params.cmdCode
socket.init((data: any) => {
systemStore.pushSystemList(data)
}, 'cmd_debug')
socket.init((data: any) => {
systemStore.pushSystemList(data)
}, 'cmd_response')
await (type ? control(params) : debugControl(params))
FtMessage.success(`[${cmdName}]已发送`)
// if (!res.ok) {
// FtMessage.error(`[${cmdName}]发送失败`)
// return

4
src/views/home/index.vue

@ -1,9 +1,11 @@
<script setup lang="ts">
import Check from 'components/home/Check/index.vue'
import { ElMessageBox } from 'element-plus'
import { useSystemStore } from 'stores/useSystemStore'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const systemStore = useSystemStore()
const router = useRouter()
const checkVisible = ref(false)
@ -11,6 +13,7 @@ const ok = () => {
checkVisible.value = false
}
if (!systemStore.systemStatus.selfTestCompleted) {
ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
type: 'warning',
confirmButtonText: '确定',
@ -22,6 +25,7 @@ ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '
}).then(() => {
checkVisible.value = true
})
}
</script>
<template>

Loading…
Cancel
Save