From be27214928a43cacff975265a7c67e2e2461fd0c Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期六, 28 十一月 2026 19:39:01 +0800
Subject: [PATCH] 打印小票

---
 src/views/ecg/doctor/components/DevReadyPanel.vue |  273 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 247 insertions(+), 26 deletions(-)

diff --git a/src/views/ecg/doctor/components/DevReadyPanel.vue b/src/views/ecg/doctor/components/DevReadyPanel.vue
index 07a620e..654e3a2 100644
--- a/src/views/ecg/doctor/components/DevReadyPanel.vue
+++ b/src/views/ecg/doctor/components/DevReadyPanel.vue
@@ -28,7 +28,7 @@
         </el-col>
         <el-col :xs="24" :sm="12" :md="12" :lg="6">
           <el-form-item label="璁惧缂栧彿" prop="devId">
-            <el-input v-model="formData.devId" placeholder="璇疯緭鍏ヨ澶囩紪鍙�" @input="getDevInfo"/>
+            <el-input v-model="formData.devId" :placeholder="requireDevId ? '璇疯緭鍏ヨ澶囩紪鍙�' : '鍙暀绌�'" @input="getDevInfo"/>
           </el-form-item>
         </el-col>
       </el-row>
@@ -81,11 +81,14 @@
   </div>
   <div class="records-host">
     <ContentWrap class="records-wrap">
+    <div class="records-scroll">
     <el-table
       v-loading="loading"
       :data="list"
       :stripe="true"
       :show-overflow-tooltip="true"
+      highlight-current-row
+      @current-change="onCurrentRowChange"
       @row-click="onRowClick"
     >
       <!-- 闇�姹�11锛堜慨姝o級锛氥�屾挙閿�銆嶄綔涓�**宸插畬鎴愰鐢ㄨ褰曞垪琛ㄧ殑绗竴鍒�**锛堣〃澶存彃妲斤級锛�
@@ -97,7 +100,8 @@
             type="warning"
             :disabled="undoDisabled"
             :loading="undoLoading"
-            @click="$emit('event_undo_finish')"
+            title="鍏堝湪涓嬫柟鐐归�変竴鏉″畬鎴愯褰曪紝鍐嶇偣姝ゆ挙閿�"
+            @click="undoSelected"
           >
             鎾ら攢
           </el-button>
@@ -115,6 +119,10 @@
           <span v-else-if="scope.row.jobType === 5">"宸查鐢�"</span>
           <span v-if="scope.row.jobType === 30">"宸叉斁寮�"</span>
         </template>
+      </el-table-column>
+      <!-- 銆�2026-11-25 闇�姹傘�戝悓涓�鎮h�呭彲鑳芥湁澶氫釜妫�鏌ラ」鐩紝宸插畬鎴愬垪琛ㄥ垪鍑烘潵鎵嶈兘鍖哄垎/绮剧‘鎾ら攢 -->
+      <el-table-column label="妫�鏌ラ」鐩�" align="center" width="150">
+        <template #default="scope">{{ getCheckTypeName(scope.row.checkType) }}</template>
       </el-table-column>
 <!--      <el-table-column label="浣滀笟绫诲瀷" align="center" prop="jobType" />-->
 <!--      <el-table-column label="鍖荤敓缂栧彿" align="center" prop="docId" />-->
@@ -162,6 +170,7 @@
       </el-table-column>
 -->
     </el-table>
+    </div>
     </ContentWrap>
     <!-- 鍒嗛〉 -->
     <Pagination
@@ -191,6 +200,8 @@
 import {calGender, getBookBeginTime} from "@/utils";
 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
 import {tranlateDevState} from "@/utils/statusFormatter";
+import { copyText } from '@/utils/copyText'
+import { getConfigKey } from '@/api/infra/config'
 import {getCheckTypeName, needAutoFeeConfirm, needDevReady} from "../../../../utils/checkTypeFormatter";
 import { useRoomStore } from '@/store/modules/room'
 // 闇�姹�1锛氭偅鑰呬俊鎭� 18 椤圭粺涓�灞曠ず鍧�
