diff --git a/manager/src/utils/print.js b/manager/src/utils/print.js index 49a0f0f12..73ac669a4 100644 --- a/manager/src/utils/print.js +++ b/manager/src/utils/print.js @@ -1,7 +1,7 @@ /** - * 打印指定 DOM 区域(替代 vue-print-nb) + * 打印指定 DOM 区域(支持标准 A4 纵向与完整打印样式隔离) */ -export function printElement(elementId, title = "打印") { +export function printElement(elementId, title = "打印发货单") { const el = document.getElementById(elementId); if (!el) { return; @@ -13,22 +13,196 @@ export function printElement(elementId, title = "打印") { doc.open(); doc.write( `${title}${el.innerHTML}` ); doc.close(); iframe.contentWindow.focus(); - iframe.contentWindow.print(); - setTimeout(() => document.body.removeChild(iframe), 1000); + setTimeout(() => { + iframe.contentWindow.print(); + setTimeout(() => { + if (document.body.contains(iframe)) { + document.body.removeChild(iframe); + } + }, 1500); + }, 100); } diff --git a/manager/src/views/order/order/orderDetail.vue b/manager/src/views/order/order/orderDetail.vue index 828e9323f..fb20813d9 100644 --- a/manager/src/views/order/order/orderDetail.vue +++ b/manager/src/views/order/order/orderDetail.vue @@ -498,43 +498,179 @@ - - + + -