From d553a4be94d4f6ee162cc353a28b220403909cfc Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期六, 03 十月 2026 00:58:19 +0800
Subject: [PATCH] ai优化

---
 src/views/ecg/doctor/components/RoutinePanel.vue |  658 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 538 insertions(+), 120 deletions(-)

diff --git a/src/views/ecg/doctor/components/RoutinePanel.vue b/src/views/ecg/doctor/components/RoutinePanel.vue
index a25b38d..cc50adb 100644
--- a/src/views/ecg/doctor/components/RoutinePanel.vue
+++ b/src/views/ecg/doctor/components/RoutinePanel.vue
@@ -1,75 +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="鎮h�呯紪鍙�" prop="patId">
-            <el-input v-model="formData.patId" placeholder="璇疯緭鍏ユ偅鑰呯紪鍙�" @input="getAppointmentInfoByPatId" />
-          </el-form-item>
-          <el-form-item label="鎮h�呭悕绉�" prop="patName">
-            <el-input v-model="formData.patName" placeholder="璇疯緭鍏ユ偅鑰呭悕绉�" />
-          </el-form-item>
-          <el-form-item label="鎮h�呮弿杩�" 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="鎮h�呯紪鍙�" 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="鎮h�呭鍚�" prop="patName">
+          <el-input v-model="formData.episodeId" placeholder="璇疯緭鍏ユ偅鑰呭鍚�" />
+        </el-form-item>
+      </el-col>        
+    </el-row>
+
+    <!-- ===== 鎮h�呬俊鎭紙闇�姹�1锛�18 椤圭粺涓�灞曠ず锛�**涓�琛屽洓鍒�**锛�=====
+         鍘熷厛鏈潰鏉挎妸 18 椤规墜鍐欏湪澶氳 el-col锛坰pan=6/18 娣锋帓锛夛紝
+         鐜扮粺涓�鏀圭敤 PatientInfoBlock 缁勪欢锛屼笌棰勭害绛惧埌/璁惧棰嗙敤/瑁呮満/鎷嗘満鍚勯〉**鍙e緞涓�鑷�**銆� -->
+    <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" >
-        <template #default="scope">
-          <span v-if="scope.row.jobType === 10">"宸茶鏈�"</span>
-          <span v-if="scope.row.jobType === 35">"宸叉斁寮�"</span>
+  <!--
+    宸插畬鎴愯褰曞垪琛ㄣ��
+    婊氬姩鏂瑰紡锛�**涓棿鍐呭鍖鸿嚜韬粴鍔�**锛�.doctor-page__content 涓� overflow-y:auto锛夛紝
+    鎮h�呬俊鎭敤 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锛堜慨姝o級锛氭妸銆屾挙閿�銆嶆斁鍦�**宸插畬鎴愭鏌ヨ褰曞垪琛ㄧ殑绗竴鍒�**閲屻��
+        鍘熷厛鏀惧湪琛ㄦ牸涓婃柟鐨勭嫭绔嬫寜閽锛屼綅缃笉瀵� 鈥斺�� 鐜版敼涓鸿鍒楃殑**琛ㄥご鎻掓Ы**锛�
+        浣垮叾鎴愪负琛ㄦ牸鐨勭涓�鍒楋紙涓斿彧鍑虹幇涓�娆★紝浣滅敤浜庢渶杩戜竴浣嶅凡瀹屾垚鎮h�咃紝
+        璇箟涓庡悗绔� 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="jobType" />-->
-<!--      <el-table-column label="鍖荤敓缂栧彿" align="center" prop="docId" />-->
+      <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="docName" />
-      <el-table-column label="璁惧缂栧彿" align="center" prop="devId" />
+      <!--      <el-table-column label="璁惧缂栧彿" align="center" prop="devId" />-->
       <el-table-column label="鎮h�呯紪鍙�" align="center" prop="patId" />
       <el-table-column label="鎮h�呭悕绉�" 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
@@ -90,44 +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銆丆ontentWrap銆丳agination 绛夊彲鑷姩寮曞叆锛�
+//    浣� **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
-  getAppointmentInfoByPatId()
+  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 鏂规硶锛岀敤浜庤缃偅鑰�
 
@@ -135,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 () => {
@@ -157,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
   }
