fix(common): 统一异常处理并迁移打印功能到hiprint

- 替换所有System.out.println和printStackTrace为slf4j日志记录
- 在BeanUtils、AuditFieldUtil、DateUtils、ServletUtils等工具类中添加Logger实例
- 在Flowable相关控制器和服务中统一错误日志记录格式
- 在代码生成器中添加日志记录功能
- 将前端打印组件从Lodop迁移到hiprint打印方案
- 更新体温单打印功能使用hiprint预览打印
- 移除调试用的console.log语句
- 修复打印模板中线条元素类型定义
This commit is contained in:
2026-03-06 22:16:44 +08:00
parent 8ef334ba1b
commit b65841c0cc
58 changed files with 678 additions and 888 deletions

View File

@@ -172,7 +172,9 @@ import {computed, onMounted, ref} from 'vue';
import {ElMessage} from 'element-plus';
import {patientInfoList} from '../../components/store/patient.js';
import {getSinglePatient} from '../store/patient.js'; // 导入获取单选患者信息的方法
import {formatDateStr} from '@/utils/index';
import {formatDateStr} from '@/utils';
// 迁移到 hiprint
import { previewPrint } from '@/utils/printUtils.js';
// 响应式数据
const loading = ref(false);
@@ -433,39 +435,16 @@ function handlePrint() {
printDialogVisible.value = true;
}
// 执行打印
// 执行打印 - 使用 hiprint
function doPrint() {
try {
// 获取要打印的内容
const printContent = document.getElementById('print-content').innerHTML;
// 创建临时窗口
const printWindow = window.open('', '_blank');
// 写入内容
printWindow.document.write(`
<html>
<head>
<title>预交金清单</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #ccc; padding: 8px; }
th { background-color: #f2f2f2; }
tfoot { font-weight: bold; }
.total-row { background-color: #f5f5f5; }
</style>
</head>
<body>
${printContent}
</body>
</html>
`);
// 打印
printWindow.document.close();
printWindow.focus();
printWindow.print();
const printContent = document.getElementById('print-content');
if (printContent) {
previewPrint(printContent);
} else {
ElMessage.warning('未找到打印内容');
}
} catch (e) {
ElMessage.error('打印失败');
console.error('Print error:', e);

View File

@@ -495,38 +495,16 @@ function handlePrint() {
printDialogVisible.value = true;
}
// 执行打印
// 执行打印 - 使用 hiprint
function doPrint() {
try {
// 获取要打印的内容
const printContent = document.getElementById('print-content').innerHTML;
// 创建临时窗口
const printWindow = window.open('', '_blank');
// 写入内容
printWindow.document.write(`
<html>
<head>
<title>费用明细清单</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #ccc; padding: 8px; }
th { background-color: #f2f2f2; }
tfoot { font-weight: bold; }
.total-row { background-color: #f5f5f5; }
</style>
</head>
<body>
${printContent}
</body>
</html>
`);
// 打印
printWindow.document.close();
printWindow.focus();
printWindow.print();
const printContent = document.getElementById('print-content');
if (printContent) {
previewPrint(printContent);
} else {
ElMessage.warning('未找到打印内容');
}
} catch (e) {
ElMessage.error('打印失败');
console.error('Print error:', e);

View File

@@ -345,6 +345,8 @@ import moment from 'moment';
import {ElMessage} from 'element-plus';
import {patientInfoList} from '../../components/store/patient.js';
import {formatDateStr} from '@/utils/index';
// 迁移到 hiprint
import { previewPrint } from '@/utils/printUtils.js';
import {getCostDetail} from './api.js';
import {getOrgList} from '../../../basicmanage/ward/components/api.js';
import {User} from '@element-plus/icons-vue';
@@ -627,39 +629,16 @@ function handlePrint() {
printDialogVisible.value = true;
}
// 执行打印
// 执行打印 - 使用 hiprint
function doPrint() {
try {
// 获取要打印的内容
const printContent = document.getElementById('print-content').innerHTML;
// 创建临时窗口
const printWindow = window.open('', '_blank');
// 写入内容
printWindow.document.write(`
<html>
<head>
<title>费用明细清单</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #ccc; padding: 8px; }
th { background-color: #f2f2f2; }
tfoot { font-weight: bold; }
.total-row { background-color: #f5f5f5; }
</style>
</head>
<body>
${printContent}
</body>
</html>
`);
// 打印
printWindow.document.close();
printWindow.focus();
printWindow.print();
const printContent = document.getElementById('print-content');
if (printContent) {
previewPrint(printContent);
} else {
ElMessage.warning('未找到打印内容');
}
} catch (e) {
ElMessage.error('打印失败');
console.error('Print error:', e);

View File

@@ -147,6 +147,8 @@ import {formatDateStr} from '@/utils';
import moment from 'moment';
import {getVitalSignsInfo, listPatient} from './components/api';
import useUserStore from '@/store/modules/user';
// 迁移到 hiprint
import { previewPrint } from '@/utils/printUtils.js';
// import { getSignsCharts } from '@/api/signsManagement'
// import { date } from 'jszip/lib/defaults'
const userStore = useUserStore();
@@ -452,65 +454,23 @@ function dateDiff(start, end) {
return '0';
}
}
// 打印体温单
// 打印体温单 - 使用 hiprint
function printTW() {
// this.$print(this.$refs.print);
printRef.value.focus();
printRef.value.contentWindow.print();
// this.$refs.refTemp.printPage();
const element = printRef.value;
if (element) {
previewPrint(element);
} else {
console.error('未找到可打印的内容');
}
}
// 打印体温单
// 打印体温单 - 使用 hiprint
function printPage() {
const element = printRef.value;
if (!element) {
if (element) {
previewPrint(element);
} else {
console.error('未找到可打印的内容');
return;
}
// 创建一个克隆元素用于打印,避免修改原 DOM
const clone = element.cloneNode(true);
// 设置宽度为 A4780px ≈ 210mm高度自适应
clone.style.transform = 'scale(0.7)';
clone.style.transformOrigin = 'top left';
clone.style.width = 'calc(210mm * 1.11)';
clone.style.height = 'calc(297mm * 1.11)';
clone.style.marginLeft = '50px';
// 插入到 body 中以便 html2pdf 渲染
document.body.appendChild(clone);
// 设置 html2pdf 配置
const opt = {
margin: 0,
filename: '体温单.pdf',
image: { type: 'jpeg', quality: 1 },
html2canvas: { scale: 2, useCORS: true }, // 启用跨域资源支持
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
pagebreak: { mode: ['avoid-all'] },
onclone: (clonedDoc) => {
const chart = clonedDoc.getElementById(clone.id);
if (chart) {
chart.style.width = '210mm'; // 强制 A4 宽度
chart.style.margin = '0 auto';
}
},
};
// 导出为 PDF 并打印
html2pdf()
.from(clone)
.set(opt)
.toPdf()
.get('pdf')
.then(function (pdf) {
pdf.autoPrint(); // 自动打印
window.open(pdf.output('bloburl'), '_blank'); // 在新窗口打开 PDF以便用户确认
})
.finally(() => {
document.body.removeChild(clone); // 清理临时元素
});
}
// 转化时间
function formatDateTo(dateStr) {