Browse Source

添加自检功能

feature/three
LiLongLong 3 months ago
parent
commit
933a78fff8
  1. 1
      src/apis/self.ts
  2. 2
      src/app.vue
  3. 63
      src/components/check/index.vue
  4. 2
      src/components/exit/index.vue
  5. 25
      src/layouts/default.vue

1
src/apis/self.ts

@ -1,3 +1,4 @@
import http from 'libs/http'
export const getSelfStatus = (): Promise<Record<string, boolean>> => http.get('/self-test/status')
export const getSelfFinish = (): Promise<Record<string, boolean>> => http.post('/self-test/finish')

2
src/app.vue

@ -8,7 +8,7 @@ const systemStore = useSystemStore()
onMounted(async () => {
const res = await getStatus()
console.log(res)
systemStore.updateSystemStatus(res)
// systemStore.updateSystemStatus(res)
startProgress()
})

63
src/components/check/index.vue

@ -1,6 +1,7 @@
<script lang="ts" setup>
import { getContainerList } from '@/apis/container'
import { getSelfStatus } from '@/apis/self'
import { getSelfFinish, getSelfStatus } from '@/apis/self'
import { ElMessage } from 'element-plus'
import { useHomeStore } from 'stores/homeStore'
import { onMounted, ref, watch } from 'vue'
@ -12,18 +13,29 @@ interface SelfStatus {
}
const props = defineProps({
checking: Boolean,
type: String,
})
const emits = defineEmits(['update:checking'])
const homeStore = useHomeStore()
const visible = ref(props.checking)
const chemicalList = ref<Container.ContainerItem[]>([])
const loading = ref(false)
watch(() => props.checking, (newVal) => {
visible.value = newVal
if (newVal) {
onStartSelfTest()
}
})
onMounted(() => {
querySelfStatus()
queryContainerList()
onStartSelfTest()
})
const onStartSelfTest = () => {
if (props.checking) {
patrolSelfStatus()
queryContainerList()
}
}
const statusMap: Record<string, Record<string, string>> = {
gantryXOrigin: {
name: '机械臂x轴',
@ -86,21 +98,43 @@ const statusMap: Record<string, Record<string, string>> = {
type: 'heat',
},
}
const patrolTimes = ref()
const patrolSelfStatus = () => {
loading.value = true
patrolTimes.value = setInterval(() => {
querySelfStatus()
}, 2000)
}
const deviceStatusList = ref<SelfStatus[]>([])
const selfStateComplete = ref(false)
const querySelfStatus = () => {
const orignStatusList = []
getSelfStatus().then((res) => {
loading.value = false
if (res) {
const list: SelfStatus[] = []
Object.keys(res).forEach((item) => {
const keys = Object.keys(res)
keys.forEach((item) => {
list.push({
name: statusMap[item].name,
isOrign: res[item],
value: statusMap[item].value,
type: statusMap[item].type,
})
if (res[item]) {
orignStatusList.push(item)
}
if (orignStatusList.length === keys.length) {
clearInterval(patrolTimes.value)
selfStateComplete.value = true
}
})
deviceStatusList.value = list
}
}).catch(() => {
loading.value = false
})
}
// const pumpId = ref()
@ -127,7 +161,7 @@ const resetOrign = (item: SelfStatus) => {
if (item.value === 'x' || item.value === 'y' || item.value === 'z') {
gantry_origin(item.value)
}
else if (item.type === 'liquied') {
else if (item.type === 'liquid') {
dual_robot_joint_origin(item.value)
}
else if (item.type === 'heat') {
@ -195,6 +229,13 @@ const tray_lifting_origin = async (heatId: string) => {
await homeStore.sendControl(params)
}
const onComplete = () => {
getSelfFinish().then(() => {
ElMessage.success('自检完成')
visible.value = false
})
}
const cancel = () => {
emits('update:checking', false)
visible.value = false
@ -203,7 +244,10 @@ const cancel = () => {
<template>
<FtDialog v-model="visible" title="设备初始化" width="50%">
<div class="check-main">
<div v-loading="loading" class="check-main">
<div v-if="type !== 'cancel'">
<span style="color: red">所有电机回原点后才可操作</span>
</div>
<div class="check-status">
<h3>名称</h3>
<h3>是否在原点</h3>
@ -223,7 +267,7 @@ const cancel = () => {
<Select />
</el-icon>
</div>
<div style="text-align: center;">
<div v-if="!item.isOrign" style="text-align: center;">
<el-link type="primary" @click="resetOrign(item)">
回原点
</el-link>
@ -245,9 +289,12 @@ const cancel = () => {
</div> -->
</div>
<template #footer>
<FtButton @click="cancel">
<FtButton v-if="type === 'cancel'" @click="cancel">
取消
</FtButton>
<FtButton v-if="selfStateComplete" @click="onComplete">
自检完成
</FtButton>
</template>
</FtDialog>
</template>

2
src/components/exit/index.vue

@ -57,7 +57,7 @@ defineExpose({
</div>
</div>
<div v-if="checking">
<Check v-model:checking="checking" />
<Check v-model:checking="checking" type="cancel" />
</div>
</template>

25
src/layouts/default.vue

@ -1,12 +1,14 @@
<script setup lang="ts">
import Check from 'components/check/index.vue'
import Exit from 'components/exit/index.vue'
import Stop from 'components/home/Stop/index.vue'
import { ElMessageBox } from 'element-plus'
import { useActivateDebug } from 'hooks/useActivateDebug'
import { isClose } from 'libs/socket'
import { formatDateTime } from 'libs/utils'
import { authRoutes } from 'router/routes'
import { useSystemStore } from 'stores/systemStore'
import { onUnmounted, ref } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'
import { useRouter } from 'vue-router'
const { handleLogoClick } = useActivateDebug()
@ -20,6 +22,11 @@ const timeInterval = setInterval(() => {
currentTime.value = formatDateTime()
}, 1000)
onMounted(() => {
//
onSelfTest()
})
onUnmounted(() => {
clearInterval(timeInterval)
})
@ -29,6 +36,21 @@ const onExitHandle = () => {
exitModalRef.value.openModal()
}
}
const isCheck = ref(false)
const onSelfTest = () => {
ElMessageBox.confirm(
'请确认是否进行设备自检?',
'设备自检',
{
confirmButtonText: '自检',
cancelButtonText: '取消',
type: 'warning',
},
).then(() => {
isCheck.value = true
})
}
</script>
<template>
@ -97,6 +119,7 @@ const onExitHandle = () => {
</el-footer>
<FtStream :visible="systemStore.streamVisible" />
<Exit ref="exitModalRef" />
<Check :checking="isCheck" />
<Stop v-if="systemStore.systemStatus.emergencyStop" />
</el-container>
</template>

Loading…
Cancel
Save