Browse Source

fix:状态字段变更

master
guoapeng 3 months ago
parent
commit
1f382d5173
  1. 127
      src/components/check/index.vue
  2. 4
      src/components/home/Tube/index.vue
  3. 2
      src/layouts/default.vue
  4. 1
      src/libs/utils.ts
  5. 10
      src/stores/systemStore.ts
  6. 3
      src/types/system.d.ts

127
src/components/check/index.vue

@ -1,9 +1,8 @@
<script lang="ts" setup>
import { getContainerList } from '@/apis/container'
import { getSelfFinish, getSelfStatus } from '@/apis/self'
import { ElMessage } from 'element-plus'
import { useHomeStore } from 'stores/homeStore'
import { onMounted, onUnmounted, ref, watch } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'
interface SelfStatus {
name: string
@ -11,21 +10,11 @@ interface SelfStatus {
value: string
type: string
}
const props = defineProps({
checking: Boolean,
type: String,
})
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(() => {
onStartSelfTest()
})
@ -34,12 +23,14 @@ onUnmounted(() => {
})
const onStartSelfTest = () => {
if (props.checking) {
patrolSelfStatus()
queryContainerList()
}
patrolSelfStatus()
}
const statusMap: Record<string, Record<string, string>> = {
doorOrigin: {
name: '门',
value: '',
type: 'door',
},
gantryXOrigin: {
name: '机械臂x轴',
value: 'x',
@ -107,7 +98,7 @@ const patrolSelfStatus = () => {
loading.value = true
patrolTimes.value = setInterval(() => {
querySelfStatus()
}, 2000)
}, 1000)
}
const deviceStatusList = ref<SelfStatus[]>([])
@ -115,53 +106,44 @@ const selfStateComplete = ref(false)
const querySelfStatus = () => {
const orignStatusList = []
getSelfStatus().then((res) => {
console.log('res', res)
loading.value = false
if (res) {
const list: SelfStatus[] = []
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,
try {
const list: SelfStatus[] = []
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
}
})
if (res[item]) {
orignStatusList.push(item)
}
if (orignStatusList.length === keys.length) {
clearInterval(patrolTimes.value)
selfStateComplete.value = true
}
})
deviceStatusList.value = list
deviceStatusList.value = list
console.log('deviceStatusList', list)
}
catch (e) {
console.log('error', e)
}
}
}).catch(() => {
loading.value = false
})
}
// const pumpId = ref()
const queryContainerList = () => {
getContainerList().then((res) => {
if (res) {
const list: Container.ContainerItem[] = res
const solutionList: Container.ContainerItem[] = []
list.forEach((item, index) => {
// 8,
if (index < 8) {
solutionList.push({
...item,
solutionName: `加液泵_0${index + 1}`,
})
}
})
chemicalList.value = solutionList
}
})
}
const resetOrign = (item: SelfStatus) => {
if (item.value === 'x' || item.value === 'y' || item.value === 'z') {
if (item.type === 'door') {
door_origin()
}
else if (item.value === 'x' || item.value === 'y' || item.value === 'z') {
gantry_origin(item.value)
}
else if (item.type === 'liquid') {
@ -175,6 +157,17 @@ const resetOrign = (item: SelfStatus) => {
}
}
const door_origin = async () => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: `door_origin`,
params: {},
}
await homeStore.sendControl(params)
}
// TODO
// const currentPumpId = ref()
// const onPumpChange = (value: string) => {
@ -242,7 +235,7 @@ const onComplete = () => {
</script>
<template>
<FtDialog v-model="visible" title="设备初始化" width="50%">
<FtDialog visible title="自检" width="50%">
<div v-loading="loading" class="check-main">
<!-- <div v-if="type !== 'cancel'"> -->
<!-- <span style="color: red">所有电机回原点后才可操作</span> -->
@ -267,33 +260,13 @@ const onComplete = () => {
</el-icon>
</div>
<div v-if="!item.isOrign" style="text-align: center;">
<!-- <el-link type="primary" @click="resetOrign(item)"> -->
<!-- 回原点 -->
<!-- </el-link> -->
<ft-button type="primary" :click-handle="() => resetOrign(item)">
回原点
</ft-button>
</div>
</div>
<!-- <div class="check-status">
<div>
加液泵
<el-select v-model="pumpId" size="small" style="width:10rem" @change="onPumpChange">
<el-option v-for="item in chemicalList" :key="item.solutionId" :label="item.solutionName" :value="item.pumpId" />
</el-select>
</div>
<div></div>
<div style="text-align: center;">
<el-link type="primary" @click="onPumpEmpty()">
排空
</el-link>
</div>
</div> -->
</div>
<template #footer>
<!-- <FtButton v-if="type === 'cancel'" @click="cancel"> -->
<!-- 取消 -->
<!-- </FtButton> -->
<FtButton :disabled="!selfStateComplete" :click-handle="onComplete">
关闭
</FtButton>

4
src/components/home/Tube/index.vue

@ -12,6 +12,7 @@ import { computed, ref } from 'vue'
const props = withDefaults(defineProps<{ data: System.HeatArea }>(), {
data: () => ({
moduleCode: 'heat_module_01',
trayUp: 1,
trayStatus: 0,
heating: false,
capExist: false,
@ -92,7 +93,7 @@ defineExpose({
</script>
<template>
<div class="tube" :class="{ 'tube-active': hearInfo?.selected, 'tube-shadow': data.trayStatus === 2 }">
<div class="tube" :class="{ 'tube-active': hearInfo?.selected, 'tube-shadow': data.trayUp === 1 }">
<div
v-if="data.trayStatus !== 0 && craft?.state"
class="status" :class="{
@ -128,7 +129,6 @@ defineExpose({
<span>{{ hearInfo?.label }}</span>
<span v-show="data.trayStatus === 0">空置</span>
<span v-show="data.trayStatus === 1">已放置</span>
<span v-show="data.trayStatus === 2">已抬起</span>
</div>
<div class="tube-item" @click.prevent="mousedownHandle" @touch.prevent="mousedownHandle">
<div v-if="data.trayStatus === 0" class="tube-disable" />

2
src/layouts/default.vue

@ -106,7 +106,7 @@ const isCheck = ref(false)
</el-footer>
<FtStream :visible="systemStore.streamVisible" />
<Exit ref="exitModalRef" />
<Check :checking="isCheck" />
<Check v-if="isCheck" />
<Stop v-if="systemStore.systemStatus.emergencyStop" />
</el-container>
</template>

1
src/libs/utils.ts

@ -50,6 +50,7 @@ export const cmdNameMap = {
gantry_z_origin: '机械臂z轴回原点',
cap_lifting_origin: '拍子电机回原点',
tray_lifting_origin: '加热区托盘电机回原点',
door_origin: '门电机回原点',
}
export const generateColors = (count: number): string[] => {

10
src/stores/systemStore.ts

@ -78,6 +78,7 @@ export const useSystemStore = defineStore('system', {
heatModule: [
{
moduleCode: 'heat_module_01',
trayUp: 1,
trayStatus: 1,
heating: false,
capExist: false,
@ -86,6 +87,7 @@ export const useSystemStore = defineStore('system', {
},
{
moduleCode: 'heat_module_02',
trayUp: 1,
trayStatus: 1,
heating: false,
capExist: false,
@ -94,7 +96,8 @@ export const useSystemStore = defineStore('system', {
},
{
moduleCode: 'heat_module_03',
trayStatus: 2,
trayUp: 0,
trayStatus: 0,
heating: true,
capExist: false,
temperature: 130,
@ -102,7 +105,8 @@ export const useSystemStore = defineStore('system', {
},
{
moduleCode: 'heat_module_04',
trayStatus: 2,
trayUp: 1,
trayStatus: 1,
heating: false,
capExist: false,
temperature: 0,
@ -110,6 +114,7 @@ export const useSystemStore = defineStore('system', {
},
{
moduleCode: 'heat_module_05',
trayUp: 1,
trayStatus: 1,
heating: false,
capExist: false,
@ -118,6 +123,7 @@ export const useSystemStore = defineStore('system', {
},
{
moduleCode: 'heat_module_06',
trayUp: 1,
trayStatus: 0,
heating: false,
capExist: false,

3
src/types/system.d.ts

@ -50,7 +50,8 @@ declare namespace System {
}
interface HeatArea {
moduleCode: 'heat_module_01' | 'heat_module_02' | 'heat_module_03' | 'heat_module_04' | 'heat_module_05' | 'heat_module_06'
trayStatus: 0 | 1 | 2
trayUp: 0 | 1
trayStatus: 0 | 1
heating: boolean
capExist: boolean
temperature: number

Loading…
Cancel
Save