feat(clgl)条码打印修改
This commit is contained in:
@@ -254,6 +254,54 @@
|
||||
function reloadGrid() {
|
||||
__doPostBack(null, 'reloadGrid');
|
||||
}
|
||||
function printByHiddenFrame(url) {
|
||||
var frameId = 'fastreport-print-frame-' + new Date().getTime();
|
||||
var frame = document.createElement('iframe');
|
||||
frame.id = frameId;
|
||||
frame.name = frameId;
|
||||
frame.style.position = 'fixed';
|
||||
frame.style.left = '-10000px';
|
||||
frame.style.top = '-10000px';
|
||||
frame.style.width = '1px';
|
||||
frame.style.height = '1px';
|
||||
frame.style.border = '0';
|
||||
frame.style.opacity = '0';
|
||||
frame.onload = function () {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
frame.contentWindow.onafterprint = cleanupPrintFrame;
|
||||
frame.contentWindow.focus();
|
||||
frame.contentWindow.print();
|
||||
} catch (e) {
|
||||
window.print();
|
||||
}
|
||||
}, 500);
|
||||
};
|
||||
frame.src = url;
|
||||
document.body.appendChild(frame);
|
||||
var cleaned = false;
|
||||
function cleanupPrintFrame() {
|
||||
if (cleaned) {
|
||||
return;
|
||||
}
|
||||
cleaned = true;
|
||||
if (frame && frame.parentNode) {
|
||||
frame.parentNode.removeChild(frame);
|
||||
}
|
||||
window.removeEventListener('afterprint', cleanupPrintFrame);
|
||||
}
|
||||
window.addEventListener('afterprint', cleanupPrintFrame);
|
||||
setTimeout(cleanupPrintFrame, 300000);
|
||||
}
|
||||
window.addEventListener('message', function (event) {
|
||||
if (!event.data || event.data.type !== 'fastreport-print-finished') {
|
||||
return;
|
||||
}
|
||||
var frame = document.getElementById(event.data.frameId);
|
||||
if (frame && frame.parentNode) {
|
||||
frame.parentNode.removeChild(frame);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user