Browse Source

修复错误+格式化+通知初始化

feature/history-20250108
zhangjiming 7 months ago
parent
commit
47236c4ed1
  1. 1
      src/eventBus.ts
  2. 33
      src/pages/Index/Index.vue
  3. 127
      src/pages/Index/Regular/Consumables.vue
  4. 8
      src/utils/errorHandler.ts

1
src/eventBus.ts

@ -15,6 +15,7 @@ export type ErrorModalData = {
}
type Events = {
initDevice: void
confirm: { value: number; index: number }
'show-error-modal': ErrorModalData
'show-stack-modal': ErrorModalData['stackInfo'] | null | undefined

33
src/pages/Index/Index.vue

@ -83,12 +83,13 @@
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { Time, InitWarn, LoadingModal } from './components/Consumables';
import { getCheckList, startWork, pauseWork, continueWork, stopWork, getInitState, initDevice, saveMountedCardInfo, openBuzzer, closeBuzzer } from '../../services/index';
import { startWork, pauseWork, continueWork, stopWork, getInitState, initDevice, saveMountedCardInfo, openBuzzer, closeBuzzer } from '../../services/index';
import { CheckItem, User } from '../../types/Index';
import { useConsumablesStore } from '../../store';
import { createWebSocket } from '../../websocket/socket';
import type { AppEventMessage } from '../../websocket/socket';
import { getServerInfo } from '../../utils/getServerInfo';
import { eventBus } from '../../eventBus';
const selectedTab = ref(sessionStorage.getItem('selectedTab') || '常规');
const lineWidth = ref(0);
const lineLeft = ref(0);
@ -160,9 +161,7 @@ const confirmError = async () => {
}
//
const confirmWarn = async () => {
showWarnModal.value = false
return
}
//id
const saveIdInfo = async () => {
@ -172,14 +171,17 @@ const saveIdInfo = async () => {
idCardInserted.value = false;
}
}
const showInitDeviceAlert = () => {
showModal.value = true
}
onMounted(() => {
eventBus.on('initDevice', showInitDeviceAlert)
ws.connect();
ws.subscribe<AppEventMessage>('AppEvent', handleAppEvent);
});
onBeforeUnmount(() => {
eventBus.off('initDevice', showInitDeviceAlert)
ws.unsubscribe<AppEventMessage>('AppEvent', handleAppEvent);
ws.disconnect();
});
@ -332,27 +334,6 @@ const openTest = () => {
showModal.value = true;
}
};
//
const getCheckData = async () => {
try {
const res = await getCheckList();
if (res.data && res.data.ecode == "SUC") {
checkData.value = res.data;
console.log('设备检查的结果:', checkData.value);
//
checkTestTubeSlotStatus(checkData.value);
} else {
console.log("获取检测数据失败")
showFailModal.value = true;
failMessage.value = "获取检测数据失败,请检查设备状态。"
}
} catch (error) {
console.error('获取检测数据失败:', error);
showFailModal.value = true;
failMessage.value = "获取检测数据失败,请检查设备状态。"
}
};
// 线
const updateLinePosition = (element: any) => {

127
src/pages/Index/Regular/Consumables.vue

@ -24,7 +24,11 @@
</tr>
</thead>
<tbody>
<tr v-for="report in formattedReports" :key="report.channel" :class="{ 'error-row': report.isError }">
<tr
v-for="report in formattedReports"
:key="report.channel"
:class="{ 'error-row': report.isError }"
>
<td>通道{{ report.channel + 1 }}</td>
<td>{{ report.projName || '--' }}</td>
<td>{{ report.lotId || '--' }}</td>
@ -47,9 +51,18 @@
<SpttingPlates :plates="plates" :temperature="currentTemperature" />
</div>
<div class="move-liquid-area">
<MoveLiquidArea :isLoad="isLoad" :isLoading="isLoading" :moveLiquids="moveLiquids" :tempTipNum="tempTipNum"
:bufferBig="bufferBig" :emergencyInfo="emergencyInfo" :wasteStatus="wasteStatus"
@loadConsumables="handleIsLoad" @unloadConsumables="handleIsUnload" @updateTipNum="updateTipNum" />
<MoveLiquidArea
:isLoad="isLoad"
:isLoading="isLoading"
:moveLiquids="moveLiquids"
:tempTipNum="tempTipNum"
:bufferBig="bufferBig"
:emergencyInfo="emergencyInfo"
:wasteStatus="wasteStatus"
@loadConsumables="handleIsLoad"
@unloadConsumables="handleIsUnload"
@updateTipNum="updateTipNum"
/>
</div>
</div>
<div class="main-bottom">
@ -59,9 +72,19 @@
<div class="content">缓冲液()</div>
</div>
<div class="ball-area">
<MainComponent v-for="item in bufferLittles" :key="item" class="ball-grid" :projectName="item.projShortName"
:currentCount="item.num" :totalBalls="25" :activatedBalls="item.num" :columns="5" gridWidth="240px"
gridHeight="235px" :activeColor="item.color" />
<MainComponent
v-for="item in bufferLittles"
:key="item"
class="ball-grid"
:projectName="item.projShortName"
:currentCount="item.num"
:totalBalls="25"
:activatedBalls="item.num"
:columns="5"
gridWidth="240px"
gridHeight="235px"
:activeColor="item.color"
/>
</div>
</div>
</div>
@ -70,17 +93,21 @@
<script setup lang="ts">
import { MoveLiquidArea, SpttingPlates, MainComponent } from '../components'
import { ref, onMounted, onActivated, onBeforeUnmount, watch } from 'vue'
import { scanConsumables, updateTipsNum } from '../../../services/Index/index'
import {
getInitState,
scanConsumables,
updateTipsNum,
} from '../../../services/Index/index'
import { useConsumablesStore, useEmergencyStore } from '../../../store'
import { useDeviceStore } from '../../../store/index'
import { eventBus } from '../../../eventBus'
import {
ReactionPlate,
BottleGroup,
LiquidState,
} from '../../../types/Index'
import { ReactionPlate, BottleGroup, LiquidState } from '../../../types/Index'
import { createWebSocket } from '../../../websocket/socket'
import type { ConsumablesStateMessage, SensorStateMessage, EmergencyPosStateMessage } from '../../../websocket/socket';
import type {
ConsumablesStateMessage,
SensorStateMessage,
EmergencyPosStateMessage,
} from '../../../websocket/socket'
import { getServerInfo } from '../../../utils/getServerInfo'
import { formatScanReports } from '../../../utils/errorHandler'
import { ElMessage } from 'element-plus'
@ -91,15 +118,15 @@ const consumableStore = useConsumablesStore()
const emergencyStore = useEmergencyStore()
const deviceStore = useDeviceStore()
//
const currentTemperature = ref(40);
const currentTemperature = ref(40)
//
const wasteStatus = ref(false)
//
const isLoad = ref(false)
const isLoading = ref(false)
//
//
const plates = ref<ReactionPlate[]>([])
//
//
const moveLiquids = ref<LiquidState[]>([
{
id: 1,
@ -190,7 +217,7 @@ const isHandleScan = ref(false)
const handleConfirmScan = () => {
showScanResults.value = false
isHandleScan.value = true
if (formattedReports.value.some(report => report.isError)) {
if (formattedReports.value.some((report) => report.isError)) {
isLoad.value = false
isAlreadyLoad.value = false
ElMessage.warning('存在错误,请检查耗材')
@ -203,15 +230,15 @@ const startWebSocket = () => {
//
const handleSensorState = (data: SensorStateMessage['data']) => {
// 使
currentTemperature.value = data.incubateBoxTemperature;
currentTemperature.value = data.incubateBoxTemperature
wasteStatus.value = data.wasteBinFullFlag
consumableStore.updateWasteStatus(wasteStatus.value)
//
if (currentTemperature.value > 40) {
console.warn('温度过高警告');
console.warn('温度过高警告')
//
}
};
}
//
const handleConsumablesState = (data: ConsumablesStateMessage['data']) => {
@ -233,17 +260,24 @@ const updatePlatesAndBuffers = ({
value: number
index: number
}) => {
if (plates.value && plates.value[index]) plates.value[index].num = value
if (bufferLittles.value && bufferLittles.value[index])
if (plates.value && plates.value[index]) {
plates.value[index].num = value
}
if (bufferLittles.value && bufferLittles.value[index]) {
bufferLittles.value[index].num = value
if (bufferBig.value && bufferBig.value[index])
}
if (bufferBig.value && bufferBig.value[index]) {
bufferBig.value[index].isUse = value > 0
}
}
onMounted(() => {
eventBus.on('confirm', updatePlatesAndBuffers)
startWebSocket()
socket.subscribe<SensorStateMessage>('SensorState', handleSensorState);
socket.subscribe<ConsumablesStateMessage>('ConsumablesStateService', handleConsumablesState);
socket.subscribe<SensorStateMessage>('SensorState', handleSensorState)
socket.subscribe<ConsumablesStateMessage>(
'ConsumablesStateService',
handleConsumablesState,
)
// getEmergencyInfo()
})
onBeforeUnmount(() => {
@ -252,8 +286,11 @@ onBeforeUnmount(() => {
if (socket !== null) {
socket.disconnect() //
}
socket.unsubscribe<SensorStateMessage>('SensorState', handleSensorState);
socket.unsubscribe<ConsumablesStateMessage>('ConsumablesStateService', handleConsumablesState);
socket.unsubscribe<SensorStateMessage>('SensorState', handleSensorState)
socket.unsubscribe<ConsumablesStateMessage>(
'ConsumablesStateService',
handleConsumablesState,
)
})
//
onActivated(() => {
@ -267,9 +304,13 @@ onActivated(() => {
const consumablesData = ref<ConsumablesStateMessage['data'] | null>(null)
//
const handleIsLoad = async () => {
isLoading.value = true
const res = await getInitState()
if (res.ecode === 'SUC' && !res.data.deviceInited) {
eventBus.emit('initDevice')
return
}
try {
isLoading.value = true
const res = await scanConsumables()
isLoading.value = false
@ -279,10 +320,6 @@ const handleIsLoad = async () => {
//
showScanResults.value = true
consumablesData.value = res.data.consumableState
//
if (res.data.consumableState) {
}
} catch (error) {
console.error('加载耗材失败:', error)
isLoading.value = false
@ -296,14 +333,13 @@ watch(isHandleScan, (newVal) => {
if (consumablesData.value) {
moveLiquids.value = consumablesData.value.tips
plates.value = consumablesData.value.reactionPlateGroup as ReactionPlate[]
bufferLittles.value = consumablesData.value.littBottleGroup as BufferLittle[]
bufferLittles.value = consumablesData.value
.littBottleGroup as BufferLittle[]
bufferBig.value = consumablesData.value.larBottleGroup as BottleGroup[]
tempTipNum.value = [...moveLiquids.value.map((liquid) => liquid.tipNum)]
isLoad.value = true
isAlreadyLoad.value = true
consumableStore.setConsumablesData(consumablesData.value)
//
consumablesData.value = null
}
} else {
//
@ -314,7 +350,10 @@ const handleIsUnload = () => {
isLoad.value = !isLoad.value
isLoading.value = false
isAlreadyLoad.value = false
socket.unsubscribe<ConsumablesStateMessage>('ConsumablesStateService', handleConsumablesState);
socket.unsubscribe<ConsumablesStateMessage>(
'ConsumablesStateService',
handleConsumablesState,
)
// moveLiquids tempTipNum
moveLiquids.value = [
{ id: 1, tipNum: 0 },
@ -365,14 +404,20 @@ const handleIsUnload = () => {
]
bufferBig.value = []
}
const updateTipNum = async ({ index, tipNum }: { index: number; tipNum: number }) => {
const updateTipNum = async ({
index,
tipNum,
}: {
index: number
tipNum: number
}) => {
//
tempTipNum.value[index] = tipNum
console.log('🚀 ~ updateTipNum ~ tempTipNum:', tempTipNum.value)
//
try {
if (deviceStore.status === 'IDLE') {
await updateTipsNum({ group: `CG${index}`, num: tipNum })
await updateTipsNum({ group: `TipG${index+1}`, num: tipNum })
} else {
ElMessage.error('设备正在工作,无法修改数值')
}
@ -492,7 +537,7 @@ const updateTipNum = async ({ index, tipNum }: { index: number; tipNum: number }
flex-wrap: wrap;
.ball-grid {
margin: 0 15px 5px 15px
margin: 0 15px 5px 15px;
}
}
}

8
src/utils/errorHandler.ts

@ -2,16 +2,16 @@
const ERROR_MAP = {
PASS: '通过',
EMPTY: '空',
EXPIRED: '材过期',
MISS_REACTION_PLATE: '没有反应板',
EXPIRED: '材过期',
MISS_REACTION_PLATE: '没有反应板',
MISS_LITTSB: '缺少小缓冲液',
MISS_LARBS: '缺少大缓冲液',
MISS_IDCARD: '未找到匹配的项目ID卡',
LITTSB_LOTID_MISMATCH: '小缓冲液批号不匹配',
LARBS_LOTID_MISMATCH: '大缓冲液批号不匹配',
REACTION_PLATE_2D_CODE_FORMATE_ERROR: '反应板二维码格式错误',
CODE_ERROR_PROJINFO_IS_ERROR: '代码错误,项目信息异常',
UN_SUPPORT_PROJ: '不支持的项目',
REACTION_PLATE_2D_CODE_FORMATE_ERROR: '反应板二维码格式错误',
} as const
type ErrorCode = keyof typeof ERROR_MAP
@ -31,7 +31,7 @@ export const getErrorMessage = (code: ErrorCode): string => {
* @returns
*/
export const isError = (code: ErrorCode): boolean => {
return code !== 'PASS'
return code !== 'PASS' && code !== 'EMPTY'
}
/**

Loading…
Cancel
Save