From fd50118161dc0f6c552f2947abb673061224d7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=82=E7=B3=96?= <2178503051@qq.com> Date: Wed, 10 Jun 2026 11:29:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(contract/export/preview):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=90=88=E5=90=8C=E6=89=93=E5=8D=B0=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=A1=B5=E7=A0=81?= =?UTF-8?q?=E5=92=8C=E4=BF=AE=E5=A4=8D=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 移除coilTable的异常行高亮逻辑 2. 修复导航栏告警badge的显示逻辑 3. 为合同导出和预览添加页码标注,调整打印样式 4. 移除冗余的合同打印预览代码 --- klp-ui/src/layout/components/Navbar.vue | 6 +- .../components/ContractExportDialog.vue | 62 +++++-- .../contract/components/ContractPreview.vue | 173 ------------------ .../wms/report/components/coilTable/index.vue | 6 +- 4 files changed, 51 insertions(+), 196 deletions(-) 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 @@