From 09dc74e264b6262cbe41c9c8476e24705871d4a6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期日, 08 十一月 2026 23:31:17 +0800
Subject: [PATCH] yxh

---
 src/views/ecg/doctor/components/RoutinePanel.vue |  971 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 834 insertions(+), 137 deletions(-)

diff --git a/src/views/ecg/doctor/components/RoutinePanel.vue b/src/views/ecg/doctor/components/RoutinePanel.vue
index cc3fcfc..bdeb2b1 100644
--- a/src/views/ecg/doctor/components/RoutinePanel.vue
+++ b/src/views/ecg/doctor/components/RoutinePanel.vue
@@ -1,84 +1,160 @@
 <!-- 甯歌妫�鏌� 鍖荤敓鐣岄潰-->
 <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="getRentInfoByPatId" />
-<!--        <Qrcode v-if="formData.patId !== undefined && formData.patId !== ''" :text="formData.patId" logo="/logo.gif" width=100 />-->
-            <Barcode v-if="displayBarCode" :value="displayBarCode" :width=100 />
-            <el-button @click="copyBarcode()">澶嶅埗</el-button>
-          </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="patDetails">
-            <dict-tag v-if="formData.patSrc" :type="DICT_TYPE.ECG_PAT_SOURCE" :value="formData.patSrc" />
-            {{formData.patDetails?.deptDesc}} {{formData.patDetails?.wardDesc}} {{formData.patDetails?.bedNo}}
-          </el-form-item>
-          <el-form-item label="妫�鏌ユ椂闂�" prop="rentTime">
-            <el-date-picker
-                v-model="formData.rentTime"
-                type="date"
-                value-format="x"
-                placeholder="閫夋嫨瑁呮満鏃堕棿"
+  <el-form class="patient-compact-form" ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading">
+    <!--
+      銆愭湰闇�姹傘�戠揣鎬ュ姞鍋氭搷浣滄彁绀猴紙缂栬緫鍖轰笂鏂癸紝甯搁┗锛�
+      绱ф�ョ梾浜轰笉鎺掗槦锛氬湪涓嬮潰涓変釜杈撳叆妗嗕换涓�涓噷杈撳叆鍚庢寜鍥炶溅锛屾煡鍒伴绾﹁褰曞嵆鍙洿鎺ュ仛妫�鏌ャ��
+    -->
+    <el-alert type="warning" :closable="false" class="emergency-tip">
+      <template #title>
+        <span class="emergency-tip__text">
+          鏈夌揣鎬ョ梾浜烘椂锛岃杈撳叆<span class="emergency-tip__key">鐢宠鍗曞彿</span>銆佹垨<span class="emergency-tip__key">灏辫瘖鍙�</span>銆佹垨<span class="emergency-tip__key">鎮h�呯紪鍙�</span>鍚庢寜<span class="emergency-tip__enter">鍥炶溅閿�</span>锛屾煡鍒扮梾浜洪绾﹁褰曞嵆鍙仛妫�鏌ワ紒锛侊紒
+        </span>
+      </template>
+    </el-alert>
+    <!-- ===== 缂栬緫鍖猴紙闇�瑕佸綍鍏ョ殑瀛楁锛�===== -->
+      <el-row :gutter="4">
+        <el-col :xs="24" :sm="12" :md="12" :lg="6">
+          <el-form-item label="鐢宠鍗曞彿" prop="applyNo">
+            <!-- 銆愭湰闇�姹傦細绱ф�ュ姞鍋氥�戝洖杞﹀嵆鎸夌敵璇峰崟鍙锋煡杩戜竴涓湀鐨勯绾� -->
+            <el-input
+              v-model="formData.applyNo"
+              placeholder="璇疯緭鍏ョ敵璇峰崟鍙�"
+              @keyup.enter="searchEmergencyCandidates('applyNo')"
             />
           </el-form-item>
         </el-col>
-        <el-col :span="12">
+        <el-col :xs="24" :sm="12" :md="12" :lg="6">
           <el-form-item label="妫�鏌ラ」鐩�" prop="">
-            {{formData.checkType && getCheckTypeName(formData.checkType)}}
+            {{ formData?.checkType && getCheckTypeName(formData?.checkType) }}
           </el-form-item>
