From b8846be759b62473850fe09b284d440ce3cd1cce Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期三, 20 十一月 2024 14:52:34 +0800
Subject: [PATCH] 打印预约小票

---
 src/views/ecg/appointment/CheckItemPanel.vue |   51 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/src/views/ecg/appointment/CheckItemPanel.vue b/src/views/ecg/appointment/CheckItemPanel.vue
index ea51d69..ef4a19d 100644
--- a/src/views/ecg/appointment/CheckItemPanel.vue
+++ b/src/views/ecg/appointment/CheckItemPanel.vue
@@ -3,16 +3,18 @@
 import {useCheckTypeStore} from "@/store/modules/checkType";
 import {AppointmentApi, AppointmentVO} from "@/api/ecg/appointment";
 import {formatTimeslot} from "@/utils/formatter";
-import {isCurrentDay} from "@/utils/dateUtil";
+import {calculateAge, formatTimestamp, isCurrentDay} from "@/utils/dateUtil";
 import {QueueSequenceApi, QueueSequenceVO} from "@/api/ecg/queuesequence";
 import {formatDate} from "../../../utils/formatTime";
 import { cloneDeep } from 'lodash-es'
+import {hiprint} from "vue-plugin-hiprint";
+import {calGender, getBookBeginTime} from "@/utils";
 
 defineComponent({
   name: 'CheckItemPanel'
 })
 
-const  props = defineProps({
+const props = defineProps({
   appointment: {
     type: Object as PropType<AppointmentVO>,
     required: true
@@ -23,6 +25,8 @@
 
 const checkTypeTimeslotList = ref<QueueSequenceVO>()
 const bookTimeSlotVip = ref<number>()
+
+const bookSeqNum = ref<number>()
 
 const _confirmAppointment = async () => {
   if (!isCurrentDay(props.appointment.bookDate)) {
@@ -41,6 +45,8 @@
             tempAppointment.bookTimeslot = bookTimeSlotVip.value
           }
           const data = await AppointmentApi.confirmAppointmentVip(tempAppointment)
+          bookSeqNum.value = data
+          _printNote()
           ElNotification({
             title: '娓╅Θ鎻愮ず',
             message: data,
@@ -56,12 +62,48 @@
         })
   } else {
     const data = await AppointmentApi.confirmAppointment(props.appointment)
+    bookSeqNum.value = data
+    _printNote()
     ElNotification({
       title: '娓╅Θ鎻愮ず',
       message: data,
       type: 'warning'
     })
   }
+}
+
+const _printNote = async (printMode?: number) => {
+  console.info( props.appointment )
+
+// 寮曞叆鍚庝娇鐢ㄧず渚�
+  hiprint.init({
+    //    host: 'http://192.168.2.100:17521',
+    token: '111111'
+  });
+// 涓嬪垪鏂规硶閮芥槸娌℃湁鎷栨嫿璁捐椤甸潰鐨�, 鐩稿綋浜庝唬鐮佹ā寮�, 浣跨敤浠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});
+//鏂囨湰
+  const checkTypeName = checkTypeStore.getCheckTypeName(props.appointment.bookCheckType)
+  panel.addPrintText({ options: { width: 140, height: 12, top: 2, left: 20, title: checkTypeName, textAlign: 'center', fontSize: 8, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
+  const patientBaisc = props.appointment.patName + "  " + calGender(props.appointment.patGender) + "  " + calculateAge(props.appointment.patBirthday) + "宀�"
+  panel.addPrintText({ options: { width: 140, height: 12, top: 16, left: 20, title: patientBaisc, textAlign: 'center' , fontSize: 8, fontWeight: '700', } });
+  const ward_bed = props.appointment.patWardDesc + "-" + props.appointment.patBedNo
+  panel.addPrintText({ options: { width: 140, height: 12, top: 30, left: 20, title: ward_bed, textAlign: 'center', fontSize: 8, fontFamily: '榛戜綋', } });
+  const bookTime = formatTimestamp(props.appointment.bookDate) + " " + getBookBeginTime(props.appointment.bookTimeslot)
+  panel.addPrintText({ options: { width: 140, height: 12, top: 44, left: 20, title: bookTime, textAlign: 'center', fontSize: 8 } });
+  //panel.addPrintText({ options: { width: 140, height: 12, top: 58, left: 20, title: props.appointment.patId, textAlign: 'center', fontSize: 8 } });
+  //panel.addPrintText({ options: { width: 140, height: 12, top: 72, left: 20, title: props.appointment.patMobile, textAlign: 'center', fontSize: 8, fontFamily: '寰蒋闆呴粦',  fontWeight: '700', } });
+  const _bookSeqNum = bookSeqNum.value + ''  // 锛侊紒闇�瑕佸瓧绗︿覆
+  panel.addPrintText({ options: { width: 140, height: 12, top: 62, left: 20, title: _bookSeqNum, textAlign: 'center', fontSize: 16, fontFamily: '寰蒋闆呴粦',  fontWeight: '900' } });
+
+//鎵撳嵃
+  if (undefined === printMode)
+    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([{},{},{}]);
 }
 
 onMounted( async () => {
@@ -87,9 +129,10 @@
           :disabled="item.queueVipNo === item.queueVipFull"
       />
     </el-select>
-
+    {{bookSeqNum}}
     <el-divider/>
-    <el-button :type="isCurrentDay(appointment.bookDate)?'primary':'warning'" @click="_confirmAppointment"><Icon icon="ep:refresh" class="mr-5px" /> 鎺掗槦 </el-button>
+    <el-button @click="_confirmAppointment" :type="isCurrentDay(appointment.bookDate)?'primary':'warning'"><Icon icon="ep:list" class="mr-5px" /> 鎺掗槦 </el-button>
+    <el-button @click="_printNote(8)"><Icon icon="ep:printer" class="mr-5px" /> 鎵撳嵃鍙� </el-button>
   </el-card>
 </template>
 

--
Gitblit v1.9.3