| | |
| | | import QueuePanel from "@/views/ecg/doctor/components/QueuePanel.vue"; |
| | | import DoctorPageLayout from "@/components/DoctorPageLayout/src/DoctorPageLayout.vue"; |
| | | import {DoctorApi, PatientStatisticVO, RoomBedVO} from '@/api/ecg/doctor'; |
| | | import { notifySeatInvalidOnce, isSeatInvalidError, resetSeatInvalidNotify } from '@/utils/seatGuard' |
| | | import {QueueVO} from "@/api/ecg/queue"; |
| | | import {ElMessage, ElMessageBox, ElNotification} from "element-plus"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import {useRoomStore} from "@/store/modules/room"; |
| | | |
| | | const roomStore = useRoomStore(); |
| | |
| | | const state = ref<boolean>() |
| | | |
| | | const patientList = ref<QueueVO[]>([]) |
| | | /** 【自助诊断】最近一次取数的说明(空列表时显示) */ |
| | | const fetchInfo = ref('') |
| | | |
| | | let timerRunFlag : boolean = false |
| | | const bedControlFlag = ref<boolean>(true); |
| | |
| | | const finishNextPatient = async () => { |
| | | finishFlag.value = true |
| | | try { |
| | | // 【本需求】叫号前若仍有「安装中(36)」患者且未点「装机完成」,先自动完成他,再叫下一位 |
| | | const installing = patientList.value.find(item => item.status === 36) |
| | | if (installing) { |
| | | const ok = (await devInstallPanelRef.value?.completeCurrent?.()) !== false |
| | | if (!ok) { |
| | | ElMessage.warning('自动「装机完成」未成功,请先手动完成当前患者') |
| | | return |
| | | } |
| | | } |
| | | patientList.value = await DoctorApi.finishInstallNextPatient(roomBedVO.value) |
| | | patientStat.value = await DoctorApi.getDevInstallStatistic(roomBedVO.value) |
| | | getInstallingPatient() |
| | | |
| | | // 用于解决 左侧重置后 获取当前 【安装中】患者 |
| | | setInstallingPatient(installingPatient) |
| | | // 用于解决 左侧重置后 获取当前【安装中】患者; |
| | | // 若已无安装中患者(刚完成且没有下一位),清空左上角,避免把刚完成的人又显示回来 |
| | | if (patientList.value.some(item => item.status === 36)) { |
| | | setInstallingPatient(installingPatient) |
| | | } else { |
| | | devInstallPanelRef.value?.setPatient?.(undefined) |
| | | } |
| | | } finally { |
| | | finishFlag.value = false |
| | | } |
| | |
| | | |
| | | const initLoad = async () => { |
| | | if (roomBedVO.value.roomId == null) { |
| | | ElNotification.error({ |
| | | message: '请重新就座!', |
| | | type: 'info', |
| | | duration: 3000 // 自动关闭时间,默认为3000ms |
| | | }) |
| | | // 【本需求】没有工位:停掉轮询并只提示一次(原来每 5 秒弹一次,现场表现就是一直跳) |
| | | timerRunFlag = false |
| | | notifySeatInvalidOnce() |
| | | return |
| | | } |
| | | |
| | | patientList.value = await DoctorApi.getToBeInstalledPatientList(roomBedVO.value) |
| | | patientList.value = (await DoctorApi.getToBeInstalledPatientList(roomBedVO.value)) || [] |
| | | // 【自助诊断】记录本次取数时间与条数(空列表时显示) |
| | | fetchInfo.value = `最近取数 ${new Date().toLocaleTimeString()} · 返回 ${patientList.value.length} 条` |
| | | getInstallingPatient() |
| | | patientStat.value = await DoctorApi.getDevInstallStatistic(roomBedVO.value) |
| | | const queueVO2 = await DoctorApi.bedDoctorGet(roomBedVO.value) |
| | | if (queueVO2.status === 20) |
| | | // 【本需求】bed-doctor-get 是【我是否还坐在这里】的判定:失败说明工位已被释放 / 他人接手, |
| | | // 此时停掉轮询并一次性提示,避免每 5 秒刷一次【请重新就座】。 |
| | | let queueVO2: any |
| | | try { |
| | | queueVO2 = await DoctorApi.bedDoctorGet(roomBedVO.value) |
| | | } catch (e: any) { |
| | | if (isSeatInvalidError(e)) { |
| | | timerRunFlag = false |
| | | notifySeatInvalidOnce() |
| | | return |
| | | } |
| | | throw e |
| | | } |
| | | // 【加固】接口可能返回 null,原来直接取 .status 会抛异常、中断本轮后续步骤 |
| | | if (queueVO2 && queueVO2.status === 20) |
| | | state.value = true |
| | | else if (queueVO2.status === 30) |
| | | else if (queueVO2 && queueVO2.status === 30) |
| | | state.value = false |
| | | // 需求3:同步"停止候诊"开关状态 |
| | | await loadStopReady() |
| | |
| | | } |
| | | } |
| | | |
| | | const undoFinish = async () => { |
| | | const last = await DoctorApi.lastFinishedPatient(roomBedVO.value) |
| | | if (!last || !last.patId) { |
| | | ElMessage.warning('本工位今日暂无已完成的检查记录') |
| | | /** |
| | | * 撤销「装机完成」:撤销**选中的那条**完成记录(2026-11-25 需求)。 |
| | | * 原实现由后端 lastFinishedPatient 取最近一条,医生无法选择;现按「患者 + 检查项目」精确撤销。 |
| | | */ |
| | | const undoFinish = async (record?: any) => { |
| | | if (!record || !record.patId) { |
| | | ElMessage.warning('请先在「已完成列表」中点选一条记录,再点「撤销」') |
| | | return |
| | | } |
| | | const who = record.patName || record.patId |
| | | const ctName = record.checkTypeName || record.checkType || '' |
| | | try { |
| | | await ElMessageBox.confirm( |
| | | `确定撤销「${last.patName || last.patId}」的完成操作吗?该患者将回到候诊区。`, |
| | | `确定撤销「${who}」的「${ctName || '装机'}」完成记录吗?该患者将回到候诊区。`, |
| | | '撤销', |
| | | { type: 'warning', confirmButtonText: '确定撤销', cancelButtonText: '取消' } |
| | | ) |
| | |
| | | try { |
| | | const msg = await DoctorApi.undoFinishPatient({ |
| | | ...roomBedVO.value, |
| | | patId: last.patId, |
| | | checkType: last.bookCheckType |
| | | patId: record.patId, |
| | | checkType: record.checkType |
| | | } as any) |
| | | ElMessage.success(msg || '已撤销') |
| | | // 【撤销标识】撤销后立刻刷新「已完成记录」列表,让这条记录显示成「已撤销」 |
| | | devInstallPanelRef.value?.getList?.() |
| | | await initLoad() |
| | | } finally { |
| | | undoFlag.value = false |
| | |
| | | |
| | | const doctorTimer = () => { |
| | | console.log('doctorTimer ...') |
| | | initLoad() |
| | | // 【加固】单轮取数失败不能变成 unhandled rejection(原来 `initLoad()` 不 await 不 catch, |
| | | // 某轮接口异常会让页面停在旧数据,现场表现就是"列表一直是空的")。 |
| | | initLoad().catch((e) => console.error('[doctorTimer] 本轮取数失败(已忽略,下一轮继续)', e)) |
| | | if (timerRunFlag) |
| | | setTimeout(doctorTimer, 5000) // five seconds |
| | | } |
| | | |
| | | /** 初始化 **/ |
| | | /** |
| | | * 【主/围观】跟随 store 切换"正在查看的工位"(原来只在 onMounted 拷一次, |
| | | * 切到别的人工位围观后本页数据不变,必须刷新页面才生效)。 |
| | | */ |
| | | watch( |
| | | () => [roomStore.room?.roomId, roomStore.room?.bedNo], |
| | | async () => { |
| | | if (!roomStore.room) return |
| | | roomBedVO.value.roomId = roomStore.room.roomId |
| | | roomBedVO.value.roomName = roomStore.room.roomName |
| | | roomBedVO.value.bedNo = roomStore.room.bedNo |
| | | roomBedVO.value.checkTypes = roomStore.room.checkTypes |
| | | roomBedVO.value.opType = roomStore.room.opType |
| | | // 【本需求】重新拿到工位 -> 复位【工位失效】提示,允许下次再提示一次 |
| | | resetSeatInvalidNotify() |
| | | // 【本次需求】换工位后**整页数据都换成新工位的**: |
| | | // ① 先清空左侧"患者信息"(避免还显示上一个工位的患者) |
| | | devInstallPanelRef.value?.setPatient?.(undefined) |
| | | // ② 启动/继续取数定时器(待装列表、统计、当前叫号患者、停止候诊开关都会刷新) |
| | | if (!timerRunFlag && roomBedVO.value.roomId != null) { |
| | | timerRunFlag = true |
| | | doctorTimer() |
| | | } else if (roomBedVO.value.roomId != null) { |
| | | await initLoad() |
| | | } |
| | | // ③ 刷新「已完成列表」(面板内会按新工位的 checkTypes 重新过滤) |
| | | devInstallPanelRef.value?.getList?.() |
| | | } |
| | | ) |
| | | |
| | | onMounted(() => { |
| | | timerRunFlag = false |
| | | bedControlFlag.value = true |
| | |
| | | roomBedVO.value.bedNo = roomStore.room!.bedNo |
| | | roomBedVO.value.checkTypes = roomStore.room!.checkTypes |
| | | roomBedVO.value.opType = roomStore.room!.opType |
| | | resetSeatInvalidNotify() |
| | | |
| | | timerRunFlag = true |
| | | doctorTimer() |
| | |
| | | 布局优化:功能按钮固定在页面底部,不再用 position:absolute 浮在内容上。 |
| | | 详见 components/DoctorPageLayout(与叫号检查/设备领用页共用同一布局)。 |
| | | --> |
| | | <DoctorPageLayout> |
| | | <DoctorPageLayout :bed-switch-enabled="false"> |
| | | <template #header> |
| | | <TitlePanel :titleType=2 :room="roomBedVO" :patientStatistic="patientStat" /> |
| | | </template> |
| | |
| | | /> |
| | | |
| | | <template #aside> |
| | | <QueuePanel :room="roomBedVO" :queue="patientList" @event_RecallFinish="onEventRecallFinish"/> |
| | | <QueuePanel :room="roomBedVO" :queue="patientList" :fetch-info="fetchInfo" |
| | | @event_RecallFinish="onEventRecallFinish"/> |
| | | </template> |
| | | |
| | | |