-          <el-form-item label="澶囨敞" prop="remark">
-            <el-input v-model="formData.remark" placeholder="璇疯緭鍏ュ娉�" />
+        </el-col>
+        <el-col :xs="24" :sm="12" :md="12" :lg="6">
+          <el-form-item label="灏辫瘖鍙�" prop="episodeId">
+            <!-- 銆愭湰闇�姹傦細绱ф�ュ姞鍋氥�戝洖杞﹀嵆鎸夊氨璇婂彿鏌ヨ繎涓�涓湀鐨勯绾� -->
+            <el-input
+              v-model="formData.episodeId"
+              placeholder="璇疯緭鍏ュ氨璇婃祦姘村彿"
+              @keyup.enter="searchEmergencyCandidates('episodeId')"
+            />
+            <!--
+              銆愭湰闇�姹傘�戞潯鐮佷粠銆屾偅鑰呯紪鍙枫�嶆尓鍒拌繖閲岋紙灏辫瘖鍙蜂笅鏂癸級锛�
+                路 鍐呭 = 灏辫瘖鍙凤紱榛樿鏄惁鏄剧ず鐢便�屾鏌ョ被鍨� 鈫� 鏄惁鏄剧ず鏉$爜銆嶉厤缃喅瀹氾紱
+                路 鍖荤敓鍙敤鍒囨崲鎸夐挳鎵嬪姩鏄鹃殣锛堟樉绀轰腑鈫掋�岄殣钘忋�嶏紱闅愯棌涓啋銆屾潯鐮併�嶏級锛�
+                路 銆屽鍒躲�嶅彧鍦ㄦ潯鐮佹樉绀烘椂鍑虹幇銆�
+            -->
+            <div v-if="showBarcodeToggle || showBarCode" class="barcode-row">
+              <Barcode v-if="showBarCode" :value="barcodeContent" :width="100" />
+              <el-button v-if="showBarcodeToggle" size="small" @click="toggleBarcode()">
+                {{ barcodeToggleLabel }}
+              </el-button>
+              <el-button v-if="showCopyButton" size="small" :disabled="!barcodeContent" @click="copyBarcode()">
+                澶嶅埗
+              </el-button>
+            </div>
+          </el-form-item>
+        </el-col>
+        <!-- 銆愭湰闇�姹傘�戞偅鑰呭鍚嶈繖涓�鍒楀凡鍘绘帀锛氫笅鏂� PatientInfoBlock 宸叉湁濮撳悕灞曠ず -->
+        <el-col :xs="24" :sm="12" :md="12" :lg="6">
+          <el-form-item label="鎮h�呯紪鍙�" prop="patId">
+            <!-- 銆愭湰闇�姹傦細绱ф�ュ姞鍋氥�戝洖杞﹀嵆鎸夋偅鑰呯紪鍙锋煡杩戜竴涓湀鐨勯绾� -->
+            <el-input
+              v-model="formData.patId"
+              placeholder="璇疯緭鍏ユ偅鑰呯紪鍙�"
+              @input="getRentInfoByPatId"
+              @keyup.enter="searchEmergencyCandidates('patId')"
+            />
           </el-form-item>
         </el-col>
       </el-row>
-    </el-form>
-    <el-button @click="submitForm" type="primary" :disabled="formLoading">妫�鏌ュ畬鎴�</el-button>
-    <el-button @click="cancelInstall"  :disabled="formLoading">鏀惧純妫�鏌�</el-button>
-    <el-button @click="resetForm()">閲� 缃�</el-button>
-    <el-button v-if="formData.checkType && checkTypeStore.getExpenseRecognition(formData.checkType)" @click="feeConfirm"  :disabled="formLoading">纭垂</el-button>
-    <el-button v-if="formData.checkType && checkTypeStore.getExpenseRecognition(formData.checkType)" @click="feeCancel"  :disabled="formLoading">鍙栨秷纭垂</el-button>
+
+    <!-- ===== 鎮h�呬俊鎭紙闇�姹�1锛�18 椤圭粺涓�灞曠ず锛�**涓�琛屽洓鍒�**锛�=====
+         鍘熷厛鏈潰鏉挎妸 18 椤规墜鍐欏湪澶氳 el-col锛坰pan=6/18 娣锋帓锛夛紝
+         鐜扮粺涓�鏀圭敤 PatientInfoBlock 缁勪欢锛屼笌棰勭害绛惧埌/璁惧棰嗙敤/瑁呮満/鎷嗘満鍚勯〉**鍙e緞涓�鑷�**銆� -->
+    <PatientInfoBlock :data="formData" check-type-field="checkType" :span="6" />
+    <el-row>     
+      <el-col :xs="24" :sm="12" :md="12" :lg="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 :xs="24" :sm="24" :md="12" :lg="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 || formData.id == null">纭垂</el-button>
+  <el-button size="small" v-if="needAutoFeeConfirm(formData.checkType)" @click="feeCancel" :disabled="formLoading || formData.id == null">鍙栨秷纭垂</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锛夛紝
+    鎮h�呬俊鎭敤 sticky 鍥哄畾鍦ㄩ《閮紱搴曢儴 footer 鐢� DoctorPageLayout 鍥哄畾锛屾棤闇�婊氬姩鍗冲彲瑙併��
+    锛堟浘灏濊瘯璁� el-table 鍐呴儴婊氬姩浠ュ浐瀹氳〃澶达紝浣嗘湰椤圭洰 Element Plus 2.7.0 涓�
+       height/maxHeight 鍧囨湭鐢熸晥锛屽凡鍥為��锛岃瑙併�婇儴缃叉竻鍗曘��5.3.15銆傦級
+  -->
+  <!-- 銆愭湰娆¢渶姹傘�戞搷浣滃姛鑳藉尯涓庡凡瀹屾垚璁板綍涔嬮棿鐨勬爣棰樻爮 -->
+  <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">
+      <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="lost">
         <template #default="scope">
