yxh
2026-10-05 936c01060eea0924b88ca5c35d221a972a6aba7d
src/views/ecg/doctor/components/RoutinePanel.vue
@@ -1,76 +1,112 @@
<!-- 常规检查 医生界面-->
<template>
    <el-form
      ref="formRef"
      :model="formData"
      :rules="formRules"
      label-width="100px"
      v-loading="formLoading"
    >
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="患者编号" prop="patId">
            <el-input v-model="formData.patId" placeholder="请输入患者编号" @input="getRentInfoByPatId" />
            <Qrcode v-if="formData.patId !== undefined && formData.patId !== ''" :text="formData.patId" logo="/logo.gif" width=100 />
          </el-form-item>
          <el-form-item label="患者名称" prop="patName">
            <el-input v-model="formData.patName" placeholder="请输入患者名称" />
          </el-form-item>
          <el-form-item label="患者描述" prop="patDeptDesc">
            科室: {{formData.patDeptDesc}} 病区: {{formData.patWardDesc}} 床位: {{formData.patBedNo}}
          </el-form-item>
          <el-form-item label="检查时间" prop="rentTime">
            <el-date-picker
                v-model="formData.rentTime"
                type="date"
                value-format="x"
                placeholder="选择装机时间"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="formData.remark" placeholder="请输入备注" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-button @click="submitForm" type="primary" :disabled="formLoading">检查完成</el-button>
    <el-button @click="resetForm()">重 置</el-button>
    <el-button @click="cancelInstall"  :disabled="formLoading">放弃检查</el-button>
  <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-form-item label="申请单号" prop="applyNo">
          <el-input v-model="formData.applyNo" placeholder="请输入申请单号" />
        </el-form-item>
      </el-col>
       <el-col :span="6">
        <el-form-item label="检查项目" prop="">
          {{ formData?.checkType && getCheckTypeName(formData?.checkType) }}
        </el-form-item>
      </el-col>
        <el-col :span="6">
        <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>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="患者姓名" prop="patName">
          <el-input v-model="formData.episodeId" placeholder="请输入患者姓名" />
        </el-form-item>
      </el-col>
    </el-row>
    <!-- ===== 患者信息(需求1:18 项统一展示,**一行四列**)=====
         原先本面板把 18 项手写在多行 el-col(span=6/18 混排),
         现统一改用 PatientInfoBlock 组件,与预约签到/设备领用/装机/拆机各页**口径一致**。 -->
    <PatientInfoBlock :data="formData" check-type-field="checkType" :span="6" />
    <el-row>
      <el-col :span="6">
        <el-form-item label="检查时间" prop="rentTime">
          <el-date-picker v-model="formData.rentTime" type="date" value-format="x" placeholder="选择时间" />
        </el-form-item>
      </el-col>
      <el-col :span="18">
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formData.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
  <div class="patient-actions">
  <el-button size="small" @click="submitForm" type="primary" :disabled="formLoading">检查完成</el-button>
  <el-button size="small" @click="cancelInstall" :disabled="formLoading">放弃检查</el-button>
  <el-button size="small" @click="resetForm()">重 置</el-button>
  <el-button size="small" @click="yddownload()" :loading="yddownloadLoading" :disabled="yddownloadLoading">平板运动心电图知情同意书</el-button>
  <el-button size="small" @click="sgdownload()" :loading="sgdownloadLoading" :disabled="sgdownloadLoading">食管心脏电生理诊疗知情同意书</el-button>
  <el-button size="small" v-if="needAutoFeeConfirm(formData.checkType)" @click="feeConfirm" :disabled="formLoading">确费</el-button>
  <el-button size="small" v-if="needAutoFeeConfirm(formData.checkType)" @click="feeCancel" :disabled="formLoading">取消确费</el-button>
  </div>
  <!-- 医生装机列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" @row-click="onRowClick" >
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="装机情况" align="center" prop="lost" >
  <!--
    已完成记录列表。
    滚动方式:**中间内容区自身滚动**(.doctor-page__content 为 overflow-y:auto),
    患者信息用 sticky 固定在顶部;底部 footer 由 DoctorPageLayout 固定,无需滚动即可见。
    (曾尝试让 el-table 内部滚动以固定表头,但本项目 Element Plus 2.7.0 下
       height/maxHeight 均未生效,已回退,详见《部署清单》5.3.15。)
  -->
  <div class="records-host">
    <ContentWrap class="records-wrap">
      <el-table
        v-loading="loading"
        :data="list"
        :stripe="true"
        :show-overflow-tooltip="true"
        @row-click="onRowClick"
      >
      <!--
        需求11(修正):把「撤销」放在**已完成检查记录列表的第一列**里。
        原先放在表格上方的独立按钮行,位置不对 —— 现改为该列的**表头插槽**,
        使其成为表格的第一列(且只出现一次,作用于最近一位已完成患者,
        语义与后端 lastFinishedPatient 一致)。
      -->
      <el-table-column label="撤销" align="center" width="90px" fixed="left">
        <template #header>
          <el-button
            link
            type="warning"
            :disabled="undoDisabled"
            :loading="undoLoading"
            @click="$emit('event_undo_finish')"
          >
            撤销
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="检查状态" align="center" prop="lost">
        <template #default="scope">
          <span v-if="scope.row.jobType === 60">已检查</span>
          <span v-if="scope.row.jobType === 50">已放弃</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="作业类型" align="center" prop="jobType" />-->
