11<template >
22 <a-modal
33 v-model =" visible"
4- :title =" $t('cmdb.ci.qrcodeBatchTitle')"
54 width =" 800px"
65 :footer =" null"
76 :maskClosable =" true"
87 >
9- <p class =" qrcode-batch-tip" >{{ $t('cmdb.ci.qrcodeBatchTip') }}</p >
8+ <p slot =" title" >
9+ {{ $t('cmdb.ci.qrcodeBatchTitle') }}
10+ <a-tooltip :title =" $t('cmdb.ci.qrcodeBatchTip')" >
11+ <a-icon style =" color : #999 ; cursor : pointer ;" type =" question-circle" />
12+ </a-tooltip >
13+ </p >
1014
1115 <div v-if =" qrcodeList.length === 0 && !generating" class =" qrcode-batch-empty" >
1216 <a-empty :description =" $t('cmdb.ci.qrcodeBatchEmpty')" />
1317 </div >
1418
1519 <div v-if =" generating" class =" qrcode-batch-generating" >
1620 <a-spin />
17- <span >正在生成 {{ generatedCount }} / {{ totalCount }} ... </span >
21+ <span >{{ $t('cmdb.ci.qrcodeBatchGenerating', { generatedCount, totalCount }) }} </span >
1822 </div >
1923
2024 <div v-if =" qrcodeList.length" class =" qrcode-batch-grid" ref =" qrcodeGrid" >
@@ -93,7 +97,7 @@ export default {
9397 if (canvas) {
9498 try {
9599 await QRCode .toCanvas (canvas, item .url , {
96- width: 150 ,
100+ width: 140 ,
97101 margin: 1 ,
98102 color: { dark: ' #000000' , light: ' #ffffff' }
99103 })
@@ -135,7 +139,20 @@ export default {
135139 return
136140 }
137141
138- const content = grid .innerHTML
142+ const printGrid = grid .cloneNode (true )
143+ const sourceCanvases = grid .querySelectorAll (' canvas' )
144+ const printCanvases = printGrid .querySelectorAll (' canvas' )
145+ printCanvases .forEach ((canvas , index ) => {
146+ const sourceCanvas = sourceCanvases[index]
147+ if (! sourceCanvas) return
148+ const img = printWindow .document .createElement (' img' )
149+ img .src = sourceCanvas .toDataURL (' image/png' )
150+ img .width = sourceCanvas .width || 140
151+ img .height = sourceCanvas .height || 140
152+ canvas .replaceWith (img)
153+ })
154+
155+ const content = printGrid .innerHTML
139156 printWindow .document .write (`
140157 <html>
141158 <head>
@@ -146,6 +163,7 @@ export default {
146163 .qrcode-batch-item { text-align: center; width: 170px; }
147164 .qrcode-batch-item-label { font-size: 12px; margin: 4px 0 2px; word-break: break-all; }
148165 .qrcode-batch-item-id { font-size: 11px; color: #999; margin: 0; }
166+ .qrcode-batch-item img { display: block; margin: 0 auto; }
149167 @media print {
150168 .qrcode-batch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
151169 .qrcode-batch-item { page-break-inside: avoid; }
@@ -192,7 +210,8 @@ export default {
192210 flex-wrap : wrap ;
193211 gap : 16px ;
194212 justify-content : center ;
195- padding : 8px 0 ;
213+ max-height : 50vh ;
214+ overflow-y : auto ;
196215}
197216
198217.qrcode-batch-item {
0 commit comments