-          <span v-if="scope.row.jobType === 60">宸叉鏌�</span>
+          <!-- 銆愭湰闇�姹傘�戝畬鎴愯鎾ら攢杩囷細璇ユ潯璁板綍鏄剧ず銆屽凡鎾ら攢銆嶏紱鍐嶆瀹屾垚鏃跺悗绔� undone 鑷姩鍙樺洖 false -->
+          <el-tag v-if="scope.row.undone" type="danger" size="small">宸叉挙閿�</el-tag>
+          <span v-else-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="鎮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
@@ -99,41 +175,145 @@
           </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>
 
+  <!--
+    銆愭湰闇�姹傦細绱ф�ユ偅鑰呬笉鎺掗槦鐩存帴妫�鏌ャ�戦绾﹂�夋嫨妗�
+    瑙﹀彂锛氬湪銆岀敵璇峰崟鍙� / 灏辫瘖鍙� / 鎮h�呯紪鍙枫�嶄换涓�杈撳叆妗嗗唴鎸夊洖杞︺��
+    澶氭潯棰勭害鏃跺脊姝ゆ锛屾寜棰勭害鏃堕棿鍊掑簭锛堟渶杩戠殑鍦ㄥ墠锛夈��
+  -->
+  <Dialog v-model="emergencyVisible" title="閫夋嫨棰勭害璁板綍锛堢揣鎬ュ姞鍋氾級" width="880px" append-to-body>
+    <el-alert type="warning" :closable="false" class="mb-10px">
+      <template #title>
+        <span class="text-13px">
+          鎵惧埌 {{ emergencyList.length }} 鏉¢绾﹁褰曪細**鐐归�変竴琛�**锛堟暣琛岄珮浜� + 宸︿晶钃濇潯 + 銆屽凡閫夈�嶆爣绛撅級鍚庣偣銆岄�夋嫨骞舵鏌ャ�嶏紝
+          涔熷彲鐩存帴**鍙屽嚮**璇ヨ銆傞�変腑鍚庡彲鐩存帴妫�鏌ワ紝瀹屾垚鍚庡悓鏍疯繘鍏ャ�屽凡瀹屾垚鍒楄〃銆嶏紙涓嶆帓闃熴�佷笉鍗犲彿锛夈��
+        </span>
+      </template>
+    </el-alert>
+    <el-table
+      ref="emergencyTableRef"
+      class="emergency-table"
+      :data="emergencyList"
+      v-loading="emergencyLoading"
+      highlight-current-row
+      border
+      max-height="360px"
+      :row-class-name="emergencyRowClass"
+      @row-click="(row) => (emergencySelected = row)"
+      @current-change="(row) => (emergencySelected = row)"
+      @row-dblclick="(row) => confirmEmergency(row)"
+    >
+      <!-- 銆愭湰闇�姹傘�戦�変腑鏍囪瘑鍒楋細閫変腑琛屾樉绀恒�屸湏 宸查�夈�嶏紝閬垮厤鍙潬鑳屾櫙鑹插垎杈ㄤ笉娓� -->
+      <el-table-column label="閫夋嫨" width="80" align="center" fixed="left">
+        <template #default="scope">
+          <el-tag v-if="isEmergencySelected(scope.row)" type="primary" effect="dark" size="small">
+            鉁� 宸查��
+          </el-tag>
+          <span v-else class="text-gray-400">鈥�</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="棰勭害鏃ユ湡" align="center" prop="bookDate" width="120">
+        <template #default="scope">{{ formatDate(scope.row.bookDate, 'YYYY-MM-DD') }}</template>
+      </el-table-column>
+      <el-table-column label="鏃舵" align="center" width="120">
+        <template #default="scope">{{ formatTimeslot(scope.row.bookTimeslot) }}</template>
+      </el-table-column>
+      <el-table-column label="妫�鏌ラ」鐩�" align="center" min-width="130">
+        <template #default="scope">{{ getCheckTypeName(scope.row.bookCheckType) }}</template>
+      </el-table-column>
+      <el-table-column label="鎮h�呭悕绉�" align="center" prop="patName" min-width="100" />
+      <el-table-column label="鎮h�呯紪鍙�" align="center" prop="patId" min-width="110" />
+      <el-table-column label="鐢宠鍗曞彿" align="center" prop="applyNo" min-width="130" />
+      <el-table-column label="鐘舵��" align="center" width="90">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.ECG_STATUS" :value="scope.row.status" />
+        </template>
+      </el-table-column>
+    </el-table>
+    <template #footer>
+      <!-- 搴曢儴鍥炴樉宸查�夊摢涓�鏉★紝閬垮厤閫夐敊 -->
+      <span v-if="emergencySelected" class="emergency-selected-hint">
+        宸查�夛細{{ formatDate(emergencySelected.bookDate, 'YYYY-MM-DD') }}
+        {{ formatTimeslot(emergencySelected.bookTimeslot) }}
+        {{ getCheckTypeName(emergencySelected.bookCheckType) }}
+        <span class="text-gray-500">锛坽{ emergencySelected.patName }}锛�</span>
+      </span>
+      <el-button @click="emergencyVisible = false">鍙� 娑�</el-button>
+      <el-button type="primary" :disabled="!emergencySelected" @click="confirmEmergency()">
+        閫夋嫨骞舵鏌�
+      </el-button>
+    </template>
+  </Dialog>
 </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 {QueueVO} from "@/api/ecg/queue";