@@ -249,6 +260,29 @@
   patId: [{ required: true, message: '鐩墠娌℃湁鎮h��', trigger: 'blur' }],
   patName: [{ required: true, message: '鐩墠娌℃湁鎮h��', trigger: 'blur' }]
 })
+
+/**
+ * 銆愮郴缁熷弬鏁般�戝姩鎬佽鍘嬪拰蹇冪數璁惧棰嗙敤瀹夎鐧昏璁惧缂栧彿
+ *   鍊尖�滄槸鈥濓紙榛樿锛夆啋 璁惧缂栧彿蹇呭~锛�
+ *   鍊尖�滃惁鈥�       鈫� 鍏佽涓嶅~锛堟牎楠岃鍒欏悓姝ユ斁寮�锛夈��
+ */
+const requireDevId = ref(true)
+const loadDevIdRequired = async () => {
+  try {
+    const value = await getConfigKey('ecg.dev.rent.device.no.required')
+    const text = String(value ?? '').trim()
+    requireDevId.value = !(
+      text === '鍚�' || text === '0' ||
+      text.toLowerCase() === 'false' || text.toLowerCase() === 'no'
+    )
+  } catch (e) {
+    console.warn('[DevReadyPanel] 璇诲彇鈥滆澶囩紪鍙峰繀濉�濈郴缁熷弬鏁板け璐ワ紝鎸夊繀濉鐞�', e)
+    requireDevId.value = true
+  }
+  formRules.devId = requireDevId.value
+    ? [{ required: true, message: '璁惧缂栧彿涓嶈兘涓虹┖', trigger: 'blur' }]
+    : []
+}
 const formRef = ref() // 琛ㄥ崟 Ref
 
 const devInfo = ref<Partial<DeviceVO>>({
@@ -314,7 +348,7 @@
       `銆�${ctName}銆嶄笉闇�瑕佽澶囬鐢紝涓嶈兘鍦ㄨ澶囬鐢ㄦā鍧楀姙鐞嗐�俙 +
       `璇风‘璁ゆ槸鍚﹀簲鍒般�屽彨鍙锋鏌ャ�嶉〉闈㈠鐞嗚鎮h�呫�俙
     )
-    return
+    return false
   }
 
   // 鏍¢獙琛ㄥ崟
@@ -327,7 +361,12 @@
     await DevRentApi.devReady(formData.value)
 
     if (autoPrint.value && formData.value.patId && formData.value.checkType) {
-      printBill(formData.value.patDetails?.appointmentId)
+      const apptId = formData.value.patDetails?.appointmentId
+      // 銆愭湰娆′慨澶嶃�戣嚜鍔ㄦ墦鍗版椂鑻ユ病鏈夐绾﹀崟鍙峰氨**闈欓粯璺宠繃**锛�
+      // 鎵嬪姩鐐广�屾墦鍗板皬绁ㄣ�嶄細缁欏嚭"鏃犻绾﹀崟"鐨勬彁绀猴紝浣嗛鐢ㄥ畬鎴愬悗鐨勮嚜鍔ㄦ墦鍗颁笉璇ュ脊璀﹀憡鎵撴柇娴佺▼銆�
+      if (apptId != null) {
+        printBill(apptId)
+      }
     }
 
     // 鑷姩纭垂
@@ -341,6 +380,7 @@
     // 鍙戦�佹搷浣滄垚鍔熺殑浜嬩欢
     emit('event_dev_ready')
     message.success(t('鎿嶄綔瀹屾垚'))
+    return true
   } finally {
     formLoading.value = false
   }
@@ -436,7 +476,18 @@
   formData.value.patIdentityId = queueVO?.patIdentityId
   getFreeRentInfo(formData.value)  // 寰呮鏌ョ殑淇℃伅  @ dev_rent 琛�
 }
