From 45923ec6cb5d7ea44c71f1a07bdffb2beec9e32f Mon Sep 17 00:00:00 2001 From: liufumingren Date: Tue, 9 Jun 2026 14:18:51 +0800 Subject: [PATCH] 1 --- src/components/BatchReceivingPrintDialog.vue | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/components/BatchReceivingPrintDialog.vue b/src/components/BatchReceivingPrintDialog.vue index d044bc2b..c0168f07 100644 --- a/src/components/BatchReceivingPrintDialog.vue +++ b/src/components/BatchReceivingPrintDialog.vue @@ -120,6 +120,7 @@ 进度: {{ completedPrintCount }} / {{ selectionRows.length }}
关闭 + 浏览器打印 {{ currentPrintIndex < selectionRows.length - 1 ? '打印并切换下一个' : '打印当前单据' }} @@ -579,6 +580,36 @@ async function doPrint() { printing.value = false } } + +function browserPrint() { + const previewEl = document.querySelector('.preview-page') as HTMLElement | null + if (!previewEl) { + ElMessage.warning('暂无预览内容可打印') + return + } + const printWindow = window.open('', '_blank', 'width=800,height=600') + if (!printWindow) { + ElMessage.warning('请允许浏览器弹出窗口') + return + } + const styles = document.querySelectorAll('style, link[rel="stylesheet"]') + let styleHtml = '' + styles.forEach(s => { styleHtml += s.outerHTML }) + + printWindow.document.write(` + + + 打印预览${styleHtml} + + ${previewEl.outerHTML} + + + `) + printWindow.document.close() + printWindow.focus() + printWindow.print() + printWindow.close() +}