yxh
2026-11-26 bd3f4b0a9b9207b647de0f0d8c52600a2742fd56
src/views/ecg/doctor/components/DevInstallPanel.vue
@@ -2,19 +2,19 @@
  <el-form class="patient-compact-form" ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading">
    <!-- ===== 编辑区(需要录入的字段)===== -->
    <el-row :gutter="20">
      <el-col :span="6">
      <el-col :xs="24" :sm="12" :md="12" :lg="6">
        <el-form-item label="检查项目" prop="">
          {{ getCheckTypeName(formData.checkType) }}
        </el-form-item>
      </el-col>
      <el-col :span="12">
      <el-col :xs="24" :sm="24" :md="12" :lg="12">
        <el-form-item label="患者编号" prop="patId">
          <el-input v-model="formData.patId" placeholder="请输入患者编号" @input="getRentInfoByPatId" />
          <Barcode v-if="displayBarCode" :value="displayBarCode" :width=100 />
          <el-button @click="copyBarcode()">复制</el-button>
          <Barcode v-if="showBarCode" :value="barcodeContent" :width=100 />
          <el-button v-if="showCopyButton" :disabled="!barcodeContent" @click="copyBarcode()">复制</el-button>
        </el-form-item>
      </el-col>
      <el-col :span="6">
      <el-col :xs="24" :sm="12" :md="12" :lg="6">
        <el-form-item label="设备编号" prop="devId">
          <el-input v-model="formData.devId" placeholder="请输入设备编号" @input="getDevInfo" />
        </el-form-item>
@@ -50,11 +50,14 @@
  </div>
  <div class="records-host">
    <ContentWrap class="records-wrap">
    <div class="records-scroll">
    <el-table
      v-loading="loading"
      :data="list"
      :stripe="true"
      :show-overflow-tooltip="true"
      highlight-current-row
      @current-change="onCurrentRowChange"
      @row-click="onRowClick"
    >
      <!-- 需求11(修正):「撤销」作为**已完成装机记录列表的第一列**(表头插槽),
@@ -66,7 +69,8 @@
            type="warning"
            :disabled="undoDisabled"
            :loading="undoLoading"
            @click="$emit('event_undo_finish')"
            title="先在下方点选一条完成记录,再点此撤销"
            @click="undoSelected"
          >
            撤销
          </el-button>
@@ -79,6 +83,10 @@
          <span v-else-if="scope.row.jobType === 10">"已装机"</span>
          <span v-if="scope.row.jobType === 35">"已放弃"</span>
        </template>
      </el-table-column>
      <!-- 【2026-11-25 需求】同一患者可能有多个检查项目,已完成列表列出来才能区分/精确撤销 -->
      <el-table-column label="检查项目" align="center" width="150">
        <template #default="scope">{{ getCheckTypeName(scope.row.checkType) }}</template>
      </el-table-column>
      <!--      <el-table-column label="作业类型" align="center" prop="jobType" />-->
      <!--      <el-table-column label="医生编号" align="center" prop="docId" />-->
@@ -111,6 +119,7 @@
        </template>
      </el-table-column>-->
    </el-table>
    </div>
    </ContentWrap>
    <!-- 分页 -->
    <Pagination
@@ -136,6 +145,7 @@
import { useCheckTypeStore } from "@/store/modules/checkType";
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { tranlateDevState } from "../../../../utils/statusFormatter";
import { copyText } from '@/utils/copyText'
import { getCheckTypeName, needDevReady } from "../../../../utils/checkTypeFormatter";
import { useRoomStore } from '@/store/modules/room'
// 需求1:患者信息 18 项统一展示块
@@ -171,7 +181,6 @@
const formRef = ref() // 表单 Ref
const displayBarCode = ref<string>()
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
@@ -234,9 +243,19 @@
    formData.value.doctorAdviceNo = queueVO?.doctorAdviceNo
  formData.value.patIdentityId = queueVO?.patIdentityId
  getReadyRentInfo(formData.value)    // 获取领用信息
  copyBarcode()
}
defineExpose({ setPatient, getList: () => getList() }) // 提供 setPatient 方法,用于设置患者
/**
 * 【叫号自动完成】供父页面点「叫号」时先自动完成当前患者(等同点「装机完成」)。
 */
const completeCurrent = async (): Promise<boolean> => {
  try {
    return (await submitForm()) === true
  } catch (e) {
    console.warn('[DevInstallPanel] 自动「装机完成」失败', e)
    return false
  }
}
defineExpose({ setPatient, getList: () => getList(), completeCurrent }) // 提供 setPatient 方法,用于设置患者
/** 提交表单 */
@@ -249,7 +268,7 @@
    message.warning(
      `「${ctName}」不需要设备领用,不能办理装机。请确认是否应到「叫号检查」页面处理该患者。`
    )
    return
    return false
  }
  // 校验表单
@@ -271,6 +290,7 @@
    // 发送操作成功的事件
    emit('event_dev_install')
    message.success(t('操作成功'))
    return true
  } finally {
    formLoading.value = false
  }
