refactor(print): 更新打印功能实现并优化药品管理查询
- 替换旧的hiprint直接调用为统一的printUtils工具类 - 新增门诊手术计费打印模板支持(含流程图) - 修改门诊收费结算单打印逻辑,使用新的打印工具类 - 修复门诊挂号打印模板注释说明 - 优化药品库房查询,过滤已删除的记录 - 更新药品管理接口URL路径配置 - 添加打印客户端连接状态检查,支持浏览器打印预览备选方案 - 改进打印错误处理和用户提示机制
This commit is contained in:
@@ -17,8 +17,10 @@ const TEMPLATE_MAP = {
|
||||
import('@/views/pharmacymanagement/westernmedicine/components/templateJson.json'),
|
||||
IN_HOSPITAL_DISPENSING: () =>
|
||||
import('@/views/drug/inHospitalDispensing/components/templateJson.json'),
|
||||
//门诊挂号
|
||||
// 门诊挂号
|
||||
OUTPATIENT_REGISTRATION: () => import('@/components/Print/OutpatientRegistration.json'),
|
||||
// 门诊手术计费(含流程图)
|
||||
OUTPATIENT_SURGERY_CHARGE: () => import('@/components/Print/OutpatientSurgeryCharge.json'),
|
||||
//门诊收费
|
||||
OUTPATIENT_CHARGE: () => import('@/components/Print/OutpatientBilling.json'),
|
||||
//门诊病历
|
||||
@@ -121,6 +123,8 @@ export const PRINT_TEMPLATE = {
|
||||
IN_HOSPITAL_DISPENSING: 'IN_HOSPITAL_DISPENSING',
|
||||
//门诊挂号
|
||||
OUTPATIENT_REGISTRATION: 'OUTPATIENT_REGISTRATION',
|
||||
// 门诊手术计费
|
||||
OUTPATIENT_SURGERY_CHARGE: 'OUTPATIENT_SURGERY_CHARGE',
|
||||
//门诊收费
|
||||
OUTPATIENT_CHARGE: 'OUTPATIENT_CHARGE',
|
||||
//处方签
|
||||
@@ -242,8 +246,11 @@ export function executePrint(data, template, printerName, options = {}, business
|
||||
...options,
|
||||
};
|
||||
|
||||
// 如果指定了打印机,添加到打印选项中
|
||||
if (printerName) {
|
||||
// 检查客户端是否连接
|
||||
const isClientConnected = window.hiprint.hiwebSocket && window.hiprint.hiwebSocket.connected;
|
||||
|
||||
// 如果指定了打印机且客户端已连接,添加到打印选项中
|
||||
if (printerName && isClientConnected) {
|
||||
printOptions.printer = printerName;
|
||||
// 保存到缓存
|
||||
savePrinterToCache(printerName, businessName);
|
||||
@@ -259,8 +266,24 @@ export function executePrint(data, template, printerName, options = {}, business
|
||||
reject({ success: false, event: e, message: '打印失败' });
|
||||
});
|
||||
|
||||
// 执行打印
|
||||
hiprintTemplate.print2(data, printOptions);
|
||||
// 根据客户端连接状态选择打印方式
|
||||
if (isClientConnected && printerName) {
|
||||
// 客户端已连接且指定了打印机,使用静默打印
|
||||
hiprintTemplate.print2(data, printOptions);
|
||||
} else {
|
||||
// 客户端未连接或未指定打印机,使用浏览器打印预览(不需要客户端连接)
|
||||
console.log('打印客户端未连接,使用浏览器打印预览方式');
|
||||
hiprintTemplate.print(data, printOptions, {
|
||||
styleHandler: () => {
|
||||
return '<style>@media print { @page { margin: 0; } }</style>';
|
||||
},
|
||||
callback: () => {
|
||||
console.log('打印窗口已打开');
|
||||
}
|
||||
});
|
||||
// 浏览器打印模式下,直接resolve(因为打印窗口已打开)
|
||||
resolve({ success: true, message: '打印窗口已打开' });
|
||||
}
|
||||
} catch (error) {
|
||||
reject({ success: false, error: error, message: error.message || '打印过程中发生错误' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user