@@ -175,50 +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 getAppointmentInfoByPatId = () => {
-  const tempPatId = formData.value.patId;
-  resetForm()
-  if (isStringEmpty(tempPatId))
+const yddownload = async () => {
+  // 妫�鏌� setappointmentId 鏄惁瀛樺湪
+  if (!props.setappointmentId) {
+    message.warning('褰撳墠鏃犲氨璇婁腑鎮h�呰鍏堝彨鍙�')
     return
+  }
 
-  formData.value.patId = tempPatId;
-  getAppointmentInfo()
+  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 getAppointmentInfo = async () => {
-  const appointmentData = await AppointmentApi.getAppointmentByPatId(formData.value.patId)
-  if (null === appointmentData)
+const sgdownload = async () => {
+  // 妫�鏌� setappointmentId 鏄惁瀛樺湪
+  if (!props.setappointmentId) {
+    message.warning('褰撳墠鏃犲氨璇婁腑鎮h�呰鍏堝彨鍙�')
     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瀵硅薄锛屾寚瀹歁IME绫诲瀷涓篧ord鏂囨。[9,10](@ref)
+    // 瀵逛簬Word 2003 XML鏍煎紡锛屼娇鐢�'application/msword'
+    const blob = new Blob([data], { type: 'application/msword' })
+
+    // 3. 涓築lob瀵硅薄鍒涘缓涓�涓复鏃剁殑涓嬭浇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)
+    // 杩欓噷鍙互娣诲姞鏇村弸濂界殑鐢ㄦ埛閿欒鎻愮ず锛屼緥濡備娇鐢╝lert鎴栭〉闈㈠脊绐�
+  }
+}
+const getRentInfoByPatId = () => {
+  const tempPatId = formData.value.patId
+  resetForm()
+  if (isStringEmpty(tempPatId)) return
+
+  formData.value.patId = tempPatId
+  getFreeRentInfo(formData.value)
+  copyBarcode()
+}
+
+const getFreeRentInfo = async (devRentVO) => {
+  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.patName = appointmentData.patName
-  formData.value.patDeptDesc = appointmentData.patDeptDesc
-  formData.value.patWardDesc = appointmentData.patWardDesc
-  formData.value.patBedNo = appointmentData.patBedNo
+  // formData.value = data  //涓嶈兘鏁翠釜璧嬪�硷紝 榛樿棰嗙敤鏃堕棿琚竻绌�
+  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,
@@ -231,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] 骞虫澘杩愬姩蹇冪數锛夛紝
+  // 鍙彿妫�鏌ラ〉浼氭妸**澶氫釜璇婂鐨勮褰曟贩鍦ㄤ竴璧�**鏄剧ず 鈥斺�� 姝f槸鐢ㄦ埛鍙嶉鐨勭幇璞°��
+  //
+  // 鐢卞悇椤甸潰锛圧outine.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)
@@ -246,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` 澶栫殑鎮h�呭瓧娈�**鍏ㄦ槸 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` 杩欐潯璺緞**娌℃湁鍋氬洖濉�**銆�
+ *
+ * 鍚庢灉锛氬尰鐢熶竴鐐硅褰曡锛孭atientInfoBlock 閲岄櫎濮撳悕澶栫殑淇℃伅**鍏ㄩ儴鍙樻垚 '-'**锛�
+ * 琛ㄧ幇涓�"鎮h�呬俊鎭己澶�"銆�
+ *
+ * 淇锛�**淇濈暀褰撳墠鎮h�呬俊鎭�**锛屽彧鐢ㄨ繑鍥炵殑璁板綍瀛楁瑕嗙洊锛堜粎褰撹繑鍥炲�间负闈炵┖鏃讹級銆�
+ */
 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.devInstallCancel(data)
-    formData.value.id = result
-    message.success(t('鎿嶄綔鎴愬姛'))
-  } else {
-    await DevRentApi.devInstallCancel(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())
 }
 
 /** 鍒濆鍖� **/
@@ -277,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;
+}
+
+/* ==========================================================================
+   鎮h�呬俊鎭浐瀹氬湪鍐呭鍖洪《閮ㄣ��
+   鍐呭鍖鸿嚜韬笉婊氬姩锛堟粴鍔ㄦ潯鍦ㄨ褰曡〃鏍间笂锛夛紝鍥犳**涓嶉渶瑕� position:sticky** 鈥斺��
+   鐩存帴浣滀负 flex 鐨勫浐瀹氶」锛坒lex: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);
+}
+
+
+
+/* ==========================================================================
+   鎮h�呬俊鎭浐瀹氬湪鍐呭鍖洪《閮ㄣ��
+   鍐呭鍖猴紙.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);
+}
+
+/* ==========================================================================
+   鎮h�呮搷浣滃姛鑳藉潡锛氫綅浜庛�屾偅鑰呬俊鎭�嶄笌銆屽凡瀹屾垚璁板綍鍒楄〃銆嶄箣闂达紝鐙珛鎴愬潡銆�
+   闇�姹傦細鍚勫姛鑳芥寜閽紙妫�鏌ュ畬鎴� / 鏀惧純妫�鏌� / 閲嶇疆 / 鐭ユ儏鍚屾剰涔� 鈥︼級**鎺掑湪涓�琛�**銆�
+   鍋氭硶锛歠lex + gap锛屽苟 **绂佹鎹㈣**锛坒lex-wrap:nowrap锛夛紱
+   鎸夐挳鐢� size="small" 浠ュ绾冲叏閮ㄦ寜閽紱鍗充娇瀹藉害涓嶈冻涔熶笉鎶樿銆�
+   涓婁笅杈规 + 搴曡壊锛屼娇瀹冧笌鎮h�呬俊鎭�佽褰曞垪琛ㄥ湪瑙嗚涓婂垎鍖恒��
+   ========================================================================== */
+.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>

--
Gitblit v1.9.3