yxh
10 天以前 97f4e581af58ca03ff4c39210fd4b2f3ae11f8ff
src/views/ecg/doctor/components/DevReadyPanel.vue
@@ -14,21 +14,21 @@
    >
      <!-- ===== 编辑区(需要录入的字段)===== -->
      <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-input v-model="formData.devId" :placeholder="requireDevId ? '请输入设备编号' : '可留空'" @input="getDevInfo"/>
          </el-form-item>
        </el-col>
      </el-row>
@@ -74,13 +74,21 @@
    </div>
  <!-- 医生装机列表 -->
  <!-- 【本次需求】操作功能区与已完成记录之间的标题栏 -->
  <div class="records-title">
    <span class="records-title__bar"></span>
    <span class="records-title__text">已完成列表</span>
  </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(修正):「撤销」作为**已完成领用记录列表的第一列**(表头插槽),
@@ -92,7 +100,8 @@
            type="warning"
            :disabled="undoDisabled"
            :loading="undoLoading"
            @click="$emit('event_undo_finish')"
            title="先在下方点选一条完成记录,再点此撤销"
            @click="undoSelected"
          >
            撤销
          </el-button>
@@ -105,9 +114,15 @@
      </el-table-column>
      <el-table-column label="领用情况" align="center" prop="cancelled" >
        <template #default="scope">
          <span v-if="scope.row.jobType === 5">"已领用"</span>
          <!-- 【本需求】完成被撤销过:该条记录显示「已撤销」;再次完成时后端 undone 自动变回 false -->
          <el-tag v-if="scope.row.undone" type="danger" size="small">已撤销</el-tag>
          <span v-else-if="scope.row.jobType === 5">"已领用"</span>
          <span v-if="scope.row.jobType === 30">"已放弃"</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" />-->
@@ -155,6 +170,7 @@
      </el-table-column>
-->
    </el-table>
    </div>
    </ContentWrap>
    <!-- 分页 -->
    <Pagination
@@ -184,6 +200,8 @@
import {calGender, getBookBeginTime} from "@/utils";
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import {tranlateDevState} from "@/utils/statusFormatter";
import { copyText } from '@/utils/copyText'
import { getConfigKey } from '@/api/infra/config'
import {getCheckTypeName, needAutoFeeConfirm, needDevReady} from "../../../../utils/checkTypeFormatter";
import { useRoomStore } from '@/store/modules/room'
// 需求1:患者信息 18 项统一展示块
@@ -242,6 +260,29 @@
  patId: [{ required: true, message: '目前没有患者', trigger: 'blur' }],
  patName: [{ required: true, message: '目前没有患者', trigger: 'blur' }]
})
/**
 * 【系统参数】动态血压和心电设备领用安装登记设备编号
 *   值“是”(默认)→ 设备编号必填;
 *   值“否”       → 允许不填(校验规则同步放开)。
 */
const requireDevId = ref(true)
const loadDevIdRequired = async () => {
  try {
    const value = await getConfigKey('ecg.dev.rent.device.no.required')
    const text = String(value ?? '').trim()
    requireDevId.value = !(
      text === '否' || text === '0' ||
      text.toLowerCase() === 'false' || text.toLowerCase() === 'no'
    )
  } catch (e) {
    console.warn('[DevReadyPanel] 读取“设备编号必填”系统参数失败,按必填处理', e)
    requireDevId.value = true
  }
  formRules.devId = requireDevId.value
    ? [{ required: true, message: '设备编号不能为空', trigger: 'blur' }]
    : []
}
const formRef = ref() // 表单 Ref
const devInfo = ref<Partial<DeviceVO>>({
@@ -251,7 +292,6 @@
  state: undefined,
})
const displayBarCode = ref<string> ()
const getRentInfoByPatId = () => {
  const tempPatId = formData.value.patId;
@@ -261,7 +301,6 @@
  formData.value.patId = tempPatId;
  getFreeRentInfo(formData.value)
  copyBarcode()
}
// 根据患者或设备, 获取 Free的租赁
@@ -309,7 +348,7 @@
      `「${ctName}」不需要设备领用,不能在设备领用模块办理。` +
      `请确认是否应到「叫号检查」页面处理该患者。`
    )
    return
    return false
  }
  // 校验表单
@@ -336,6 +375,7 @@
    // 发送操作成功的事件
    emit('event_dev_ready')
    message.success(t('操作完成'))
    return true
  } finally {
    formLoading.value = false
  }
@@ -416,6 +456,10 @@
  formData.value.doctor = queueVO?.doctor
  formData.value.doctorTime = queueVO?.doctorTime
  formData.value.patSrc = queueVO?.patSrc
  // 【本次修复】条码/打印小票依赖 patDetails(含 source/appointmentId),
  // 队列行本就带着它;原先只在 getFreeRentInfo() 查到"待检查单"时才赋值,
  // 导致绝大多数情况下 patDetails 为 undefined → 条码不显示。
  formData.value.patDetails = queueVO?.patDetails
  formData.value.patMobile = queueVO?.patMobile
  formData.value.patPhone = queueVO?.patPhone
  formData.value.patWardDesc = queueVO?.patWardDesc