-import {RoomBedVO} from "@/api/ecg/doctor";
-import {Barcode} from "@/components/Barcode";
-import {useCheckTypeStore} from "@/store/modules/checkType";
-import {DICT_TYPE} from "@/utils/dict";
+import { dateFormatter, formatDate } from '@/utils/formatTime'
+import { formatTimeslot } from '@/utils/formatter'
+import { AppointmentApi, AppointmentVO } from '@/api/ecg/appointment'
+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()
 
@@ -144,44 +324,197 @@
   formData.value.patId = queueVO?.patId
   formData.value.patName = queueVO?.patName
   formData.value.checkType = queueVO?.bookCheckType
-  formData.value.patSrc = queueVO?.patDetails.source
+  // 浠ヤ笅瀛楁鐢卞悗绔粠棰勭害鍗曡ˉ榻愶紙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
+  // 銆愭湰娆′慨澶嶃�戞潯鐮�/鎵撳嵃灏忕エ渚濊禆 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
+  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 鏂规硶锛岀敤浜庤缃偅鑰�
+defineExpose({ setPatient, getList: () => getList() }) // 鎻愪緵 setPatient 鏂规硶锛岀敤浜庤缃偅鑰�
 
 const { t } = useI18n() // 鍥介檯鍖�
 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,
-  interference: undefined,
-  baseline: undefined,
-  detachment: undefined,
+  tolerance: undefined,
+  patBirthday: undefined,
+  registerDate: undefined,
+  doctor: undefined,
+  doctorTime: undefined,
   remark: undefined,
