From ad633b10d9965f70c81df279d6360ef34528e0e2 Mon Sep 17 00:00:00 2001 From: gzt Date: Fri, 20 Dec 2024 22:32:50 +0800 Subject: [PATCH] update --- src/pages/Index/Regular/Consumables.vue | 244 ++++++++++++++++----- src/pages/Index/Regular/Emergency.vue | 155 ++++++++++++- .../Index/components/Consumables/ChangeNum.vue | 14 +- src/services/Index/running/running.ts | 2 +- src/types/Index/Consumables.ts | 4 +- src/utils/errorHandler.ts | 60 +++++ 6 files changed, 405 insertions(+), 74 deletions(-) create mode 100644 src/utils/errorHandler.ts diff --git a/src/pages/Index/Regular/Consumables.vue b/src/pages/Index/Regular/Consumables.vue index 43b37df..64628f8 100644 --- a/src/pages/Index/Regular/Consumables.vue +++ b/src/pages/Index/Regular/Consumables.vue @@ -1,15 +1,46 @@ @@ -813,5 +893,64 @@ onUnmounted(() => { .slide-up-leave-to { transform: translateY(100%); } + + .tube-selector-overlay { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(4px); + display: flex; + justify-content: center; + align-items: center; + z-index: 10000; + } + + .tube-selector-container { + background: white; + border-radius: 8px; + padding: 20px; + width: 600px; + + .tube-selector-header { + text-align: center; + margin-bottom: 20px; + + .title { + font-size: 32px; + font-weight: bold; + } + } + + .tube-grid { + display: grid; + grid-template-columns: repeat(5, 1fr); + gap: 15px; + padding: 20px; + + .tube-button { + padding: 20px; + font-size: 24px; + border: 2px solid #409eff; + border-radius: 8px; + background: white; + cursor: pointer; + transition: all 0.3s; + + &:hover:not(:disabled) { + background: #409eff; + color: white; + } + + &.occupied { + border-color: #909399; + background: #f4f4f5; + cursor: not-allowed; + } + } + } + } } diff --git a/src/pages/Index/components/Consumables/ChangeNum.vue b/src/pages/Index/components/Consumables/ChangeNum.vue index 117a0f8..d2071da 100644 --- a/src/pages/Index/components/Consumables/ChangeNum.vue +++ b/src/pages/Index/components/Consumables/ChangeNum.vue @@ -57,7 +57,7 @@ const query = ref({ // 监听 value 的变化,同步更新 query watch(value, (newVal) => { query.value = { - group: `GROUP${plateIndex.value}`, + group: `CG`${ plateIndex.value } `, num: Number(newVal) } }) @@ -72,18 +72,18 @@ const openDialog = (plate, index) => { value.value = Number(plate.num) plateIndex.value = index title.value = plate.projShortName || '' - dialogTitle.value = `请选择${title.value}数值` + dialogTitle.value = `请选择${ title.value } 数值` // 初始化 query query.value = { - group: `GROUP${index}`, + group: `CG`${index}`, num: Number(plate.num) - } +} } -defineExpose({ - openDialog, -}) + defineExpose({ + openDialog, + }) const handleCancel = () => { isOpen.value = false diff --git a/src/services/Index/running/running.ts b/src/services/Index/running/running.ts index b123d01..1dce8fe 100644 --- a/src/services/Index/running/running.ts +++ b/src/services/Index/running/running.ts @@ -12,7 +12,7 @@ export const getRunningList = async () => { } } -//获取试管架的状态 轮询请求 +//获取试管架的状态 export const getTubeRackState = async () => { try { const res = await apiClient.post( diff --git a/src/types/Index/Consumables.ts b/src/types/Index/Consumables.ts index 145bcc4..768d3e5 100644 --- a/src/types/Index/Consumables.ts +++ b/src/types/Index/Consumables.ts @@ -2,9 +2,11 @@ // scanReports 接口 export interface ScanReport { chNum: number - report: string // 如:PASS 或者其他状态 + state: string // 如:PASS 或者其他状态 projId: number lotId: string + projName: string + projShortName: string } // scanRawResults 接口 diff --git a/src/utils/errorHandler.ts b/src/utils/errorHandler.ts new file mode 100644 index 0000000..0bedebb --- /dev/null +++ b/src/utils/errorHandler.ts @@ -0,0 +1,60 @@ +// 错误码映射表 +const ERROR_MAP = { + PASS: '通过', + EMPTY: '空', + EXPIRED: '转材过期', + MISS_REACTION_PLATE: '没有反应板架', + MISS_LITTSB: '缺少小缓冲液', + MISS_LARBS: '缺少大缓冲液', + MISS_IDCARD: '未找到匹配的项目ID卡', + LITTSB_LOTID_MISMATCH: '小缓冲液批号不匹配', + LARBS_LOTID_MISMATCH: '大缓冲液批号不匹配', + CODE_ERROR_PROJINFO_IS_ERROR: '代码错误,项目信息异常', + UN_SUPPORT_PROJ: '不支持的项目', + REACTION_PLATE_2D_CODE_FORMATE_ERROR: '反应板二维码格式错误', +} as const + +type ErrorCode = keyof typeof ERROR_MAP + +/** + * 获取错误说明 + * @param code 错误码 + * @returns 错误说明 + */ +export const getErrorMessage = (code: ErrorCode): string => { + return ERROR_MAP[code as ErrorCode] || '未知错误' +} + +/** + * 检查是否为错误状态 + * @param code 错误码 + * @returns 是否为错误状态 + */ +export const isError = (code: ErrorCode): boolean => { + return code !== 'PASS' +} + +/** + * 格式化扫描报告 + * @param reports 扫描报告数组 + * @returns 格式化后的错误信息数组 + */ +export const formatScanReports = ( + reports: Array<{ + chNum: number + state: string + projId: number + lotId: string + projName: string + projShortName: string + }>, +) => { + return reports.map((item) => ({ + channel: item.chNum, + code: item.state, + message: getErrorMessage(item.state as ErrorCode), + isError: isError(item.state as ErrorCode), + projName: item.projName, + lotId: item.lotId, + })) +}