diff --git a/openhis-ui-vue3/src/components/Print/OutpatientSurgeryCharge.json b/openhis-ui-vue3/src/components/Print/OutpatientSurgeryCharge.json index 99521484..515dd970 100644 --- a/openhis-ui-vue3/src/components/Print/OutpatientSurgeryCharge.json +++ b/openhis-ui-vue3/src/components/Print/OutpatientSurgeryCharge.json @@ -2,509 +2,44 @@ "panels": [ { "index": 0, - "name": 1, + "name": "门诊收费凭证", "paperType": "自定义", "height": 297, "width": 80, + "paperHeader": 0, + "paperFooter": 597, + "paperNumberDisabled": true, "paperList": { "type": "自定义", "width": 80, "height": 297 }, - "panelPageRule": "none", - "paperHeader": 0, - "paperFooter": 597, - "paperNumberDisabled": true, - "paperNumberContinue": true, - "expandCss": "", - "panelAngle": 0, - "overPrintOptions": { - "content": "", - "opacity": 0.7, - "type": 1 - }, - "watermarkOptions": { - "content": "", - "fillStyle": "rgba(87, 13, 248, 0.5)", - "fontSize": "36px", - "rotate": 25, - "width": 413, - "height": 310, - "timestamp": true, - "format": "YYYY-MM-DD HH:mm" - }, - "panelLayoutOptions": { - "layoutType": "column", - "layoutRowGap": 0, - "layoutColumnGap": 0 - }, "printElements": [ - { - "options": { - "left": 0, - "top": 8, - "height": 14, - "width": 226.5, - "title": "{{HOSPITAL_NAME}}门诊收费凭证", - "coordinateSync": false, - "widthHeightSync": false, - "fontWeight": "bold", - "textAlign": "center", - "fontSize": 11 - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 26, - "height": 10, - "width": 80, - "title": "患者:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "patientName" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 100, - "top": 26, - "height": 10, - "width": 60, - "title": "性别:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "sex" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 160, - "top": 26, - "height": 10, - "width": 60, - "title": "年龄:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "age" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 38, - "height": 10, - "width": 100, - "title": "科室:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "organizationName" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 120, - "top": 38, - "height": 10, - "width": 100, - "title": "医生:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "practitionerName" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 50, - "height": 10, - "width": 80, - "title": "病人类型:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "personType" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 100, - "top": 50, - "height": 10, - "width": 120, - "title": "门诊号:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "busNo" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 62, - "height": 10, - "width": 150, - "title": "收费时间:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "chargeTime" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 0, - "top": 76, - "height": 2, - "width": 226.5, - "coordinateSync": false, - "widthHeightSync": false, - "borderWidth": 1, - "borderStyle": "solid", - "borderColor": "#000000" - }, - "printElementType": { - "title": "线", - "type": "line" - } - }, - { - "options": { - "left": 10, - "top": 82, - "height": 10, - "width": 80, - "title": "收费项目", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "fontWeight": "bold" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 100, - "top": 82, - "height": 10, - "width": 40, - "title": "数量", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "fontWeight": "bold", - "textAlign": "center" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 145, - "top": 82, - "height": 10, - "width": 80, - "title": "金额", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "fontWeight": "bold", - "textAlign": "right" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 0, - "top": 94, - "height": 40, - "width": 226.5, - "title": "费用明细", - "field": "chargeItem", - "coordinateSync": false, - "widthHeightSync": false, - "textAlign": "center", - "fontSize": 8, - "columns": [ - [ - { - "title": "收费项目", - "width": 95, - "field": "chargeItemName", - "checked": true, - "columnId": "chargeItemName", - "fixed": false, - "rowspan": 1, - "colspan": 1 - }, - { - "title": "数量", - "width": 40, - "field": "quantityValue", - "checked": true, - "columnId": "quantityValue", - "fixed": false, - "rowspan": 1, - "colspan": 1 - }, - { - "title": "金额", - "width": 50, - "field": "totalPrice", - "checked": true, - "columnId": "totalPrice", - "fixed": false, - "rowspan": 1, - "colspan": 1, - "formatter2": "function(value, row, index, options, rowIndex, column) {\n if (!value) return '';\n return `${value}`;\n}" - } - ] - ] - }, - "printElementType": { - "title": "表格", - "type": "table", - "editable": true, - "columnDisplayEditable": true, - "columnDisplayIndexEditable": true, - "columnTitleEditable": true, - "columnResizable": true, - "columnAlignEditable": true, - "isEnableEditField": true, - "isEnableContextMenu": true, - "isEnableInsertRow": true, - "isEnableDeleteRow": true, - "isEnableInsertColumn": true, - "isEnableDeleteColumn": true, - "isEnableMergeCell": true - } - }, - { - "options": { - "left": 0, - "top": 136, - "height": 2, - "width": 226.5, - "coordinateSync": false, - "widthHeightSync": false, - "borderWidth": 1, - "borderStyle": "solid", - "borderColor": "#000000" - }, - "printElementType": { - "title": "线", - "type": "line" - } - }, - { - "options": { - "left": 10, - "top": 142, - "height": 10, - "width": 80, - "title": "合计:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "FULAMT_OWNPAY_AMT" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 100, - "top": 142, - "height": 10, - "width": 120, - "title": "现金:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "textAlign": "right", - "field": "SELF_CASH_PAY" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 154, - "height": 10, - "width": 100, - "title": "微信:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "SELF_VX_PAY" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 120, - "top": 154, - "height": 10, - "width": 100, - "title": "支付宝:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "textAlign": "right", - "field": "SELF_ALI_PAY" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 166, - "height": 10, - "width": 150, - "title": "医保账户:", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 9, - "field": "SELF_YB_ZH_PAY" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 0, - "top": 180, - "height": 2, - "width": 226.5, - "coordinateSync": false, - "widthHeightSync": false, - "borderWidth": 1, - "borderStyle": "dashed", - "borderColor": "#CCCCCC" - }, - "printElementType": { - "title": "线", - "type": "line" - } - }, - { - "options": { - "left": 0, - "top": 186, - "height": 12, - "width": 226.5, - "title": "门诊手术计费流程", - "coordinateSync": false, - "widthHeightSync": false, - "fontWeight": "bold", - "textAlign": "center", - "fontSize": 10, - "color": "#0066CC" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - }, - { - "options": { - "left": 10, - "top": 200, - "height": 85, - "width": 206.5, - "coordinateSync": false, - "widthHeightSync": false, - "field": "surgeryFlowImage", - "imgSrc": "/img/surgery-charge-flow.png", - "fit": "contain" - }, - "printElementType": { - "title": "图片", - "type": "image" - } - }, - { - "options": { - "left": 0, - "top": 288, - "height": 10, - "width": 226.5, - "title": "请妥善保管,有疑问请咨询服务台", - "coordinateSync": false, - "widthHeightSync": false, - "fontSize": 8, - "textAlign": "center", - "color": "#666666" - }, - "printElementType": { - "title": "文本", - "type": "text" - } - } + {"options": {"left": 0, "top": 8, "height": 14, "width": 226.5, "title": "{{HOSPITAL_NAME}}门诊收费凭证", "fontWeight": "bold", "textAlign": "center", "fontSize": 11}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 26, "height": 10, "width": 80, "title": "患者:", "fontSize": 9, "field": "patientName"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 100, "top": 26, "height": 10, "width": 60, "title": "性别:", "fontSize": 9, "field": "sex"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 160, "top": 26, "height": 10, "width": 60, "title": "年龄:", "fontSize": 9, "field": "age"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 38, "height": 10, "width": 100, "title": "科室:", "fontSize": 9, "field": "organizationName"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 120, "top": 38, "height": 10, "width": 100, "title": "医生:", "fontSize": 9, "field": "practitionerName"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 50, "height": 10, "width": 80, "title": "病人类型:", "fontSize": 9, "field": "personType"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 100, "top": 50, "height": 10, "width": 120, "title": "门诊号:", "fontSize": 9, "field": "busNo"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 62, "height": 10, "width": 150, "title": "收费时间:", "fontSize": 9, "field": "chargeTime"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 0, "top": 76, "height": 2, "width": 226.5, "borderWidth": 1, "borderStyle": "solid", "borderColor": "#000000"}, "printElementType": {"title": "线", "type": "line"}}, + {"options": {"left": 10, "top": 82, "height": 10, "width": 80, "title": "收费项目", "fontSize": 9, "fontWeight": "bold"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 100, "top": 82, "height": 10, "width": 40, "title": "数量", "fontSize": 9, "fontWeight": "bold", "textAlign": "center"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 145, "top": 82, "height": 10, "width": 80, "title": "金额", "fontSize": 9, "fontWeight": "bold", "textAlign": "right"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 0, "top": 94, "height": 40, "width": 226.5, "field": "chargeItem", "textAlign": "center", "fontSize": 8, "columns": [[{"title": "收费项目", "width": 95, "field": "chargeItemName"}, {"title": "数量", "width": 40, "field": "quantityValue"}, {"title": "金额", "width": 50, "field": "totalPrice"}]]}, "printElementType": {"title": "表格", "type": "table"}}, + {"options": {"left": 0, "top": 136, "height": 2, "width": 226.5, "borderWidth": 1, "borderStyle": "solid", "borderColor": "#000000"}, "printElementType": {"title": "线", "type": "line"}}, + {"options": {"left": 10, "top": 142, "height": 10, "width": 80, "title": "合计:", "fontSize": 9, "field": "FULAMT_OWNPAY_AMT"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 100, "top": 142, "height": 10, "width": 120, "title": "现金:", "fontSize": 9, "textAlign": "right", "field": "SELF_CASH_PAY"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 154, "height": 10, "width": 100, "title": "微信:", "fontSize": 9, "field": "SELF_VX_PAY"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 120, "top": 154, "height": 10, "width": 100, "title": "支付宝:", "fontSize": 9, "textAlign": "right", "field": "SELF_ALI_PAY"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 166, "height": 10, "width": 150, "title": "医保账户:", "fontSize": 9, "field": "SELF_YB_ZH_PAY"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 0, "top": 180, "height": 2, "width": 226.5, "borderWidth": 1, "borderStyle": "dashed", "borderColor": "#CCCCCC"}, "printElementType": {"title": "线", "type": "line"}}, + {"options": {"left": 0, "top": 186, "height": 12, "width": 226.5, "title": "门诊手术计费流程", "fontWeight": "bold", "textAlign": "center", "fontSize": 10, "color": "#0066CC"}, "printElementType": {"title": "文本", "type": "text"}}, + {"options": {"left": 10, "top": 200, "height": 85, "width": 206.5, "field": "surgeryFlowImage", "fit": "contain"}, "printElementType": {"title": "图片", "type": "image"}}, + {"options": {"left": 0, "top": 288, "height": 10, "width": 226.5, "title": "请妥善保管,有疑问请咨询服务台", "fontSize": 8, "textAlign": "center", "color": "#666666"}, "printElementType": {"title": "文本", "type": "text"}} ] } ] -} \ No newline at end of file +} diff --git a/openhis-ui-vue3/src/utils/printUtils.js b/openhis-ui-vue3/src/utils/printUtils.js index c283a40e..b71105cc 100644 --- a/openhis-ui-vue3/src/utils/printUtils.js +++ b/openhis-ui-vue3/src/utils/printUtils.js @@ -3,6 +3,8 @@ * 集中管理所有打印相关功能 */ +import {hiprint} from 'vue-plugin-hiprint'; + // 打印模板映射表 . const TEMPLATE_MAP = { // CLINIC_CHARGE: () => import('@/views/charge/cliniccharge/components/template.json'), @@ -42,6 +44,24 @@ const TEMPLATE_MAP = { //中药医生处方单 DOC_CHINESE_MEDICINE_PRESCRIPTION: () => import('@/components/Print/DocChineseMedicinePrescription.json'), + + // ========== 新增模板(原LODOP迁移)========== + //腕带 + WRIST_BAND: () => import('@/components/Print/WristBand.json'), + //分诊条 + TRIAGE_TICKET: () => import('@/components/Print/TriageTicket.json'), + //输液标签 + INJECT_LABEL: () => import('@/components/Print/InjectLabel.json'), + //床头卡 + BED_CARD: () => import('@/components/Print/BedCard.json'), + //护理交接班 + CHANGE_SHIFT_BILL: () => import('@/components/Print/ChangeShiftBill.json'), + //医嘱执行单 + EXE_ORDER_SHEET: () => import('@/components/Print/ExeOrderSheet.json'), + //体温单 + TEMPERATURE_SHEET: () => import('@/components/Print/TemperatureSheet.json'), + //会诊申请单 + CONSULTATION: () => import('@/components/Print/Consultation.json'), }; /** @@ -147,6 +167,24 @@ export const PRINT_TEMPLATE = { PHARMACY_PRESCRIPTION: 'PHARMACY_PRESCRIPTION', //中药医生处方单 DOC_CHINESE_MEDICINE_PRESCRIPTION: 'DOC_CHINESE_MEDICINE_PRESCRIPTION', + + // ========== 新增模板(原LODOP迁移)========== + //腕带 + WRIST_BAND: 'WRIST_BAND', + //分诊条 + TRIAGE_TICKET: 'TRIAGE_TICKET', + //输液标签 + INJECT_LABEL: 'INJECT_LABEL', + //床头卡 + BED_CARD: 'BED_CARD', + //护理交接班 + CHANGE_SHIFT_BILL: 'CHANGE_SHIFT_BILL', + //医嘱执行单 + EXE_ORDER_SHEET: 'EXE_ORDER_SHEET', + //体温单 + TEMPERATURE_SHEET: 'TEMPERATURE_SHEET', + //会诊申请单 + CONSULTATION: 'CONSULTATION', }; /** @@ -155,8 +193,8 @@ export const PRINT_TEMPLATE = { */ export function getPrinterList() { try { - if (window.hiprint && window.hiprint.hiwebSocket && window.hiprint.hiwebSocket.connected) { - const printerList = window.hiprint.hiwebSocket.getPrinterList(); + if (hiprint && hiprint.hiwebSocket && hiprint.hiwebSocket.connected) { + const printerList = hiprint.hiwebSocket.getPrinterList(); return printerList || []; } else { console.warn('打印服务未连接,返回空打印机列表'); @@ -230,15 +268,28 @@ export function savePrinterToCache(printerName, businessName = 'default') { export function executePrint(data, template, printerName, options = {}, businessName = 'default') { return new Promise((resolve, reject) => { try { - if (!window.hiprint) { - throw new Error('打印插件未加载'); - } + // 调试信息 + console.log('hiprint 对象:', hiprint); + console.log('hiprint.PrintTemplate:', hiprint.PrintTemplate); + console.log('模板数据:', template); const userStore = useUserStore(); const processedTemplate = JSON.parse( JSON.stringify(template).replace(/{{HOSPITAL_NAME}}/g, userStore.hospitalName) ); - const hiprintTemplate = new window.hiprint.PrintTemplate({ template: processedTemplate }); + + console.log('打印模板:', processedTemplate.panels?.[0]?.name, '元素数量:', processedTemplate.panels?.[0]?.printElements?.length); + + // 创建打印模板 + let hiprintTemplate; + try { + hiprintTemplate = new hiprint.PrintTemplate({ template: processedTemplate }); + } catch (templateError) { + console.error('创建打印模板失败:', templateError); + console.error('模板内容:', JSON.stringify(processedTemplate, null, 2)); + throw new Error('打印模板创建失败: ' + templateError.message); + } + const printOptions = { title: '打印标题', height: 210, @@ -247,7 +298,7 @@ export function executePrint(data, template, printerName, options = {}, business }; // 检查客户端是否连接 - const isClientConnected = window.hiprint.hiwebSocket && window.hiprint.hiwebSocket.connected; + const isClientConnected = hiprint.hiwebSocket && hiprint.hiwebSocket.connected; // 如果指定了打印机且客户端已连接,添加到打印选项中 if (printerName && isClientConnected) { @@ -348,9 +399,9 @@ export async function selectPrinterAndPrint( // 预览打印 export function previewPrint(elementDom) { if (elementDom) { - //初始化 - window.hiprint.init(); - const hiprintTemplate = new window.hiprint.PrintTemplate(); + // 初始化已在 main.js 中完成,无需重复调用 + // hiprint.init(); + const hiprintTemplate = new hiprint.PrintTemplate(); // printByHtml为预览打印 hiprintTemplate.printByHtml(elementDom, {}); } else {