-  paid: undefined,
-  roomId: props.room.roomId,
-  bedNo: props.room.bedNo
+  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> ()
+
+// =====================================================================================
+// 銆愭湰闇�姹傦細绱ф�ユ偅鑰呬笉鎺掗槦鐩存帴妫�鏌ャ��
+//   鍦ㄣ�岀敵璇峰崟鍙� / 灏辫瘖鍙� / 鎮h�呯紪鍙枫�嶄换涓�杈撳叆妗嗗洖杞� 鈫� 鏌ヨ繎涓�涓湀銆佹湰绐楀彛妫�鏌ラ」鐩殑棰勭害璁板綍
+//   鈫� 1 鏉$洿鎺ヨ鍏ワ紱澶氭潯寮归�夋嫨妗嗭紙鎸夐绾︽椂闂村�掑簭锛夆啋 璇诲叆鍚庡彲鐩存帴銆屾鏌ュ畬鎴愩��
+//   鈫� 鍚庣鍦�"浠婂ぉ娌℃湁寰呮鏌ュ崟"鏃舵寜棰勭害鍗曡ˉ寤猴紝浠庤�屽儚鎺掗槦鎮h�呬竴鏍疯繘鍏ャ�屽凡瀹屾垚鍒楄〃銆�
+// =====================================================================================
+const emergencyMode = ref(false) // 褰撳墠琛ㄥ崟鏄惁鏉ヨ嚜"绱ф�ュ姞鍋�"
+const emergencyVisible = ref(false) // 閫夋嫨妗�
+const emergencyLoading = ref(false)
+const emergencyList = ref<AppointmentVO[]>([])
+const emergencySelected = ref<AppointmentVO | undefined>()
+/** 閫夋嫨琛ㄦ牸寮曠敤锛堜繚鐣欙細鍚庣画濡傞渶 scrollToRow 绛夎兘鍔涘彲鐢級 */
+const emergencyTableRef = ref<any>()
+
+/** 閫変腑鍒ゆ柇锛堟ā鏉块噷鐢紝閬垮厤鐩存帴姣旇緝瀵硅薄寮曠敤锛� */
+const isEmergencySelected = (row: AppointmentVO) =>
+  null != emergencySelected.value && emergencySelected.value.id === row?.id
+
+/** 閫変腑琛屽姞 is-selected 绫伙紝閰嶅悎涓嬫柟鏍峰紡鍋氥�屾暣琛岄珮浜� + 宸︿晶钃濇潯 + 鍔犵矖銆� */
+const emergencyRowClass = ({ row }: { row: AppointmentVO }) =>
+  isEmergencySelected(row) ? 'is-selected' : ''
+
+/** 鏈獥鍙o紙璇婂锛夊紑灞曠殑妫�鏌ラ」鐩紝鐢ㄤ簬杩囨护鍊欓�夐绾︼紱涓虹┖琛ㄧず涓嶉檺鍒� */
+const currentWindowCheckTypes = (): number[] | undefined => {
+  const fromProp = props.room?.checkTypes
+  const types =
+    Array.isArray(fromProp) && fromProp.length > 0 ? fromProp : (roomStore.room?.checkTypes as number[] | undefined)
+  return Array.isArray(types) && types.length > 0 ? [...types] : undefined
+}
+
+/** 鍥炶溅锛氭寜杈撳叆妗嗛噷鐨勫�兼煡棰勭害鍊欓�� */
+const searchEmergencyCandidates = async (field: 'applyNo' | 'episodeId' | 'patId') => {
+  const code = String((formData.value as Record<string, any>)[field] ?? '').trim()
+  if (!code) return
+  emergencyLoading.value = true
+  try {
+    const list = (await AppointmentApi.getEmergencyCandidates(code, currentWindowCheckTypes())) as AppointmentVO[]
+    const rows = Array.isArray(list) ? list : []
+    if (rows.length === 0) {
+      message.warning('杩戜竴涓湀鍐呮病鏈夋壘鍒版湰绐楀彛妫�鏌ラ」鐩殑棰勭害璁板綍')
+      return
+    }
+    if (rows.length === 1) {
+      applyAppointment(rows[0])
+      message.success('宸茶鍏ラ绾﹁褰曪紝鍙洿鎺ョ偣銆屾鏌ュ畬鎴愩��')
+      return
+    }
+    emergencyList.value = rows
+    emergencySelected.value = undefined
+    emergencyVisible.value = true
+  } finally {
+    emergencyLoading.value = false
+  }
+}
+
+/** 閫夋嫨妗嗙‘璁わ紙涔熸敮鎸佸弻鍑昏鐩存帴纭锛� */
+const confirmEmergency = (row?: AppointmentVO) => {
+  const target = row ?? emergencySelected.value
+  if (!target) return
+  applyAppointment(target)
+  emergencyVisible.value = false
+}
+
+/**
+ * 鎶婇绾﹀崟璇诲叆琛ㄥ崟銆�
+ * 娉ㄦ剰锛氳繖閲屾槸"绱ф�ュ姞鍋�"锛�**涓嶆帓闃�**鈥斺�斾笉寤� queue 琛屻�佷笉鍙栧彿锛�
+ * 銆屾鏌ュ畬鎴愩�嶆椂鐢卞悗绔寜闇�琛ュ缓銆屽緟妫�鏌ャ�嶆鏌ュ崟锛堣 DevRentServiceImpl#prepareEmergencyDevRent锛夈��
+ */
+const applyAppointment = (appt: AppointmentVO) => {
+  resetForm()
+  emergencyMode.value = true
+  formData.value.applyNo = appt.applyNo
+  formData.value.episodeId = appt.episodeId
+  formData.value.patId = appt.patId
+  formData.value.patName = appt.patName
+  formData.value.checkType = appt.bookCheckType
+  formData.value.patGender = appt.patGender
+  formData.value.patBirthday = appt.patBirthday
+  formData.value.patSrc = appt.patSrc
+  formData.value.tolerance = appt.tolerance
+  formData.value.doctor = appt.doctor
+  formData.value.doctorTime = appt.doctorTime
+  formData.value.registerDate = appt.registerDate
+  formData.value.paid = appt.paid
+  formData.value.doctorAdviceNo = appt.doctorAdviceNo
+  formData.value.patMobile = appt.patMobile
+  formData.value.patPhone = appt.patPhone
+  formData.value.patIdentityId = appt.patIdentityId
+  formData.value.outpatientNo = appt.outpatientNo
+  formData.value.patWardDesc = appt.patWardDesc
+  formData.value.patBedNo = appt.patBedNo
+  formData.value.medicalCard = appt.medicalCard
+  // 鏉$爜/鎵撳嵃灏忕エ渚濊禆 patDetails.source
+  formData.value.patDetails = {
+    source: appt.patSrc,
+    appointmentId: appt.id
+  } as unknown as typeof formData.value.patDetails
+  message.success('宸茶鍏ラ绾﹁褰曪紝鍙洿鎺ョ偣銆屾鏌ュ畬鎴愩��')
+}
 
 /** 鎻愪氦琛ㄥ崟 */
 const submitForm = async () => {
@@ -192,14 +525,24 @@
   try {
     formData.value.roomId = props.room.roomId
     formData.value.bedNo = props.room.bedNo
-    const data = formData.value as unknown as DevRentVO
-    await DevRentApi.routineFinish(data)
+    // 銆愭湰闇�姹傦細绱ф�ユ偅鑰呬笉鎺掗槦鐩存帴妫�鏌ャ�戝甫涓�"绱ф�ュ姞鍋�"鏍囪锛�
+    //   鍚庣鎹鍦ㄣ�屼粖澶╂病鏈夊緟妫�鏌ュ崟銆嶆椂鎸夐绾﹀崟琛ュ缓涓�琛岋紝浠庤�岃兘姝e父瀹屾垚骞跺啓鍏ャ�屽凡瀹屾垚鍒楄〃銆�
+    const data = formData.value as unknown as DevRentVO & { emergency?: boolean }
+    data.emergency = emergencyMode.value
+    // 鍚庣 routine-finish 宸茶繑鍥炴湰娆″畬鎴愮殑妫�鏌ュ崟 id锛堢揣鎬ュ姞鍋氭椂鏄湇鍔$鏂板缓鐨勯偅鏉★級
+    const rentId = (await DevRentApi.routineFinish(data)) as unknown as number | string | undefined
+
+    // 鑷姩纭垂锛氱敤杩斿洖鐨� rentId锛涙棤 id 鏃堕潤榛樿烦杩囷紙涓嶅啀寮广�岃鍏堟鏌ャ�嶏級
+    if (needAutoFeeConfirm(formData.value.checkType)) {
+      feeConfirm(rentId)
+    }
+
     message.success(t('鎿嶄綔鎴愬姛'))
     dialogVisible.value = false
     // 鍙戦�佹搷浣滄垚鍔熺殑浜嬩欢
     emit('event_routine')
     resetForm()
-    getList()  // 鍖荤敓浣滀笟鍘嗗彶
+    getList() // 鍖荤敓浣滀笟鍘嗗彶
   } finally {
     formLoading.value = false
   }
@@ -212,49 +555,134 @@
     devId: undefined,
     patId: undefined,
     patName: 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,
     patDetails: undefined,
     paid: undefined,
+    doctorAdviceNo: undefined,
     roomId: props.room.roomId,
     bedNo: props.room.bedNo
   }