<!--      <el-table-column label="医生编号" align="center" prop="docId" />-->
      <!--      <el-table-column label="作业类型" align="center" prop="jobType" />-->
      <!--      <el-table-column label="医生编号" align="center" prop="docId" />-->
      <el-table-column label="医生名称" align="center" prop="docName" />
<!--      <el-table-column label="设备编号" align="center" prop="devId" />-->
      <!--      <el-table-column label="设备编号" align="center" prop="devId" />-->
      <el-table-column label="患者编号" align="center" prop="patId" />
      <el-table-column label="患者名称" align="center" prop="patName" />
      <el-table-column
          label="作业时间"
          align="center"
          prop="jobTime"
          :formatter="dateFormatter"
          width="180px"
      />
<!--      <el-table-column label="作业概要" align="center" prop="summary" />-->
      <el-table-column label="作业时间" align="center" prop="jobTime" :formatter="dateFormatter" width="180px" />
      <!--      <el-table-column label="作业概要" align="center" prop="summary" />-->
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column
          label="创建时间"
          align="center"
          prop="createTime"
          :formatter="dateFormatter"
          width="180px"
      />
      <el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" width="180px" />
      <!--
      <el-table-column label="操作" align="center" min-width="120px">
        <template #default="scope">
          <el-button
@@ -91,47 +127,108 @@
          </el-button>
        </template>
      </el-table-column>
    </el-table>
-->
      </el-table>
    </ContentWrap>
    <!-- 分页 -->
    <Pagination
        :total="total"
        v-model:page="queryParams.pageNo"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>
  </div>