@@ -344,7 +364,6 @@
  formData.value.patId = tempPatId;
  getReadyRentInfo(formData.value)
  copyBarcode()
}
// 获取患者的领用信息
@@ -435,9 +454,29 @@
    const data = await JobRecordApi.getJobRecordDoctorPage(queryParams)
    list.value = data.list
    total.value = data.total
    // 列表刷新后旧的选中行已失效,清掉,避免「撤销」作用到上一屏的记录
    selectedRecord.value = undefined
  } finally {
    loading.value = false
  }
}
/** 【2026-11-25 需求】已完成列表的选中行:撤销前先点选一条,撤销作用在选中记录上 */
const selectedRecord = ref<any>()
const onCurrentRowChange = (row: any) => {
  selectedRecord.value = row || undefined
}
/** 撤销:只撤销当前选中的那条完成记录(未选中时提示,不再默认撤销"最近一条") */
const undoSelected = () => {
  if (!selectedRecord.value) {
    message.warning('请先在「已完成列表」中点选一条记录,再点「撤销」')
    return
  }
  emit('event_undo_finish', {
    ...selectedRecord.value,
    checkTypeName: getCheckTypeName(selectedRecord.value.checkType)
  })
}
const onRowClick = (cur) => {
@@ -474,46 +513,51 @@
  getList()
}
const getDisplayBarcode = (): string => {
  if (!formData.value.checkType)
    return ""
/**
 * 【本需求】患者条码口径(门诊/急诊/体检 = 就诊流水号;住院不出条码,只留「复制」)
 *
 *  · 门诊(1) / 急诊(2) / 体检(4) → 条码内容 = **就诊流水号**(episodeId)
 *  · 住院(3)                    → **不显示条码**,只保留「复制」按钮(复制内容同样是就诊流水号)
 *  · 「复制」按钮与条码一致:同受「检查类型 → 患者条码显示」配置控制
 *    (该检查类型未勾选这个患者来源时,条码和复制按钮都不显示)
 */
const patSourceValue = computed<number | null>(() => {
  const source = formData.value.patDetails?.source ?? formData.value.patSrc
  return source === null || source === undefined || source === '' ? null : Number(source)
})
  // 【本次修复】「患者条码显示」未配置(null/空)→ 不显示(按现场确认口径)
  const displayBarcode: number[] | undefined = checkTypeStore.getCheckTypeDispBarCode(formData.value.checkType!)
  if (displayBarcode == null || displayBarcode.length === 0)
    return ""
/** 是否通过了「患者条码显示」配置(勾选了当前患者来源) */
const barcodeEnabled = computed<boolean>(() => {
  if (formData.value.checkType == null) return false
  const displayBarcode: number[] | undefined = checkTypeStore.getCheckTypeDispBarCode(formData.value.checkType)
  if (displayBarcode == null || displayBarcode.length === 0) return false
  const patSource = patSourceValue.value
  if (patSource == null) return false
  return displayBarcode.map(Number).includes(patSource)
})
  // 【本次修复】来源优先取 patDetails.source,缺失时回退到平铺的 patSrc
  // (原来直接取 patDetails.source,patDetails 缺失时 `.includes` 还会抛异常)
  const patSource = formData.value.patDetails?.source ?? formData.value.patSrc
  if (patSource == null)
    return ""
  if (!displayBarcode.map(Number).includes(Number(patSource)))
    return ""
/** 条码 / 复制的内容:统一取「就诊流水号」 */
const barcodeContent = computed<string>(() =>
  barcodeEnabled.value ? (formData.value.episodeId ?? '') : ''
)
  return getBarcode()
}
/** 是否显示条码:住院(来源 3)不显示;内容为空时也不显示 */
const showBarCode = computed<boolean>(
  () => barcodeEnabled.value && patSourceValue.value !== 3 && barcodeContent.value !== ''
)
const getBarcode = (): string => {
  if (!formData.value.checkType)
    return ""
  const patSource = formData.value.patDetails?.source ?? formData.value.patSrc
  if (patSource == null)
    return ""
  // 门诊/急诊 → 申请单号;住院/体检 → 就诊流水号
  if (1 === Number(patSource) || 2 === Number(patSource))
    return formData.value.applyNo ?? ""
  else if (3 === Number(patSource) || 4 === Number(patSource))
    return formData.value.episodeId ?? ""
  return ""
}
/** 是否显示「复制」按钮:与条码一致(同受配置控制) */
const showCopyButton = computed<boolean>(() => barcodeEnabled.value)
const copyBarcode = async () => {
  displayBarCode.value = getDisplayBarcode()
  await navigator.clipboard.writeText(getBarcode());
  if (!barcodeContent.value) return
  // 【兼容 Chrome 85 / http 访问】非安全上下文下 navigator.clipboard 不可用,用兼容实现
  const ok = await copyText(barcodeContent.value)
  if (ok) {
    message.success('已复制')
  } else {
    message.warning('当前浏览器不支持自动复制,请手动选中复制')
  }
}
/** 初始化 **/
@@ -542,7 +586,7 @@
  }
  &__text {
    font-size: 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--el-text-color-primary);
  }
@@ -619,4 +663,22 @@
    margin-left: 0;
  }
}
/* ==========================================================================
   【2026-11-25 需求】已完成列表:只显示 4 行左右,超过就出现纵向滚动条
   (实测行高 40px、表头 63px → 63 + 4×40 + 2 = 225px)。
   ========================================================================== */
.records-scroll {
  max-height: 225px;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  :deep(.el-table__header-wrapper) {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--el-bg-color);
  }
}
</style>