|
|
@ -113,9 +113,7 @@ |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { MoveLiquidArea, SpttingPlates, MainComponent } from '../components' |
|
|
|
// import SliderAreaEx from '../components/Consumables/SliderAreaEx.vue'; |
|
|
|
// import DragAreaEx from '../components/Consumables/DragAreaEx.vue'; |
|
|
|
import { ref, onMounted, onActivated } from 'vue' |
|
|
|
import { ref, onActivated } from 'vue' |
|
|
|
import { |
|
|
|
getInitState, |
|
|
|
scanConsumables, |
|
|
@ -128,17 +126,11 @@ import { |
|
|
|
import { useConsumablesStore, useEmergencyStore } from '@/store' |
|
|
|
import { useDeviceStore } from '@/store/index' |
|
|
|
import { eventBus } from '@/eventBus' |
|
|
|
import { createWebSocket } from '@/websocket/socket' |
|
|
|
import type { ConsumablesStateMessage } from '@/websocket/socket' |
|
|
|
import InitWarn from '../components/Consumables/Warn/InitWarn.vue' |
|
|
|
import { getServerInfo } from '@/utils/getServerInfo' |
|
|
|
import { formatScanReports } from '@/utils/errorHandler' |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
import { Subject, throttleTime } from 'rxjs' |
|
|
|
|
|
|
|
const { wsUrl } = getServerInfo('/api/v1/app/ws/state') |
|
|
|
const socket = createWebSocket(wsUrl) |
|
|
|
|
|
|
|
const consumableStore = useConsumablesStore() |
|
|
|
const emergencyStore = useEmergencyStore() |
|
|
|
const deviceStore = useDeviceStore() |
|
|
@ -179,48 +171,6 @@ const confirmWarn = () => { |
|
|
|
showUnloadConsumableWarnModal.value = false |
|
|
|
} |
|
|
|
|
|
|
|
//使用websocket保证数据的实时性 |
|
|
|
const startWebSocket = () => { |
|
|
|
socket.connect() |
|
|
|
} |
|
|
|
|
|
|
|
//所有的耗材是否都有,如果有一项没有则为false |
|
|
|
//@ts-ignore |
|
|
|
let hasAllConsumables = ref(false) |
|
|
|
//处理耗材状态 |
|
|
|
let allowDel = 0 |
|
|
|
const handleConsumablesState = (data: ConsumablesStateMessage['data']) => { |
|
|
|
if (!allowDel) { |
|
|
|
console.log('耗材日志------', data) |
|
|
|
} |
|
|
|
allowDel = 1 |
|
|
|
if (!isDragging.value) { |
|
|
|
consumableStore.setConsumablesData(data) |
|
|
|
// if( |
|
|
|
// (data.tips && data.tips.length ) && |
|
|
|
// (data.reactionPlateGroup && data.reactionPlateGroup.length) && |
|
|
|
// (data.littBottleGroup && data.littBottleGroup.length) && |
|
|
|
// (data.larBottleGroup && data.larBottleGroup.length) |
|
|
|
// ){ |
|
|
|
// hasAllConsumables.value = true; |
|
|
|
// }else{ |
|
|
|
// hasAllConsumables.value = false; |
|
|
|
// } |
|
|
|
// //放入全局story 中 |
|
|
|
// consumableStore.hasAllConsumables = hasAllConsumables.value |
|
|
|
} else { |
|
|
|
console.log('正在拖动,不更新耗材') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
startWebSocket() |
|
|
|
socket.subscribe<ConsumablesStateMessage>( |
|
|
|
'ConsumablesState', |
|
|
|
handleConsumablesState, |
|
|
|
) |
|
|
|
}) |
|
|
|
|
|
|
|
// 在组件激活时恢复状态 |
|
|
|
onActivated(() => { |
|
|
|
emergencyInfo.value = emergencyStore.$state.emergencyInfo |
|
|
@ -279,6 +229,7 @@ const handleUnloadAll = async () => { |
|
|
|
// 接口未返回数据 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const handleUnloadConsumable = async (index: number) => { |
|
|
|
if (deviceStore.deviceState.workState === 'WORKING') { |
|
|
|
ElMessage.error('设备正在运行中,不可操作耗材') |
|
|
@ -292,8 +243,6 @@ const handleUnloadConsumable = async (index: number) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const isDragging = ref(false) |
|
|
|
|
|
|
|
const updateReactionPlateNum = async ({ |
|
|
|
index, |
|
|
|
plateNum, |
|
|
@ -307,17 +256,19 @@ const updateReactionPlateNum = async ({ |
|
|
|
return |
|
|
|
} |
|
|
|
if (deviceStore.deviceState.workState !== 'WORKING') { |
|
|
|
consumableStore.setDisableUpdateConsumableData(true) |
|
|
|
consumableStore.updateReactionPlateNum(index, plateNum) |
|
|
|
if (sync) { |
|
|
|
console.log(`🚀 ~ updatePlateNum ~ order ${index + 1}, num ${plateNum}`) |
|
|
|
try { |
|
|
|
await updateConsumables({ group: `CG${index + 1}`, num: plateNum }) |
|
|
|
const res = await updateConsumables({ group: `CG${index + 1}`, num: plateNum }) |
|
|
|
if (!res.success) { |
|
|
|
errMsg$.next(res.data.info || '修改耗材数量失败') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('修改耗材数量失败:', error) |
|
|
|
} |
|
|
|
isDragging.value = false |
|
|
|
} else { |
|
|
|
isDragging.value = true |
|
|
|
consumableStore.setDisableUpdateConsumableData(false) |
|
|
|
} |
|
|
|
} else { |
|
|
|
errMsg$.next('设备正在工作,无法修改数值') |
|
|
@ -337,18 +288,20 @@ const updateTipNum = async ({ |
|
|
|
return |
|
|
|
} |
|
|
|
if (deviceStore.deviceState.workState !== 'WORKING') { |
|
|
|
consumableStore.setDisableUpdateConsumableData(true) |
|
|
|
consumableStore.updateTipNum(index, tipNum) |
|
|
|
if (sync) { |
|
|
|
console.log(`🚀 ~ updateTipNum ~ order ${index + 1}, num ${tipNum}`) |
|
|
|
try { |
|
|
|
await updateTipsNum({ group: `TipG${index + 1}`, num: tipNum }) |
|
|
|
const res = await updateTipsNum({ group: `TipG${index + 1}`, num: tipNum }) |
|
|
|
if (!res.success) { |
|
|
|
errMsg$.next(res.data.info || '修改耗材数量失败') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('修改耗材数量失败:', error) |
|
|
|
} |
|
|
|
isDragging.value = false |
|
|
|
} else { |
|
|
|
isDragging.value = true |
|
|
|
} |
|
|
|
consumableStore.setDisableUpdateConsumableData(false) |
|
|
|
} |
|
|
|
} else { |
|
|
|
errMsg$.next('设备正在工作,无法修改数值') |
|
|
|
} |
|
|
|