yxh
2026-11-26 bd3f4b0a9b9207b647de0f0d8c52600a2742fd56
src/views/ecg/doctor/DevInstall.vue
@@ -9,8 +9,9 @@
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();
@@ -51,12 +52,26 @@
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
  }
@@ -89,11 +104,9 @@
const initLoad = async () => {
  if (roomBedVO.value.roomId == null) {
    ElNotification.error({
      message: '请重新就座!',
      type: 'info',
      duration: 3000 // 自动关闭时间,默认为3000ms
    })
    // 【本需求】没有工位:停掉轮询并只提示一次(原来每 5 秒弹一次,现场表现就是一直跳)
    timerRunFlag = false
    notifySeatInvalidOnce()
    return
  }
@@ -102,7 +115,19 @@
  fetchInfo.value = `最近取数 ${new Date().toLocaleTimeString()} · 返回 ${patientList.value.length} 条`
  getInstallingPatient()
  patientStat.value = await DoctorApi.getDevInstallStatistic(roomBedVO.value)
  const queueVO2 = await DoctorApi.bedDoctorGet(roomBedVO.value)
  // 【本需求】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
@@ -170,15 +195,20 @@
  }
}
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: '取消' }
    )
@@ -189,8 +219,8 @@
  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 || '已撤销')
    // 【撤销标识】撤销后立刻刷新「已完成记录」列表,让这条记录显示成「已撤销」
@@ -239,6 +269,8 @@
    roomBedVO.value.bedNo = roomStore.room.bedNo
    roomBedVO.value.checkTypes = roomStore.room.checkTypes
    roomBedVO.value.opType = roomStore.room.opType
    // 【本需求】重新拿到工位 -> 复位【工位失效】提示,允许下次再提示一次
    resetSeatInvalidNotify()
    // 【本次需求】换工位后**整页数据都换成新工位的**:
    // ① 先清空左侧"患者信息"(避免还显示上一个工位的患者)
    devInstallPanelRef.value?.setPatient?.(undefined)
@@ -266,6 +298,7 @@
    roomBedVO.value.bedNo = roomStore.room!.bedNo
    roomBedVO.value.checkTypes = roomStore.room!.checkTypes
    roomBedVO.value.opType = roomStore.room!.opType
    resetSeatInvalidNotify()
    timerRunFlag = true
    doctorTimer()