+  // 銆愭湰闇�姹傘�戞崲鎮h��/閲嶇疆鏃讹細鏉$爜鏄鹃殣鍥炲埌"璺熼殢閰嶇疆榛樿"锛岀揣鎬ュ姞鍋氭爣璁版竻绌�
+  barcodeVisible.value = null
+  emergencyMode.value = false
   formRef.value?.resetFields()
 }
-
-const getRentInfoByPatId = () => {
-  const tempPatId = formData.value.patId;
-  resetForm()
-  if (isStringEmpty(tempPatId))
+const yddownload = async () => {
+  // 妫�鏌� setappointmentId 鏄惁瀛樺湪
+  if (!props.setappointmentId) {
+    message.warning('褰撳墠鏃犲氨璇婁腑鎮h�呰鍏堝彨鍙�')
     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('褰撳墠鏃犲氨璇婁腑鎮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) => {
-  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;  //rent id
-  formData.value.applyNo = data.applyNo;
-  formData.value.episodeId = data.episodeId;
+  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,
@@ -267,10 +695,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)
@@ -282,12 +737,39 @@
 }
 
 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 () => {
@@ -304,44 +786,96 @@
   message.success(t('鎿嶄綔鎴愬姛'))
 }
 
-const feeConfirm = async () => {
-  const result = await DevRentApi.feeConfirm(formData.value.id)
-  if (0 == result)
-    message.success(t('鎿嶄綔鎴愬姛'))
+/**
+ * 纭垂銆�
+ * @param rentId 鏈妫�鏌ュ畬鎴愯繑鍥炵殑妫�鏌ュ崟 id锛涗笉浼犲垯鐢ㄨ〃鍗曢噷鐨� id銆�
+ * 銆愭湰娆′慨澶嶃�戝師瀹炵幇鍦� id 涓虹┖鏃跺脊銆岃鍏堟鏌ャ�嶁�斺�� 绱ф�ュ姞鍋氭偅鑰呮病鏈� id锛岀偣銆屾鏌ュ畬鎴愩�嶄細鍏堝脊杩欎釜閿欙紝
+ * 鍐嶅脊銆屾搷浣滄垚鍔熴�嶏紝璁╀汉璇互涓烘搷浣滃け璐ャ�傜幇鍦ㄦ敼涓洪潤榛樿烦杩囷紙鎸夐挳鏈韩涔熶細鍦ㄦ棤 id 鏃剁鐢級銆�
+ */
+const feeConfirm = async (rentId?: number | string | null) => {
+  const id = rentId ?? formData.value.id
+  if (id == null || id === '') {
+    console.warn('[feeConfirm] 鏃犳鏌ュ崟 id锛岃烦杩囩‘璐�')
+    return
+  }
+
+  try {
+    const result = await DevRentApi.feeConfirm(id as number)
+    if (0 == result) {
+      //message.success(t('纭垂鎿嶄綔鎴愬姛'))
+    }
+  } catch (err) {
+    // 妗嗘灦 浼氱粰鍑� 鍚庡彴鐨� 閿欒淇℃伅
+  }
 }
 
 const feeCancel = async () => {
-  const result = await DevRentApi.feeCancel(formData.value.id)
-  if (0 == result)
-    message.success(t('鎿嶄綔鎴愬姛'))
+  // 銆愭湰娆′慨澶嶃�戞棤妫�鏌ュ崟 id 鏃堕潤榛樿烦杩囷紙鎸夐挳宸茬鐢級锛屼笉鍐嶅脊銆岃鍏堟鏌ャ��
+  if (formData.value.id == null || formData.value.id === '') {
+    console.warn('[feeCancel] 鏃犳鏌ュ崟 id锛岃烦杩囧彇娑堢‘璐�')
+    return
+  }
+
+  try {
+    const result = await DevRentApi.feeCancel(formData.value.id)
+    if (0 == result) {
+      // message.success(t('纭垂鍙栨秷鎴愬姛'))
+    }
+  } catch (err) {
+    // 妗嗘灦 浼氱粰鍑� 鍚庡彴鐨� 閿欒淇℃伅
+  }
 }
+/**
+ * 銆愭湰闇�姹傘�戞偅鑰呮潯鐮侊細浣嶇疆鍦ㄣ�屽氨璇婂彿銆嶄笅鏂癸紝鍐呭 = 灏辫瘖鍙凤紙episodeId锛夛紝鍙樉闅�
+ *
+ *  路 榛樿鍙鎬� = 銆屾鏌ョ被鍨� 鈫� 鏄惁鏄剧ず鏉$爜銆嶉厤缃噷**鍖呭惈璇ユ偅鑰呮潵婧�**
+ *      - 宸插嬀閫夎鏉ユ簮 鈫� 榛樿鏄剧ず
+ *      - 鏈厤缃� / 閰嶇疆閲屾病鏈夎鏉ユ簮 鈫� 榛樿涓嶆樉绀猴紙渚嬪浣忛櫌(3)閫氬父涓嶄細鍕鹃�夛級
+ *  路 鍖荤敓鍙敤鎸夐挳鎵嬪姩瑕嗙洊榛樿锛氭樉绀轰腑 鈫� 銆岄殣钘忋�嶏紱闅愯棌涓� 鈫� 銆屾潯鐮併��
+ *  路 銆屽鍒躲�嶆寜閽彧鍦ㄦ潯鐮佹樉绀烘椂鍑虹幇
+ */
+const barcodeVisible = ref<boolean | null>(null) // null = 鏈墜鍔ㄦ搷浣滐紝璺熼殢閰嶇疆榛樿
 
-const getDisplayBarcode = (): string => {
-  if (!formData.value.checkType)
-    return ""
+const patSourceValue = computed<number | null>(() => {
+  const source = formData.value.patDetails?.source ?? formData.value.patSrc
+  return source === null || source === undefined || source === '' ? null : Number(source)
+})
 
-  const displayBarcode: number[] = checkTypeStore.getCheckTypeDispBarCode(formData.value.checkType!)
-  if (!displayBarcode.includes( formData.value.patSrc ))
-    return ""
+/** 閰嶇疆鍙e緞锛氳妫�鏌ョ被鍨嬬殑銆屾樉绀烘潯鐮併�嶆槸鍚﹀寘鍚綋鍓嶆偅鑰呮潵婧� */
+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)
+})
 
-  return getBarcode()
-}
+/** 鏉$爜 / 澶嶅埗鐨勫唴瀹癸細缁熶竴鍙栥�屽氨璇婂彿銆� */
+const barcodeContent = computed<string>(() => formData.value.episodeId ?? '')
 
