fix(common): 统一异常处理并迁移打印功能到hiprint
- 替换所有System.out.println和printStackTrace为slf4j日志记录 - 在BeanUtils、AuditFieldUtil、DateUtils、ServletUtils等工具类中添加Logger实例 - 在Flowable相关控制器和服务中统一错误日志记录格式 - 在代码生成器中添加日志记录功能 - 将前端打印组件从Lodop迁移到hiprint打印方案 - 更新体温单打印功能使用hiprint预览打印 - 移除调试用的console.log语句 - 修复打印模板中线条元素类型定义
This commit is contained in:
@@ -46,8 +46,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
// import QRCode from 'qrcodejs2'
|
||||
import {getLodop} from '../../../plugins/print/LodopFuncs'
|
||||
// 迁移到 hiprint
|
||||
import { simplePrint, PRINT_TEMPLATE } from '@/utils/printUtils.js'
|
||||
import moment from 'moment'
|
||||
|
||||
export default {
|
||||
name: 'VuePrintNb',
|
||||
@@ -55,8 +56,7 @@ export default {
|
||||
printData: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
}
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -66,72 +66,46 @@ export default {
|
||||
qrCode: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// console.log('mounted方法');
|
||||
// this.initBarCode();
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
// initBarCode() {
|
||||
// this.$nextTick(() => {
|
||||
// if (this.lastId !== this.printData.patient.hisId) {
|
||||
// new QRCode(this.getId(this.printData.id), {
|
||||
// text: this.printData.patient.hisId,
|
||||
// width: 50,
|
||||
// height: 50,
|
||||
// colorDark: '#000000',
|
||||
// colorLight: '#ffffff',
|
||||
// correctLevel: QRCode.CorrectLevel.H
|
||||
// });
|
||||
// }
|
||||
// this.lastId = this.printData.patient.hisId;
|
||||
// });
|
||||
// },
|
||||
//
|
||||
// getId(id) {
|
||||
// return 'qrcode' + id;
|
||||
// },
|
||||
print(printerName) {
|
||||
const LODOP = getLodop()
|
||||
const printer = this.getPrinter(LODOP, printerName)
|
||||
if (printer === null) {
|
||||
this.openMesBox('6', '没有找到打印机【' + printerName + '】')
|
||||
return
|
||||
}
|
||||
/**
|
||||
* 使用 hiprint 执行打印
|
||||
* @param {string} printerName 打印机名称
|
||||
*/
|
||||
async print(printerName) {
|
||||
console.log(this.printData, 'printData')
|
||||
this.qrCode = this.printData.orderDetail[0].comboNo + this.printData.orderDetail[0].executionSeq
|
||||
LODOP.PRINT_INIT()
|
||||
LODOP.SET_PRINTER_INDEX(printer)// 指定打印机
|
||||
this.setPrint(LODOP)
|
||||
LODOP.SET_PRINT_PAGESIZE(0, 1070, 800, '')
|
||||
LODOP.PREVIEW() // 打印预览
|
||||
// LODOP.PRINT(); // 直接打印
|
||||
},
|
||||
setPrint(LODOP) {
|
||||
LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', document.getElementById(this.printData.id + 'div1').innerHTML)
|
||||
LODOP.ADD_PRINT_HTM(82, 0, '100%', '100%', document.getElementById(this.printData.id + 'div2').innerHTML)
|
||||
LODOP.ADD_PRINT_HTM(265, 10, '100%', '100%', document.getElementById(this.printData.id + 'div3').innerHTML)
|
||||
LODOP.SET_PRINT_STYLEA(0, 'ItemType', 1)
|
||||
// 设置二维码 qrcode ,条码128B等
|
||||
// LODOP.ADD_PRINT_BARCODE(Top,Left,Width,Height,BarCodeType,BarCodeValue);
|
||||
LODOP.ADD_PRINT_BARCODE(0, 300, 75, 75, 'qrcode', this.qrCode)// 设置条码位置、宽高、字体、值
|
||||
LODOP.SET_PRINT_STYLEA(0, 'FontSize', 18)// 设置上面这个条码下方的文字字体大小
|
||||
// LODOP.SET_PRINT_STYLEA(0,"Color","#FF0000");//设置当前条码以及条码下方字体的颜色
|
||||
LODOP.SET_PRINT_STYLEA(0, 'Angle', 180)// 设置旋转角度
|
||||
LODOP.SET_PRINT_STYLEA(0, 'ShowBarText', 0)// 设置是否显示下方的文字
|
||||
LODOP.SET_PRINT_STYLEA(0, 'AlignJustify', 2)// 设置条码下方的文字相对于条码本身居中
|
||||
// LODOP.SET_PRINT_STYLEA(0,"AlignJustify",1);//设置条码下方的文字相对于条码本身居左
|
||||
// LODOP.SET_PRINT_STYLEA(0,"AlignJustify",3);//设置条码下方的文字相对于条码本身居右
|
||||
// LODOP.SET_PRINT_STYLEA(0,"GroundColor","#0080FF");//设置条码的背景色
|
||||
},
|
||||
// 获取打印机
|
||||
getPrinter(LODOP, name) {
|
||||
const listCount = LODOP.GET_PRINTER_COUNT() // 当前打印设备数量
|
||||
for (let i = 0; i < listCount; i++) {
|
||||
if (LODOP.GET_PRINTER_NAME(i) === name) {
|
||||
return name
|
||||
try {
|
||||
// 构建打印数据
|
||||
const orderDetail = this.printData.orderDetail || []
|
||||
const qrCode = orderDetail[0] ? (orderDetail[0].comboNo + orderDetail[0].executionSeq) : ''
|
||||
|
||||
// 转换药品明细数据
|
||||
const formattedOrderDetail = orderDetail.map(item => ({
|
||||
orderName: item.orderName,
|
||||
doseOnceUnit: (item.doseOnce || '') + (item.doseUnit || ''),
|
||||
flag: item.flag || '',
|
||||
frequency: item.frequency || '',
|
||||
usageName: item.usageName || ''
|
||||
}))
|
||||
|
||||
const printData = {
|
||||
hisNo: this.printData.patient ? this.printData.patient.hisNo : '',
|
||||
name: this.printData.patient ? this.printData.patient.name : '',
|
||||
sexName: this.printData.patient ? this.printData.patient.sexName : '',
|
||||
patientAge: this.printData.patient ? this.printData.patient.patientAge : '',
|
||||
priority: this.printData.priority || '',
|
||||
qrCode: qrCode,
|
||||
orderDetail: formattedOrderDetail,
|
||||
printDate: moment().format('YYYY-MM-DD HH:mm')
|
||||
}
|
||||
// 使用 hiprint 打印
|
||||
await simplePrint(PRINT_TEMPLATE.INJECT_LABEL, printData, printerName)
|
||||
} catch (error) {
|
||||
console.error('输液标签打印失败:', error)
|
||||
if (this.openMesBox) {
|
||||
this.openMesBox('6', '打印失败: ' + (error.message || '未知错误'))
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user