</template>
<script setup lang="ts">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { DevRentApi, DevRentVO } from '@/api/ecg/devrent'
import {dateFormatter} from "@/utils/formatTime";
import {JobRecordApi, JobRecordVO} from "@/api/ecg/jobrecord";
import {isStringEmpty} from "@/utils/stringUtil";
import {curDayEnd, curDayStart} from "@/utils/dateUtil";
import {DeviceApi} from "@/api/ecg/devmanage";
import {QueueVO} from "@/api/ecg/queue";
import {RoomBedVO} from "@/api/ecg/doctor";
import {AppointmentApi} from "@/api/ecg/appointment";
import { dateFormatter } from '@/utils/formatTime'
import { JobRecordApi, JobRecordVO } from '@/api/ecg/jobrecord'
import { isStringEmpty } from '@/utils/stringUtil'
import { calculateAge, curDayEnd, curDayStart, formatTimestamp } from '@/utils/dateUtil'
import { calGender } from '@/utils'
import dayjs from 'dayjs'
import { QueueVO } from '@/api/ecg/queue'
import { RoomBedVO, DoctorApi } from '@/api/ecg/doctor'
import { Barcode } from '@/components/Barcode'
import { useCheckTypeStore } from '@/store/modules/checkType'
import { getCheckTypeName, needAutoFeeConfirm } from '../../../../utils/checkTypeFormatter'
import { useRoomStore } from '@/store/modules/room'
// ⚠️ 必须显式 import:`unplugin-vue-components` 的 globs 只覆盖
//    `src/components/**`(见 build/vite/index.ts 的 Components({ globs: [...] })),
//    因此 src/components/ 下的 Dialog、ContentWrap、Pagination 等可自动引入,
//    但 **src/views/** 下的本组件必须手写 import**。
//    若漏写,Vue 会把它当成「未知标签」**静默不渲染**(只有控制台 warning),
//    而 vite build 与 ESLint 都不会报错 —— 实测因改造时误删本行 import,
//    导致「叫号检查」页面患者信息**整块消失**。
import PatientInfoBlock from '@/views/ecg/doctor/components/PatientInfoBlock.vue'
/** 设备装机 表单 */
defineComponent({ name: 'RoutinePanel' })
const  props = defineProps({
const props = defineProps({
  room: {
    type: Object as PropType<RoomBedVO>,
    required: true
  },
  setappointmentId: {
    type: [String, Number],
    required: false,
    default: null
  },
  /**
   * 需求11:记录列表第一列的「撤销」按钮状态,由父页面控制
   * (撤销动作请求后端、需要 loading 与禁用态,逻辑保留在父页面)。
   */
  undoDisabled: {
    type: Boolean,
    required: false,
    default: false
  },
  undoLoading: {
    type: Boolean,
    required: false,
    default: false
  }
})
const emit = defineEmits(['event_routine']) // 定义 success 事件,用于操作成功后的回调
const emit = defineEmits(['event_routine', 'event_undo_finish'])
const checkTypeStore = useCheckTypeStore()
const setPatient = (queueVO: QueueVO | undefined) => {
  resetForm()
  formData.value.applyNo = queueVO?.applyNo
  formData.value.episodeId = queueVO?.episodeId
  formData.value.patId = queueVO?.patId
  formData.value.patName = queueVO?.patName
  formData.value.checkType = queueVO?.bookCheckType
  // 以下字段由后端从预约单补齐(queue 表不存),用于医生端展示
  formData.value.patGender = queueVO?.patGender
  formData.value.tolerance = queueVO?.tolerance
  formData.value.patBirthday = queueVO?.patBirthday
  formData.value.registerDate = queueVO?.registerDate
  formData.value.doctor = queueVO?.doctor
  formData.value.doctorTime = queueVO?.doctorTime
  // 需求1:补齐排队序号 / 状态 / 病区 / 床号 / 电话 / 来源 / 门诊号
  // 这些平铺字段由后端 QueueServiceImpl#fillAppointmentInfo 回填,
  // 原先这里没有赋值,导致模板里读不到(显示为空)。
  formData.value.seqNum = queueVO?.seqNum
  formData.value.status = queueVO?.status
  formData.value.patSrc = queueVO?.patSrc
  formData.value.patMobile = queueVO?.patMobile
  formData.value.patPhone = queueVO?.patPhone
  formData.value.patWardDesc = queueVO?.patWardDesc
  formData.value.patBedNo = queueVO?.patBedNo
  formData.value.medicalCard = queueVO?.medicalCard
  formData.value.outpatientNo = queueVO?.outpatientNo
    // 需求1:医嘱号(此前 3 个面板都遗漏了该字段的赋值,导致 PatientInfoBlock 恒显示 '-')
    formData.value.doctorAdviceNo = queueVO?.doctorAdviceNo
  formData.value.patIdentityId = queueVO?.patIdentityId
  getFreeRentInfo(formData.value)
  copyBarcode()
}
defineExpose({ setPatient }) // 提供 setPatient 方法,用于设置患者
@@ -139,16 +236,64 @@
const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // 弹窗的是否展示
const yddownloadLoading = ref(false);
const sgdownloadLoading = ref(false);
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const formData = ref({})
const formData = ref<Partial<DevRentVO>>({
  id: undefined,
  devId: undefined,
  patId: undefined,
  patName: undefined,
  patGender: undefined,
  patDetails: undefined,
  checkType: undefined,
  rentTime: new Date().getTime(),
  returnTime: undefined,
  tolerance: undefined,
  patBirthday: undefined,
  registerDate: undefined,
  doctor: undefined,
  doctorTime: undefined,
  remark: undefined,
  paid: undefined
})
/** 后端日期统一是毫秒时间戳,转成 YYYY-MM-DD 展示 */
const fmtDate = (value?: number | null) => (value ? formatTimestamp(value as unknown as Date) : '')
// 性别:1 男 2 女。为空时不走 calGender(它会把空值当成"女")
const genderText = computed(() => {
  const gender = formData.value.patGender
  return gender === 1 || gender === 2 ? calGender(gender) : ''
})
// 年龄:按出生日期计算
const ageText = computed(() => {
  const birthday = formData.value.patBirthday
  if (!birthday) {
    return ''
  }
  const age = calculateAge(birthday as unknown as Date)
  return Number.isFinite(age) ? `${age}岁` : ''
})
// 距今天数:按开单日期(doctorTime)计算
const daysFromOrder = computed(() => {
  const orderTime = formData.value.doctorTime
  if (!orderTime) {
    return ''
  }
  return `${dayjs().startOf('day').diff(dayjs(orderTime).startOf('day'), 'day')}天`
})
const formRules = reactive({
  // devId: [{ required: true, message: '设备编号不能为空', trigger: 'blur' }],
  rentTime: [{ required: true, message: '请选择装机日期', trigger: 'blur' }],
  rentTime: [{ required: true, message: '请选择装机日期', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
const displayBarCode = ref<string>()
/** 提交表单 */
const submitForm = async () => {
@@ -161,12 +306,18 @@
    formData.value.bedNo = props.room.bedNo
    const data = formData.value as unknown as DevRentVO
    await DevRentApi.routineFinish(data)
    // 自动确费
    if (needAutoFeeConfirm(formData.value.checkType)) {
      feeConfirm()
    }
    message.success(t('操作成功'))
    dialogVisible.value = false
    // 发送操作成功的事件
    emit('event_routine')
    resetForm()
    getList()
    getList() // 医生作业历史
  } finally {
    formLoading.value = false
  }
@@ -179,49 +330,132 @@
    devId: undefined,
    patId: undefined,
    patName: undefined,
    patDeptCode: undefined,
    patDeptDesc: undefined,
    patWardCode: undefined,
    patWardDesc: undefined,
    patBedNo: undefined,
    patGender: undefined,
    checkType: undefined,
    rentTime: new Date().getTime(),
    returnTime: undefined,
    tolerance: undefined,
    patBirthday: undefined,
    registerDate: undefined,
    doctor: undefined,
    doctorTime: undefined,
    interference: undefined,
    baseline: undefined,
    detachment: undefined,
    remark: undefined,
    category: '',
    brand: '',
    model: '',
    patDetails: undefined,
    paid: undefined,
    doctorAdviceNo: undefined,
    roomId: props.room.roomId,
    bedNo: props.room.bedNo
  }
  formRef.value?.resetFields()
}
const getRentInfoByPatId = () => {
  const tempPatId = formData.value.patId;
  resetForm()
  if (isStringEmpty(tempPatId))
const yddownload = async () => {
  // 检查 setappointmentId 是否存在
  if (!props.setappointmentId) {
    message.warning('当前无就诊中患者请先叫号')
    return
  }
  formData.value.patId = tempPatId;
  yddownloadLoading.value = true
  try {
    const response = await DoctorApi.yddownload(props.setappointmentId)
    console.log(response, 'xml1')
    console.log(response.fileContent, 'xml2')
    downloadWordFile(response.fileContent, response.fileName)
  } finally {
    yddownloadLoading.value = false
  }
}
const sgdownload = async () => {
  // 检查 setappointmentId 是否存在
  if (!props.setappointmentId) {
    message.warning('当前无就诊中患者请先叫号')
    return
  }
  sgdownloadLoading.value = true
  try {
    const response = await DoctorApi.sgdownload(props.setappointmentId)
    downloadWordFile(response.fileContent, response.fileName)
  } finally {
    sgdownloadLoading.value = false
  }
}
const downloadWordFile = (data, filename = 'document') => {
  try {
    // 1. 确保文件名以.doc结尾
    if (!filename.endsWith('.doc')) {
      filename += '.doc'
    }
    // 2. 创建Blob对象,指定MIME类型为Word文档[9,10](@ref)
    // 对于Word 2003 XML格式,使用'application/msword'
    const blob = new Blob([data], { type: 'application/msword' })
    // 3. 为Blob对象创建一个临时的下载URL[8,10](@ref)
    const url = URL.createObjectURL(blob)
    // 4. 创建一个隐藏的不可见的<a>链接元素[10](@ref)
    const link = document.createElement('a')
    link.style.display = 'none' // 隐藏链接
    link.href = url
    link.download = filename // 设置下载的文件名
    // 5. 将链接添加到DOM中,模拟点击,然后移除它[10](@ref)
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
    // 6. 释放URL对象以释放内存[9,10](@ref)
    // 使用setTimeout确保下载触发后再释放
    setTimeout(() => {
      URL.revokeObjectURL(url)
    }, 100)
    console.log('文件下载已触发!')
  } catch (error) {
    console.error('下载文件时发生错误:', error)
    // 这里可以添加更友好的用户错误提示,例如使用alert或页面弹窗
  }
}
const getRentInfoByPatId = () => {
  const tempPatId = formData.value.patId
  resetForm()
  if (isStringEmpty(tempPatId)) return
  formData.value.patId = tempPatId
  getFreeRentInfo(formData.value)
  copyBarcode()
}
const getFreeRentInfo = async (devRentVO) => {
  const data = await DevRentApi.getFreeRent(devRentVO)
  if (null === data)
  if (
    (devRentVO.devId == null || devRentVO.devId === '') &&
    (devRentVO.patId == null || devRentVO.patId === '')
  )
    return
  const data = await DevRentApi.getFreeRent(devRentVO)
  if (null === data) return
  // formDate 对应  DevRent
  // formData.value = data  //不能整个赋值, 默认领用时间被清空
  formData.value.id = data.id;
  formData.value.id = data.id //rent id
  formData.value.applyNo = data.applyNo
  formData.value.episodeId = data.episodeId
  formData.value.patDetails = data.patDetails
}
const loading = ref(true) // 列表的加载中
const list = ref<JobRecordVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
// 当前诊室信息(用于取诊室开展的检查项目做兜底,见 syncRoomCheckTypes)
const roomStore = useRoomStore()
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
@@ -234,10 +468,37 @@
  jobTime: [curDayStart(), curDayEnd()],
  summary: undefined,
  remark: undefined,
  createTime: []
  createTime: [],
  // ========================================================================
  // 按**当前诊室开展的检查项目**隔离已完成记录。
  //
  // 背景:`job_record` 表只有 doc_id + check_type,**没有 room_id**;
  // 而 /ecg/job-record/doctor-page 是强制按登录医生查"自己的记录"。
  // 于是同一医生在多个诊室坐诊时(如 1号门诊 ct=[100,1100]、6号门诊 ct=[400] 平板运动心电),
  // 叫号检查页会把**多个诊室的记录混在一起**显示 —— 正是用户反馈的现象。
  //
  // 由各页面(Routine.vue / index.vue / DevInstall.vue)在 onMounted 时
  // 用当前诊室的 checkTypes 赋值,并在每次查询前同步,确保切诊室后立即生效。
  // ========================================================================
  checkTypes: undefined as number[] | undefined
})
/**
 * 把「当前诊室开展的检查项目」同步到查询条件,实现已完成记录按诊室隔离。
 * 见 queryParams.checkTypes 的说明。
 */
const syncRoomCheckTypes = () => {
  // 优先用页面传入的诊室信息;为空时回退到 store(更可靠,见 TitlePanel 同处说明)
  const fromProp = props.room?.checkTypes
  const types = (Array.isArray(fromProp) && fromProp.length > 0)
    ? fromProp
    : roomStore.room?.checkTypes
  queryParams.checkTypes = (Array.isArray(types) && types.length > 0) ? [...types] : undefined
}
/** 查询列表 */
const getList = async () => {
  // 查询前同步当前诊室开展的检查项目,保证只显示本诊室的记录
  syncRoomCheckTypes()
  loading.value = true
  try {
    const data = await JobRecordApi.getJobRecordDoctorPage(queryParams)
@@ -249,30 +510,116 @@
}
const onRowClick = (cur) => {
  if (cur !== null)
    getSelectedRent( cur.rentId )
  if (cur !== null) getSelectedRent(cur.rentId)
}
/**
 * 点击「已完成检查记录」的某一行:只把**该条记录**的信息合入表单。
 *
 * ⚠️ 原实现是 `formData.value = await DevRentApi.getDevRent(rentId)` —— **整个替换**。
 * 而实测 `GET /ecg/dev-rent/get` 的响应里,除 `patName` 外的患者字段**全是 null**:
 *   {"patName":"…","patGender":null,"patBirthday":null,"registerDate":null,"doctor":null,
 *    "patMobile":null,"patPhone":null,"patWardDesc":null,"patBedNo":null,"outpatientNo":null,
 *    "patIdentityId":null,"doctorAdviceNo":null,"tolerance":null}
 * 原因:`dev_rent` 表**不存**这些字段,它们是由 `DevRentServiceImpl` 从 appointment
 * 回填的;而 `/dev-rent/get` 这条路径**没有做回填**。
 *
 * 后果:医生一点记录行,PatientInfoBlock 里除姓名外的信息**全部变成 '-'**,
 * 表现为"患者信息缺失"。
 *
 * 修复:**保留当前患者信息**,只用返回的记录字段覆盖(仅当返回值为非空时)。
 */
const getSelectedRent = async (rentId) => {
  formData.value = await DevRentApi.getDevRent(rentId)
  const record = await DevRentApi.getDevRent(rentId)
  if (!record) return
  const merged = { ...formData.value } as Record<string, any>
  Object.keys(record as Record<string, any>).forEach((k) => {
    const v = (record as Record<string, any>)[k]
    // 只覆盖"确有值"的字段,避免用 null 冲掉已回填好的患者信息
    if (v !== null && v !== undefined && v !== '') {
      merged[k] = v
    }
  })
  // 记录里可能完全没有患者字段,此时保留原患者信息
  if (!merged.patName) merged.patName = formData.value.patName
  formData.value = merged as typeof formData.value
}
const cancelInstall = async () => {
  formData.value.roomId = props.room.roomId
  formData.value.bedNo = props.room.bedNo
  const data = formData.value as unknown as DevRentVO
  if (formData.value.id === null || formData.value.id === undefined) {
    const result = await DevRentApi.routineCheckCancel(data)
    formData.value.id = result
    message.success(t('操作成功'))
  } else {
    await DevRentApi.routineCheckCancel(data)
    message.success(t('操作成功'))
  }
  await DevRentApi.routineCheckCancel(data)
  // 发送操作成功的事件
  emit('event_routine')
  resetForm()
  getList()
  message.success(t('操作成功'))
}
const feeConfirm = async () => {
  if (formData.value.id == null) {
    message.error(t('请先检查'))
    return
  }
  try {
    const result = await DevRentApi.feeConfirm(formData.value.id)
    if (0 == result) {
      //message.success(t('确费操作成功'))
    }
  } catch (err) {
    // 框架 会给出 后台的 错误信息
  }
}
const feeCancel = async () => {
  if (formData.value.id == null) {
    message.error(t('请先检查'))
    return
  }
  try {
    const result = await DevRentApi.feeCancel(formData.value.id)
    if (0 == result) {
      // message.success(t('确费取消成功'))
    }
  } catch (err) {
    // 框架 会给出 后台的 错误信息
  }
}
const getDisplayBarcode = (): string => {
  if (formData.value.checkType == null) return ''
  const displayBarcode: number[] = checkTypeStore.getCheckTypeDispBarCode(formData.value.checkType!)
  if (
    formData.value.patDetails == null ||
    formData.value.patDetails.source == null ||
    !displayBarcode.includes(formData.value.patDetails.source)
  )
    return ''
  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 copyBarcode = async () => {
  displayBarCode.value = getDisplayBarcode()
  await navigator.clipboard.writeText(getBarcode())
}
/** 初始化 **/
@@ -280,5 +627,73 @@
  resetForm()
  getList()
})
</script>
<style scoped lang="scss">
/* ==========================================================================
   需求:表单内容挤占了下方记录表格的空间 —— 压缩行间距。
   Element Plus 默认 `.el-form-item { margin-bottom: 18px }`;
   本页表单含 18 项患者信息(4 列 = 5 行)+ 9 项设备信息,
   仅间距就要上百 px,把 el-table 挤到看不见。
   这里统一压到 4px。注意 :deep 是必需的(el-form-item 是本组件的子组件渲染)。
   ========================================================================== */
.patient-compact-form :deep(.el-form-item) {
  margin-bottom: 4px;
}
/* ==========================================================================
   患者信息固定在内容区顶部。
   内容区自身不滚动(滚动条在记录表格上),因此**不需要 position:sticky** ——
   直接作为 flex 的固定项(flex:none)即可始终留在顶部。
   背景不透明,保证与下方记录表格视觉分离。
   ========================================================================== */
:deep(.doctor-page__content) > .patient-compact-form {
  flex: none;
  padding-bottom: 4px;
  background-color: var(--el-bg-color);
  border-bottom: 1px solid var(--el-border-color-lighter);
}
/* ==========================================================================
   患者信息固定在内容区顶部。
   内容区(.doctor-page__content)自身滚动,所以这里必须用 position:sticky
   才能让 18 项患者信息在记录列表滚动时保持可见。
   背景不透明,避免滚动内容从表单项间隙透出。
   ========================================================================== */
:deep(.doctor-page__content) > .patient-compact-form {
  position: sticky;
  top: 0;
  z-index: 3;
  padding-bottom: 4px;
  background-color: var(--el-bg-color);
  border-bottom: 1px solid var(--el-border-color-lighter);
}
/* ==========================================================================
   患者操作功能块:位于「患者信息」与「已完成记录列表」之间,独立成块。
   需求:各功能按钮(检查完成 / 放弃检查 / 重置 / 知情同意书 …)**排在一行**。
   做法:flex + gap,并 **禁止换行**(flex-wrap:nowrap);
   按钮用 size="small" 以容纳全部按钮;即使宽度不足也不折行。
   上下边框 + 底色,使它与患者信息、记录列表在视觉上分区。
   ========================================================================== */
.patient-actions {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  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);
  /* Element Plus 给相邻 el-button 默认加了 margin-left:12px,会与 gap 叠加,清掉 */
  :deep(.el-button + .el-button) {
    margin-left: 0;
  }
}
</style>