SchoolPhysicalExamination/application/OutsideInterface/view/admin/printaction/print_outside_box_index.html

147 lines
4.3 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标签打印系统 - 集成码</title>
<script src="../x_admin/js/jq.js"></script>
<style>
body {
margin: 0;
padding: 20px;
font-family: Arial, sans-serif;
background-color: white;
text-align: center;
}
h1 {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.description {
font-size: 16px;
margin-bottom: 20px;
}
#barcodeContainer {
margin: 20px auto;
padding: 10px;
border: 2px dashed black;
display: inline-block;
}
/* 标签图片容器 - 精确匹配45mm×55mm尺寸 */
#labelImageContainer {
width: 531px; /* 45mm @ 300dpi */
height: 649px; /* 55mm @ 300dpi */
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
#labelImage {
max-width: 100%;
max-height: 100%;
display: block;
}
#printBtn {
display: block;
width: 200px;
margin: 20px auto;
padding: 10px;
background-color: #1E88E5;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
}
@media print {
/* 方案2如果需要完全干净的页面使用这个替代方案1 */
body {
visibility: hidden !important;
margin: 0 !important;
padding: 0 !important;
}
#labelImageContainer {
visibility: visible !important;
position: absolute !important;
left: 0 !important;
top: 0 !important;
width: 531px !important;
height: 649px !important;
margin: 0 !important;
padding: 0 !important;
}
#labelImage {
visibility: visible !important;
width: 100% !important;
height: 100% !important;
object-fit: contain !important;
}
}
</style>
</head>
<body>
<h1>标签打印系统 - 集成码</h1>
<div class="description">生成包含二维码和条形码的标签</div>
<div id="barcodeContainer">
<div id="labelImageContainer">
<img id="labelImage" src="" alt="标签图片">
</div>
</div>
<button id="printBtn">直接打印</button>
<script>
$(document).ready(function() {
loadCombinedCode();
$('#printBtn').click(function() {
// 确保图片已加载再打印
if($('#labelImage').attr('src') && $('#labelImage')[0].complete) {
window.print();
} else {
alert('请等待标签加载完成');
}
});
});
function loadCombinedCode() {
$.ajax({
url: "/z/print_combined_code",
type: "POST",
dataType: "json",
success: function(response) {
if(response.code == 10002) {
alert('没有可用的编码,请稍后再试');
}
else if(response.code == 10003) {
alert(response.msg);
}
else if(response.data && response.data.image) {
// 直接显示完整的标签图片
$('#labelImage').attr('src', response.data.image);
}
},
error: function(xhr, status, error) {
console.error("请求出错:", error);
alert('加载标签失败,请重试');
}
});
}
</script>
</body>
</html>