diff --git a/klp-ui/src/layout/components/Navbar.vue b/klp-ui/src/layout/components/Navbar.vue
index 6c7fbf48..4c6747cb 100644
--- a/klp-ui/src/layout/components/Navbar.vue
+++ b/klp-ui/src/layout/components/Navbar.vue
@@ -12,7 +12,7 @@
@@ -116,9 +116,9 @@ export default {
},
checkWarning() {
listMaterialWarning({ pageNum: 1, pageSize: 1, warningStatus: '0' }).then(response => {
- this.hasWarning = response.total > 0
+ this.hasWarning = response.total
}).catch(() => {
- this.hasWarning = false
+ this.hasWarning = 0
})
},
async logout() {
diff --git a/klp-ui/src/views/crm/contract/components/ContractExportDialog.vue b/klp-ui/src/views/crm/contract/components/ContractExportDialog.vue
index 13954ba5..82672dbb 100644
--- a/klp-ui/src/views/crm/contract/components/ContractExportDialog.vue
+++ b/klp-ui/src/views/crm/contract/components/ContractExportDialog.vue
@@ -404,7 +404,9 @@ export default {
const printW = pW - mg * 2;
const printH = pH - mg * 2;
const ratio = canvas.width / printW;
- const pageCanvasHeight = printH * ratio;
+ const footerMargin = 8;
+ const imagePrintH = printH - footerMargin;
+ const pageCanvasHeight = imagePrintH * ratio;
let currentY = 0;
const pages = [];
@@ -435,17 +437,31 @@ export default {
currentY = pageBottom;
}
+ const checkedAttachmentCount = this.attachmentConfigs.filter(a => a.checked).length;
+ const totalPages = pages.length + checkedAttachmentCount;
+ let pageNum = 0;
+
+ const fullPageCanvasHeight = Math.round(printH * ratio);
+
for (let i = 0; i < pages.length; i++) {
+ pageNum++;
const { top, bottom } = pages[i];
const sliceH = bottom - top;
- const sliceMm = sliceH / ratio;
const sc = document.createElement('canvas');
sc.width = canvas.width;
- sc.height = Math.ceil(sliceH);
- sc.getContext('2d').drawImage(canvas, 0, top, canvas.width, sliceH, 0, 0, canvas.width, sliceH);
+ sc.height = fullPageCanvasHeight;
+ const sctx = sc.getContext('2d');
+ sctx.fillStyle = '#ffffff';
+ sctx.fillRect(0, 0, sc.width, sc.height);
+ sctx.drawImage(canvas, 0, top, canvas.width, sliceH, 0, 0, canvas.width, sliceH);
+ sctx.fillStyle = '#000000';
+ sctx.font = 'bold 24px "SimHei","黑体",sans-serif';
+ sctx.textAlign = 'center';
+ sctx.textBaseline = 'bottom';
+ sctx.fillText(`第 ${pageNum} 页,共 ${totalPages} 页`, sc.width / 2, sc.height - 4);
- pdf.addImage(sc.toDataURL('image/jpeg', 0.95), 'JPEG', mg, mg, printW, sliceMm);
+ pdf.addImage(sc.toDataURL('image/jpeg', 0.95), 'JPEG', mg, mg, printW, printH);
if (i < pages.length - 1) {
pdf.addPage();
@@ -459,22 +475,34 @@ export default {
try {
const img = await this.loadImage(att.url);
pdf.addPage();
+ pageNum++;
- let drawW = img.width;
- let drawH = img.height;
- const scale = Math.min(printW / drawW, printH / drawH, 1);
- drawW *= scale;
- drawH *= scale;
+ const canvasPageW = Math.round(printW * ratio);
+ const canvasImageH = Math.round(imagePrintH * ratio);
+ const canvasFooterH = Math.round(footerMargin * ratio);
+ const canvasTotalH = canvasImageH + canvasFooterH;
- const x = mg + (printW - drawW) / 2;
- const y = mg + (printH - drawH) / 2;
+ const attCanvas = document.createElement('canvas');
+ attCanvas.width = canvasPageW;
+ attCanvas.height = canvasTotalH;
+ const actx = attCanvas.getContext('2d');
+ actx.fillStyle = '#ffffff';
+ actx.fillRect(0, 0, canvasPageW, canvasTotalH);
- const tmpCanvas = document.createElement('canvas');
- tmpCanvas.width = img.width;
- tmpCanvas.height = img.height;
- tmpCanvas.getContext('2d').drawImage(img, 0, 0);
+ const imgScale = Math.min(canvasPageW / img.width, canvasImageH / img.height, 1);
+ const imgDrawW = img.width * imgScale;
+ const imgDrawH = img.height * imgScale;
+ const imgX = (canvasPageW - imgDrawW) / 2;
+ const imgY = (canvasImageH - imgDrawH) / 2;
+ actx.drawImage(img, imgX, imgY, imgDrawW, imgDrawH);
- pdf.addImage(tmpCanvas.toDataURL('image/jpeg', 0.95), 'JPEG', x, y, drawW, drawH);
+ actx.fillStyle = '#000000';
+ actx.font = 'bold 24px "SimHei","黑体",sans-serif';
+ actx.textAlign = 'center';
+ actx.textBaseline = 'bottom';
+ actx.fillText(`第 ${pageNum} 页,共 ${totalPages} 页`, canvasPageW / 2, canvasTotalH - 4);
+
+ pdf.addImage(attCanvas.toDataURL('image/jpeg', 0.95), 'JPEG', mg, mg, printW, printH);
} catch (e) {
console.error('加载附件图片失败: ' + att.originalName, e);
}
diff --git a/klp-ui/src/views/crm/contract/components/ContractPreview.vue b/klp-ui/src/views/crm/contract/components/ContractPreview.vue
index cf926f16..b13f884d 100644
--- a/klp-ui/src/views/crm/contract/components/ContractPreview.vue
+++ b/klp-ui/src/views/crm/contract/components/ContractPreview.vue
@@ -4,7 +4,6 @@
{{ contract.contractName }}
-
@@ -65,8 +64,6 @@