-defineExpose({ setPatient, getList: () => getList() }) // 鎻愪緵 setPatient 鏂规硶锛岀敤浜庤缃偅鑰�
+/**
+ * 銆愬彨鍙疯嚜鍔ㄥ畬鎴愩�戜緵鐖堕〉闈㈢偣銆屽彨鍙枫�嶆椂鍏堣嚜鍔ㄥ畬鎴愬綋鍓嶆偅鑰咃紙绛夊悓鐐广�岄鐢ㄥ畬鎴愩�嶏級銆�
+ */
+const completeCurrent = async (): Promise<boolean> => {
+  try {
+    return (await submitForm()) === true
+  } catch (e) {
+    console.warn('[DevReadyPanel] 鑷姩銆岄鐢ㄥ畬鎴愩�嶅け璐�', e)
+    return false
+  }
+}
+defineExpose({ setPatient, getList: () => getList(), completeCurrent }) // 鎻愪緵 setPatient 鏂规硶锛岀敤浜庤缃偅鑰�
 
 
 const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
@@ -496,9 +547,29 @@
     const data = await JobRecordApi.getJobRecordDoctorPage(queryParams)
     list.value = data.list
     total.value = data.total
+    // 鍒楄〃鍒锋柊鍚庢棫鐨勯�変腑琛屽凡澶辨晥锛屾竻鎺夛紝閬垮厤銆屾挙閿�銆嶄綔鐢ㄥ埌涓婁竴灞忕殑璁板綍
+    selectedRecord.value = undefined
   } finally {
     loading.value = false
   }
+}
+
+/** 銆�2026-11-25 闇�姹傘�戝凡瀹屾垚鍒楄〃鐨勯�変腑琛岋細鎾ら攢鍓嶅厛鐐归�変竴鏉★紝鎾ら攢浣滅敤鍦ㄩ�変腑璁板綍涓� */
+const selectedRecord = ref<any>()
+const onCurrentRowChange = (row: any) => {
+  selectedRecord.value = row || undefined
+}
+
+/** 鎾ら攢锛氬彧鎾ら攢褰撳墠閫変腑鐨勯偅鏉″畬鎴愯褰曪紙鏈�変腑鏃舵彁绀猴紝涓嶅啀榛樿鎾ら攢"鏈�杩戜竴鏉�"锛� */
+const undoSelected = () => {
+  if (!selectedRecord.value) {
+    message.warning('璇峰厛鍦ㄣ�屽凡瀹屾垚鍒楄〃銆嶄腑鐐归�変竴鏉¤褰曪紝鍐嶇偣銆屾挙閿�銆�')
+    return
+  }
+  emit('event_undo_finish', {
+    ...selectedRecord.value,
+    checkTypeName: getCheckTypeName(selectedRecord.value.checkType)
+  })
 }
 
 const onRowClick = (cur) => {
@@ -517,9 +588,34 @@
   devInfo.value.state = data.devState
 }
 