@@ -426,9 +470,19 @@
    formData.value.doctorAdviceNo = queueVO?.doctorAdviceNo
  formData.value.patIdentityId = queueVO?.patIdentityId
  getFreeRentInfo(formData.value)  // 待检查的信息  @ dev_rent 表
  copyBarcode()
}
defineExpose({ setPatient }) // 提供 setPatient 方法,用于设置患者
/**
 * 【叫号自动完成】供父页面点「叫号」时先自动完成当前患者(等同点「领用完成」)。
 */
const completeCurrent = async (): Promise<boolean> => {
  try {
    return (await submitForm()) === true
  } catch (e) {
    console.warn('[DevReadyPanel] 自动「领用完成」失败', e)
    return false
  }
}
defineExpose({ setPatient, getList: () => getList(), completeCurrent }) // 提供 setPatient 方法,用于设置患者
const loading = ref(true) // 列表的加载中
@@ -488,9 +542,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) => {
@@ -584,7 +658,8 @@
*/
const getDevInfo = async () => {
  if (formData.value?.devId == null) {
  // 设备编号允许留空(系统参数=否)时,空值不再去查设备,避免无意义请求/报错
  if (!formData.value?.devId) {
    devInfo.value.brand = undefined
    devInfo.value.model = undefined
    devInfo.value.state = undefined
@@ -631,57 +706,84 @@
/**
 * 获取条形码,显示与否  同一个值
 */
const getDisplayBarcode = (): string => {
  if (formData.value.checkType == null)
    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)
})
  if (formData.value.patDetails?.source == null)
    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)
})
  const displayBarcode: number[] = checkTypeStore.getCheckTypeDispBarCode(formData.value.checkType)
  if (displayBarcode == null || displayBarcode.length === 0)
    return ""
/** 条码 / 复制的内容:统一取「就诊流水号」 */
const barcodeContent = computed<string>(() =>
  barcodeEnabled.value ? (formData.value.episodeId ?? '') : ''
)
  if (!displayBarcode.includes( formData.value.patDetails.source ))
    return ""
/** 是否显示条码:住院(来源 3)不显示;内容为空时也不显示 */
const showBarCode = computed<boolean>(
  () => barcodeEnabled.value && patSourceValue.value !== 3 && barcodeContent.value !== ''
)
  return getBarcode()
}
const getBarcode = (): string => {
  if (formData.value.checkType == null)
    return ""
  const patSource = formData.value.patDetails?.source
  if (patSource == null)
    return ""
  if (1 === patSource || 2 === patSource)
    return formData.value.applyNo??""
  else if (3 === patSource || 4 === patSource)
    return formData.value.episodeId??""
  return ""
}
/** 是否显示「复制」按钮:与条码一致(同受配置控制) */
const showCopyButton = computed<boolean>(() => barcodeEnabled.value)
const copyBarcode = async () => {
  displayBarCode.value = getDisplayBarcode()
  const barCode = getBarcode()
  if (isStringEmpty(barCode))
    return
  await navigator.clipboard.writeText( barCode );
  if (!barcodeContent.value) return
  // 【兼容 Chrome 85 / http 访问】非安全上下文下 navigator.clipboard 不可用,用兼容实现
  const ok = await copyText(barcodeContent.value)
  if (ok) {
    message.success('已复制')
  } else {
    message.warning('当前浏览器不支持自动复制,请手动选中复制')
  }
}
/** 初始化 **/
onMounted(() => {
  getList()
  loadDevIdRequired()
})
</script>
<style scoped lang="scss">
/* 【本次需求】「已完成列表」标题栏:左侧主色竖线 + 加粗小标题,紧凑高度不挤压表格 */
.records-title {
  display: flex;
  align-items: center;
  flex: none;
  gap: 6px;
  padding: 2px 0 6px;
  &__bar {
    width: 3px;
    height: 14px;
    background-color: var(--el-color-primary);
    border-radius: 2px;
  }
  &__text {
    font-size: 15px;
    font-weight: 600;
    color: var(--el-text-color-primary);
  }
}
/* ==========================================================================
   需求:表单内容挤占了下方记录表格的空间 —— 压缩行间距。
   Element Plus 默认 `.el-form-item { margin-bottom: 18px }`;
@@ -733,19 +835,43 @@
.patient-actions {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  /* 按钮多时允许换行,避免挤在一行(检查页最多 6 个按钮) */
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  /* 上下留白 + 分隔线,形成独立功能块 */
  padding: 6px 4px;
  margin-bottom: 6px;
  background-color: var(--el-bg-color);
  border-top: 1px solid var(--el-border-color-lighter);
  border-bottom: 1px solid var(--el-border-color-lighter);
  /*
    【本次需求】操作功能区做一点视觉区分,方便医生一眼定位:
    极浅的主色底 + 细边框 + 左侧 3px 主色竖条(与「▎已完成列表」标题条同款语言)。
    只做"稍有区分",不改按钮本身的尺寸/颜色/顺序。
  */
  padding: 8px 10px;
  margin: 2px 0 10px;
  background-color: var(--el-color-primary-light-9);
  border: 1px solid var(--el-color-primary-light-7);
  border-left: 3px solid var(--el-color-primary);
  border-radius: 4px;
  /* Element Plus 给相邻 el-button 默认加了 margin-left:12px,会与 gap 叠加,清掉 */
  :deep(.el-button + .el-button) {
    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>