-const getBarcode = (): string => {
-  if (!formData.value.checkType)
-    return ""
+/** 瀹為檯鏄惁鏄剧ず锛氭墜鍔ㄨ鐩栦紭鍏堬紝鍚﹀垯璺熼厤缃粯璁� */
+const barcodeVisibleEffective = computed<boolean>(() => barcodeVisible.value ?? barcodeEnabled.value)
 
-  if (1 === formData.value.patSrc || 2 === formData.value.patSrc)
-    return formData.value.applyNo??""
-  else if (3 === formData.value.patSrc || 4 === formData.value.patSrc)
-    return formData.value.episodeId??""
+/** 鏉$爜锛氬彲瑙佷笖鍐呭闈炵┖鎵嶆覆鏌� */
+const showBarCode = computed<boolean>(() => barcodeVisibleEffective.value && barcodeContent.value !== '')
 
-  return ""
+/** 銆屽鍒躲�嶆寜閽細鍙湪鏉$爜鏄剧ず鏃跺嚭鐜� */
+const showCopyButton = computed<boolean>(() => showBarCode.value)
+
+/** 鍒囨崲鎸夐挳锛氬彧瑕佹湁灏辫瘖鍙峰氨缁欙紙涓嶅彈閰嶇疆闄愬埗锛岄厤缃彧绠�"榛樿鏄惁鏄剧ず"锛� */
+const showBarcodeToggle = computed<boolean>(() => barcodeContent.value !== '')
+
+/** 鍒囨崲鎸夐挳鏂囨锛氭樉绀轰腑 鈫� 闅愯棌锛涢殣钘忎腑 鈫� 鏉$爜 */
+const barcodeToggleLabel = computed<string>(() => (showBarCode.value ? '闅愯棌' : '鏉$爜'))
+
+const toggleBarcode = () => {
+  barcodeVisible.value = !barcodeVisibleEffective.value
 }
 
 const copyBarcode = async () => {
-  displayBarCode.value = getDisplayBarcode()
-  await navigator.clipboard.writeText( getBarcode() );
+  if (!barcodeContent.value) return
+  await navigator.clipboard.writeText(barcodeContent.value)
 }
 
 /** 鍒濆鍖� **/
@@ -349,5 +883,168 @@
   resetForm()
   getList()
 })