+/**
+ * 銆愭湰娆′慨澶嶃�戠瓑寰� hiprint 鎵撳嵃瀹㈡埛绔氨缁紙鏈�澶氱害 800ms锛夈��
+ *
+ * 鎵撳嵃瀹㈡埛绔槸**鏈満** websocket 鏈嶅姟锛堥粯璁� http://localhost:17521锛夛紝
+ * `print2()`锛堥潤榛樻墦鍗帮級瑕佹眰瀹冨凡杩炴帴锛涢娆$偣鍑绘椂 socket 鍙兘杩樺湪杩炴帴涓紝
+ * 杩欓噷鐭殏杞锛岄伩鍏�"鏈満鏄庢槑瑁呬簡瀹㈡埛绔紝鍗村洜涓烘病杩炰笂鑰屾墦涓嶅嚭绁�"銆�
+ *
+ * @returns true = 瀹㈡埛绔彲鐢紝鍙潤榛樻墦鍗帮紱false = 涓嶅彲鐢紝搴斿洖閫�娴忚鍣ㄦ墦鍗�
+ */
+const waitPrintClientOpened = async (tpl: any, timeoutMs = 800): Promise<boolean> => {
+  if (typeof tpl?.clientIsOpened !== 'function') return false
+  if (tpl.clientIsOpened()) return true
+  const step = 100
+  for (let waited = 0; waited < timeoutMs; waited += step) {
+    // eslint-disable-next-line no-await-in-loop
+    await new Promise((resolve) => setTimeout(resolve, step))
+    if (tpl.clientIsOpened()) return true
+  }
+  return false
+}
+
 const printBill = async (appointmentId: number | null | undefined, printMode?: number) => {
-  if ( appointmentId == null )
+  // 銆愭湰娆′慨澶嶃�戝師鏉ヨ繖閲岀洿鎺� return锛岀幇鍦鸿〃鐜版槸"鐐广�屾墦鍗板皬绁ㄣ�嶅畬鍏ㄦ病鍙嶅簲"銆�
+  // 灏忕エ鍐呭鍙栬嚜**棰勭害鍗�**锛屾病鏈夐绾﹀崟鍙峰氨娌℃湁鍙墦鍗扮殑鍐呭 鈥斺�� 杩欓噷鏄庣‘鎻愮ず銆�
+  if (appointmentId == null) {
+    message.warning('璇ユ偅鑰呮病鏈夊叧鑱旂殑棰勭害鍗曪紙缂哄皯棰勭害鍗曞彿锛夛紝鏃犳硶鎵撳嵃灏忕エ')
     return
+  }
 
   const curAppointment: AppointmentVO = await AppointmentApi.getAppointment( appointmentId )
 
@@ -531,27 +627,126 @@
 // 涓嬪垪鏂规硶閮芥槸娌℃湁鎷栨嫿璁捐椤甸潰鐨�, 鐩稿綋浜庝唬鐮佹ā寮�, 浣跨敤浠g爜璁捐椤甸潰
 // 鎯宠瀹炵幇鎷栨嫿璁捐椤甸潰,璇峰線涓嬬湅 '鑷畾涔夎璁�'
   var hiprintTemplate = new hiprint.PrintTemplate();  // 鍙紶鍙傛暟
-  //var panel = hiprintTemplate.addPrintPanel({ width: 100, height: 130, paperFooter: 340, paperHeader: 10 }); 瀵艰嚧璧颁笁椤�
-  var panel = hiprintTemplate.addPrintPanel({ width: 140, height: 130, paperNumberDisabled:true});
-//鏂囨湰
+
+// ============================================================================
+// 銆愭湰娆¤皟鏁绰烽�傞厤寰楀疄 DL-210 + 鐑晱绾� 50脳30mm銆�
+//
+// 鎵撳嵃鏈猴細寰楀疄 DL-210锛�203dpi = 8 dots/mm锛屽彲鎵撳嵃瀹藉害 108mm锛孶SB 鍙o級
+// 鑰楁潗  锛氱儹鏁忔爣绛剧焊 50mm(瀹�) 脳 30mm(楂�)
+//
+// 涔嬪墠妯℃澘鏄� 140脳130mm锛堢粰 A4/澶ч潰鍗曠敤鐨勶級锛屾瘮 50mm 绾稿鍑� 90mm 鈬� 椹卞姩鎸� 50mm 缂╂斁锛�
+// 瀛椾笌鏉$爜浼氳鍘嬪緱寰堝皬/瑁佸垏銆傝繖閲屾暣浣撴敼涓� 50脳30mm锛屽苟鎸夊皬绾搁噸鎺掍负 **5 琛� + 1 鏉$爜**锛�
+//
+//   y 0.8mm  鈹�鈹� 妫�鏌ラ」鐩紙10pt 鍔犵矖灞呬腑锛�
+//   y 5.6mm  鈹�鈹� 濮撳悕 鎬у埆 骞撮緞锛�9pt 鍔犵矖灞呬腑锛�
+//   y10.0mm  鈹�鈹� 鐥呭尯-搴婂彿锛堝乏鍗婏級 | 棰勭害 11-28 08:00锛堝彸鍗婏級  7.5pt
+//   y14.0mm  鈹�鈹� 鎮h�呯紪鍙凤紙宸﹀崐锛�   | 鎵嬫満鍙凤紙鍙冲崐锛�            7.5pt
+//   y18.4mm  鈹�鈹� 鏉″舰鐮侊紙楂� 10.8mm锛屽 46mm锛涘唴瀹� = 灏辫瘖娴佹按鍙� episodeId锛�
+//
+// 鈿狅笍銆愬崟浣嶅潙路2026-11-28 瀹炴祴銆慼iprint 鐨� **闈㈡澘**灏哄 `addPrintPanel({width,height})` 鐢� **mm**锛�
+//    浣�**鍏冪礌**鐨� `top/left/width/height` 鐢� **pt**锛堟簮鐮侊細`options.displayLeft()` 杩斿洖 `left+"pt"`锛�
+//    鍏冪礌榛樿 height=9.75 / width=120 涔熼兘鏄� pt锛夈�傜涓�鐗堟妸鍏冪礌鍧愭爣涔熷綋 mm 浼犲叆锛�0.6/5/8.8鈥︼級锛�
+//    缁撴灉 27.4"mm" 瀹為檯鍙湁 27.4pt鈮�9.7mm 鈬� 鎵�鏈夋枃瀛�/鏉$爜鎸ゅ湪鏍囩椤堕儴銆佷簰鐩搁噸鍙犮��
+//    鐜板湪缁熶竴锛�**甯冨眬浠嶆寜 mm 鍐�**锛岃繘鍏� hiprint 鍓嶇敤 mm2pt() 鎹㈢畻锛�1mm = 72/25.4 pt锛夈��
+// ============================================================================
+  const PAPER_W = 50 // 鏍囩绾稿 mm锛堥潰鏉垮崟浣�=mm锛�
+  const PAPER_H = 30 // 鏍囩绾搁珮 mm锛堥潰鏉垮崟浣�=mm锛�
+  /** 1mm = 2.83465pt */
+  const PT_PER_MM = 72 / 25.4
+  /** mm 鈫� pt锛堝厓绱犲潗鏍�/灏哄鐢級 */
+  const mm2pt = (v: number) => Math.round(v * PT_PER_MM * 100) / 100
+  // 銆愭墦鍗颁唤鏁般�戞寮忓彛寰� = 2 寮狅紙鎮h�� 1 寮� + 绉戝鐣欏瓨 1 寮狅級銆�
+  // 鎯虫敼浠芥暟鍙敼杩欎竴涓暟瀛楋細鏀� 1 = 娴嬭瘯鐪佺焊锛涙敼 3 = 涓夎仈銆�
+  const PRINT_COPIES = 2
+  var panel = hiprintTemplate.addPrintPanel({ width: PAPER_W, height: PAPER_H, paperNumberDisabled:true});
+
+  const FONT = '寰蒋闆呴粦'
+  /**
+   * 鍔犱竴琛屾枃鏈紙缁熶竴瀛椾綋/灞呬腑锛夈��
+   * 鍏ュ弬鍗曚綅锛�**mm**锛堝唴閮ㄦ崲绠楁垚 hiprint 闇�瑕佺殑 pt锛夛紱fontSize 鍗曚綅鏄� **pt**銆�
+   */
+  const addLine = (opts: {
+    top: number; left?: number; width?: number; height?: number;
+    title: string; fontSize?: number; bold?: boolean; align?: string;
+  }) => {
+    panel.addPrintText({
+      options: {
+        left: mm2pt(opts.left ?? 1),
+        top: mm2pt(opts.top),
+        width: mm2pt(opts.width ?? PAPER_W - 2),
+        height: mm2pt(opts.height ?? 3.6),
+        title: opts.title ?? '',
+        textAlign: opts.align ?? 'center',
+        fontSize: opts.fontSize ?? 8,
+        fontFamily: FONT,
+        fontWeight: opts.bold === false ? '400' : '700'
+      }
+    })
+  }
+
+// 鈶� 妫�鏌ラ」鐩紙y 0.8~5.4mm锛�
   const checkTypeName = getCheckTypeName(curAppointment.bookCheckType)
-  panel.addPrintText({ options: { width: 140, height: 12, top: 2, left: 20, title: checkTypeName, textAlign: 'center', fontSize: 10, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
+  addLine({ top: 0.8, height: 4.6, title: checkTypeName, fontSize: 10 })
+// 鈶� 濮撳悕 鎬у埆 骞撮緞锛坹 5.6~9.6mm锛�
   const patientBaisc = curAppointment.patName + "  " + calGender(curAppointment.patGender) + "  " + calculateAge(curAppointment.patBirthday) + "宀�"
-  panel.addPrintText({ options: { width: 140, height: 12, top: 16, left: 20, title: patientBaisc, textAlign: 'center' , fontSize: 10, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
-  const ward_bed = curAppointment.patWardDesc + "-" + curAppointment.patBedNo
-  panel.addPrintText({ options: { width: 140, height: 12, top: 30, left: 20, title: ward_bed, textAlign: 'center', fontSize: 10, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
-  const bookTime = formatTimestamp(curAppointment.bookDate) + " " + getBookBeginTime(curAppointment.bookTimeslot)
-  panel.addPrintText({ options: { width: 140, height: 12, top: 44, left: 20, title: bookTime, textAlign: 'center', fontSize: 10, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
-  panel.addPrintText({ options: { width: 140, height: 12, top: 58, left: 20, title: curAppointment.patId, textAlign: 'center', fontSize: 10, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
-  panel.addPrintText({ options: { width: 140, height: 12, top: 72, left: 20, title: curAppointment.patMobile, textAlign: 'center', fontSize: 10, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
-  //鏉″舰鐮�
-  panel.addPrintText({ options: { width: 140, height: 22, top: 86, left: 20, title: curAppointment.episodeId, textType: 'barcode' } });
+  addLine({ top: 5.6, height: 4.0, title: patientBaisc, fontSize: 9 })
+// 鈶� 鐥呭尯-搴婂彿 | 棰勭害鏃堕棿锛坹 10.0~13.6mm锛�"2026-11-28 08:00" 缂╂垚 "11-28 08:00"锛�
+  const ward_bed = (curAppointment.patWardDesc || '') + (curAppointment.patBedNo ? "-" + curAppointment.patBedNo : '')
+  addLine({ top: 10.0, height: 3.6, left: 1.5, width: 22, title: ward_bed, fontSize: 7.5 })
+  const bookTime = formatTimestamp(curAppointment.bookDate).slice(5) + " " + getBookBeginTime(curAppointment.bookTimeslot)
+  addLine({ top: 10.0, height: 3.6, left: 24, width: 25, title: bookTime, fontSize: 7.5 })
+// 鈶� 鎮h�呯紪鍙� | 鎵嬫満鍙凤紙y 14.0~17.6mm锛�
+  addLine({ top: 14.0, height: 3.6, left: 1.5, width: 22, title: curAppointment.patId ?? '', fontSize: 7.5 })
+  addLine({ top: 14.0, height: 3.6, left: 24, width: 25, title: curAppointment.patMobile ?? '', fontSize: 7.5 })
+// 鈶� 鏉″舰鐮侊紙鍐呭 = 灏辫瘖娴佹按鍙凤紱鍧愭爣鍚屾牱 mm鈫抪t锛�
+//
+//    銆�"娌″眳涓�"銆戔憼 鍏冪礌鎸夊唴瀹圭畻瀹藉悗 `left = (50-w)/2` 绮剧‘灞呬腑锛�
+//               鈶� hiprint 鐨勬潯褰� svg 鏄� `width:100%`锛屽搴﹂殢鍏冪礌璧帮紝鎵�浠ュ厓绱犲搴︿笉鑳介殢鎵嬬粰銆�
+//    銆�"鏁板�煎お浣�"銆慼iprint 鏉$爜鍏冪礌鍐呴儴鏄細
+//        <svg class="hibarcode_imgcode" width=100% height=100%> + <div class="hibarcode_displayValue">鏁板��</div>
+//    鏉″舰鍗犳弧鍏冪礌楂樺害锛屾暟鍊� div 鎺掑湪鍏冪礌鐩掑瓙**涔嬩笅**锛屽厓绱犱竴楂樻暟鍊煎氨琚帹鍒扮焊杈癸紙鐢氳嚦浼氭帀鍒扮浜岄〉/琚锛夈��
+//    鍥犳杩欓噷锛�**鍏虫帀瀹冭嚜甯︾殑鏁板�硷紙hideTitle锛�**锛屾敼鐢辨垜浠嚜宸辩揣璐存潯鐮佺敾涓�琛屽眳涓暟鍊硷紙浣嶇疆鍙帶锛夈��
+  const barcodeText = curAppointment.episodeId ?? ''
+  const isPureDigits = /^\d+$/.test(barcodeText)
+  // CODE128 妯″潡鏁帮細璧峰 11 + 鏁版嵁 + 鏍¢獙 11 + 缁堟 13锛�
+  // 绾暟瀛楀伓鏁颁綅璧� CODE128-C锛�2 浣�/绗﹀彿锛夛紝鍚﹀垯璧� CODE128-B锛�1 浣�/绗﹀彿锛�
+  const barcodeModules = isPureDigits && barcodeText.length % 2 === 0
+    ? 11 + (barcodeText.length / 2) * 11 + 11 + 13
+    : 11 + barcodeText.length * 11 + 11 + 13
+  // JsBarcode 閲� 1 妯″潡 = 1px 鈮� 0.2646mm锛�+1mm 浣欓噺锛屽苟闄愬埗鍦� 18~40mm锛堝お绐勪細绯娿�佸お瀹借秴鍑虹焊闈級
+  const barcodeWidthMm = Math.min(40, Math.max(18, barcodeModules * 0.2646 + 1))
+  const barcodeLeftMm = (PAPER_W - barcodeWidthMm) / 2
+  const BARCODE_TOP = 17.4   // 鏉″舰璧峰
+  const BARCODE_H = 8.2      // 鏉″舰楂樺害锛�203dpi 鈮� 66 鐐归珮锛屾壂鐮佽冻澶燂級
+  panel.addPrintText({
+    options: {
+      left: mm2pt(barcodeLeftMm),
+      top: mm2pt(BARCODE_TOP),
+      width: mm2pt(barcodeWidthMm),
+      height: mm2pt(BARCODE_H),
+      title: barcodeText,
+      textType: 'barcode',
+      hideTitle: true   // 涓嶈 hiprint 鑷甫鐨勬暟鍊硷紙瀹冨湪鍏冪礌涓嬫柟锛屼細鎶婂唴瀹归《鍑虹焊闈級
+    }
+  });
+  // 鈶�-2 鏁板�硷細绱ц创鏉$爜涓嬫柟 0.9mm锛屽眳涓紙涓庢潯鐮佸悓瀹斤紝瓒呭嚭浼氳鎴柇锛�
+  addLine({ top: BARCODE_TOP + BARCODE_H + 0.9, height: 3.0, title: barcodeText, fontSize: 7.5 })
 
 //鎵撳嵃
-  if (printMode == null)
-    hiprintTemplate.print2([{},{},{}]); // 棰勮鏂瑰紡 鍙互浼� [瀹氫綅鍙傛暟]  http://https://ccsimple.github.io/sv-print-docs/config/template.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E8%AE%BE%E8%AE%A1%E4%BD%BF%E7%94%A8%E7%A4%BA%E4%BE%8B
-  else
-    hiprintTemplate.print([{},{},{}]);
+// 銆愭湰娆′慨澶嶃�戜紭鍏�"闈欓粯鎵撳嵃"锛堥渶瑕佹湰鏈� hiprint 鎵撳嵃瀹㈡埛绔級锛�
+// 瀹㈡埛绔湭杩炴帴/鏈畨瑁呮椂**鍥為��娴忚鍣ㄦ墦鍗�**锛堝脊鎵撳嵃瀵硅瘽妗嗭級锛岄伩鍏嶅彧鎶ャ�岃繛鎺ュ鎴风澶辫触銆嶈�屾墦涓嶅嚭绁ㄣ��
+//   路 printMode == null 鈫� 鏈熸湜闈欓粯鎵撳嵃锛堟湰鏈烘湁瀹㈡埛绔椂锛�
+//   路 printMode != null 鈫� 鏄庣‘瑕佹眰娴忚鍣ㄦ墦鍗帮紙鍘熼�昏緫淇濈暀锛�
+//
+// 銆愭墦鍗颁唤鏁般�慼iprint 鐨勫叆鍙傛暟缁勯暱搴� = 椤垫暟锛堟瘡鍏冪礌涓�椤碉級銆�
+//   姝e紡鍙e緞 = 2 寮狅紱浠芥暟鍙湪 PRINT_COPIES 涓�澶勭淮鎶わ紙1=娴嬭瘯鐪佺焊锛�3=涓夎仈锛夈��
+  const pages: any[] = Array.from({ length: PRINT_COPIES }, () => ({}))
+  if (printMode == null && (await waitPrintClientOpened(hiprintTemplate))) {
+    hiprintTemplate.print2(pages); // 闈欓粯鎵撳嵃锛堟湰鏈哄鎴风锛�  鍙紶 [瀹氫綅鍙傛暟] http://https://ccsimple.github.io/sv-print-docs/config/template.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E8%AE%BE%E8%AE%A1%E4%BD%BF%E7%94%A8%E7%A4%BA%E4%BE%8B
+  } else {
+    console.info('[printBill] 鎵撳嵃瀹㈡埛绔湭灏辩华锛屽洖閫�涓烘祻瑙堝櫒鎵撳嵃锛屼唤鏁�=' + PRINT_COPIES)
+    hiprintTemplate.print(pages);
+  }
 }
 /* hiprint 绀轰緥
 // 寮曞叆鍚庝娇鐢ㄧず渚�
@@ -592,7 +787,8 @@
 */
 
 const getDevInfo = async () => {
-  if (formData.value?.devId == null) {
+  // 璁惧缂栧彿鍏佽鐣欑┖锛堢郴缁熷弬鏁�=鍚︼級鏃讹紝绌哄�间笉鍐嶅幓鏌ヨ澶囷紝閬垮厤鏃犳剰涔夎姹�/鎶ラ敊
+  if (!formData.value?.devId) {
     devInfo.value.brand = undefined
     devInfo.value.model = undefined
     devInfo.value.state = undefined
@@ -677,12 +873,19 @@
 
 const copyBarcode = async () => {
   if (!barcodeContent.value) return
-  await navigator.clipboard.writeText(barcodeContent.value)
+  // 銆愬吋瀹� Chrome 85 / http 璁块棶銆戦潪瀹夊叏涓婁笅鏂囦笅 navigator.clipboard 涓嶅彲鐢紝鐢ㄥ吋瀹瑰疄鐜�
+  const ok = await copyText(barcodeContent.value)
+  if (ok) {
+    message.success('宸插鍒�')
+  } else {
+    message.warning('褰撳墠娴忚鍣ㄤ笉鏀寔鑷姩澶嶅埗锛岃鎵嬪姩閫変腑澶嶅埗')
+  }
 }
 
 /** 鍒濆鍖� **/
 onMounted(() => {
   getList()
+  loadDevIdRequired()
 })
 
 </script>
@@ -705,7 +908,7 @@
   }
 
   &__text {
-    font-size: 14px;
+    font-size: 15px;
     font-weight: 600;
     color: var(--el-text-color-primary);
   }
@@ -782,4 +985,22 @@
     margin-left: 0;
   }
 }
+
+/* ==========================================================================
+   銆�2026-11-25 闇�姹傘�戝凡瀹屾垚鍒楄〃锛氬彧鏄剧ず 4 琛屽乏鍙筹紝瓒呰繃灏卞嚭鐜扮旱鍚戞粴鍔ㄦ潯
+   锛堝疄娴嬭楂� 40px銆佽〃澶� 63px 鈫� 63 + 4脳40 + 2 = 225px锛夈��
+   ========================================================================== */
+.records-scroll {
+  max-height: 225px;
+  min-height: 120px;
+  overflow-y: auto;
+  overflow-x: hidden;
+
+  :deep(.el-table__header-wrapper) {
+    position: sticky;
+    top: 0;
+    z-index: 2;
+    background-color: var(--el-bg-color);
+  }
+}
 </style>

--
Gitblit v1.9.3