-
 </script>
+
+<style scoped lang="scss">
+
+/* 銆愭湰娆¢渶姹傘�戙�屽凡瀹屾垚鍒楄〃銆嶆爣棰樻爮锛氬乏渚т富鑹茬珫绾� + 鍔犵矖灏忔爣棰橈紝绱у噾楂樺害涓嶆尋鍘嬭〃鏍� */
+/* 銆愭湰闇�姹傘�戠紪杈戝尯涓婃柟鐨勩�岀揣鎬ュ姞鍋氥�嶆搷浣滄彁绀猴細涓�琛屾樉绀恒�侀啋鐩絾涓嶅崰楂樺害 */
+.emergency-tip {
+  padding: 4px 10px;
+  margin-bottom: 6px;
+
+  :deep(.el-alert__title) {
+    padding: 0;
+    font-size: 13px;
+    line-height: 20px;
+  }
+
+  &__text {
+    color: var(--el-color-warning-dark-2);
+  }
+
+  /* 鍏抽敭瀛楁/鎸夐敭鍋氬己璋冿紝鏂逛究涓�鐪肩湅鎳傝杈撲粈涔堛�佹寜浠�涔� */
+  &__key {
+    font-weight: 600;
+    color: var(--el-color-danger);
+  }
+
+  &__enter {
+    padding: 0 4px;
+    margin: 0 2px;
+    border: 1px solid var(--el-color-danger);
+    border-radius: 3px;
+    font-weight: 600;
+    color: var(--el-color-danger);
+    background-color: var(--el-color-danger-light-9);
+  }
+}
+/* 銆愭湰闇�姹傘�戠揣鎬ュ姞鍋氾細棰勭害閫夋嫨妗嗙殑銆岄�変腑琛屻�嶈瓒冲鏄庢樉
+   锛堝師鏉ュ彧鏈夐粯璁ょ殑娴呰壊 current-row 鑳屾櫙锛岀幇鍦哄弽棣�"鍙槸鍙樻繁涓�鐐癸紝鐪嬩笉娓�"锛� */
+.emergency-table {
+  :deep(.el-table__row) {
+    cursor: pointer;
+  }
+  :deep(.el-table__row:hover > td) {
+    background-color: var(--el-color-primary-light-9) !important;
+  }
+  /* 閫変腑琛岋細涓昏壊鑳屾櫙 + 鍔犵矖 + 宸︿晶 4px 涓昏壊鏉� */
+  :deep(.el-table__row.is-selected > td) {
+    background-color: var(--el-color-primary-light-6) !important;
+    color: var(--el-color-primary-dark-2);
+    font-weight: 600;
+  }
+  :deep(.el-table__row.is-selected > td:first-child) {
+    box-shadow: inset 4px 0 0 var(--el-color-primary);
+  }
+}
+
+/* 閫夋嫨妗嗗簳閮ㄣ�屽凡閫夈�嶅洖鏄� */
+.emergency-selected-hint {
+  float: left;
+  line-height: 32px;
+  font-size: 13px;
+  color: var(--el-color-primary);
+  font-weight: 600;
+}
+/* 銆愭湰闇�姹傘�戝氨璇婂彿涓嬫柟鐨勬潯鐮佽锛氭潯鐮� + [闅愯棌|鏉$爜] + [澶嶅埗] 鍚屼竴琛岋紝绱у噾涓嶆拺楂� */
+.barcode-row {
+  display: flex;
+  align-items: center;
+  gap: 6px;
+  margin-top: 4px;
+  flex-wrap: wrap;
+}
+.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: 14px;
+    font-weight: 600;
+    color: var(--el-text-color-primary);
+  }
+}
+/* ==========================================================================
+   闇�姹傦細琛ㄥ崟鍐呭鎸ゅ崰浜嗕笅鏂硅褰曡〃鏍肩殑绌洪棿 鈥斺�� 鍘嬬缉琛岄棿璺濄��
+   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;
+  /* 鎸夐挳澶氭椂鍏佽鎹㈣锛岄伩鍏嶆尋鍦ㄤ竴琛岋紙妫�鏌ラ〉鏈�澶� 6 涓寜閽級 */
+  flex-wrap: wrap;
+  gap: 8px;
+  align-items: center;
+  /*
+    銆愭湰娆¢渶姹傘�戞搷浣滃姛鑳藉尯鍋氫竴鐐硅瑙夊尯鍒嗭紝鏂逛究鍖荤敓涓�鐪煎畾浣嶏細
+    鏋佹祬鐨勪富鑹插簳 + 缁嗚竟妗� + 宸︿晶 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;
+  }
+}
+</style>

--
Gitblit v1.9.3