feat: 二维码增加状态放置重复扫描,增加批次号

This commit is contained in:
砂糖
2025-09-12 17:07:57 +08:00
parent 7c9b64c74f
commit 79c580ac01
9 changed files with 158 additions and 137 deletions

View File

@@ -87,107 +87,107 @@ export default {
const labelHeight = labelContainer.offsetHeight;
// 3. 定义打印样式(确保与预览一致)
const printStyles = `
/* 基础容器样式 */
#label-preview-container {
width: ${labelWidth}px !important;
height: ${labelHeight}px !important;
padding: 1.5rem !important;
box-sizing: border-box !important;
border: 1px solid #333 !important;
background-color: #fff !important;
}
// const printStyles = `
// /* 基础容器样式 */
// #label-preview-container {
// width: ${labelWidth}px !important;
// height: ${labelHeight}px !important;
// padding: 1.5rem !important;
// box-sizing: border-box !important;
// border: 1px solid #333 !important;
// background-color: #fff !important;
// }
.company-header {
display: flex;
align-items: center;
margin-bottom: 0.3em;
}
// .company-header {
// display: flex;
// align-items: center;
// margin-bottom: 0.3em;
// }
.company-logo {
width: 2.8em;
height: 2.8em;
margin-right: 0.5em;
}
// .company-logo {
// width: 2.8em;
// height: 2.8em;
// margin-right: 0.5em;
// }
.company-name {
font-size: 0.95em;
line-height: 1.1;
}
// .company-name {
// font-size: 0.95em;
// line-height: 1.1;
// }
.english-name {
font-size: 0.6em;
opacity: 0.8;
}
// .english-name {
// font-size: 0.6em;
// opacity: 0.8;
// }
.product-title {
font-size: 1.4em;
font-weight: bold;
text-align: center;
margin-bottom: 0.4em;
border-bottom: 1.5px solid #000;
padding-bottom: 0.2em;
}
// .product-title {
// font-size: 1.4em;
// font-weight: bold;
// text-align: center;
// margin-bottom: 0.4em;
// border-bottom: 1.5px solid #000;
// padding-bottom: 0.2em;
// }
.footer-info {
display: flex;
justify-content: space-between;
align-items: flex-start;
font-size: 0.7em;
margin-top: 0.3em;
}
// .footer-info {
// display: flex;
// justify-content: space-between;
// align-items: flex-start;
// font-size: 0.7em;
// margin-top: 0.3em;
// }
.address {
line-height: 1.2;
width: 65%;
}
// .address {
// line-height: 1.2;
// width: 65%;
// }
.english-address {
opacity: 0.8;
font-size: 0.9em;
}
// .english-address {
// opacity: 0.8;
// font-size: 0.9em;
// }
.contact-timestamp {
text-align: right;
line-height: 1.4;
}
// .contact-timestamp {
// text-align: right;
// line-height: 1.4;
// }
/* 表格与单元格样式(解决空单元格问题) */
table {
border-collapse: collapse !important;
width: 100% !important;
table-layout: fixed !important; /* 固定列宽 */
}
// /* 表格与单元格样式(解决空单元格问题) */
// table {
// border-collapse: collapse !important;
// width: 100% !important;
// table-layout: fixed !important; /* 固定列宽 */
// }
td {
border: 1px solid #000 !important;
padding: 6px 4px !important; /* 确保单元格大小 */
min-height: 28px !important; /* 空单元格最小高度 */
vertical-align: middle !important;
text-align: center !important;
word-break: break-all !important; /* 长文本换行 */
font-family: "SimSun", serif !important;
font-size: 14px !important;
}
// td {
// border: 1px solid #000 !important;
// padding: 6px 4px !important; /* 确保单元格大小 */
// min-height: 28px !important; /* 空单元格最小高度 */
// vertical-align: middle !important;
// text-align: center !important;
// word-break: break-all !important; /* 长文本换行 */
// font-family: "SimSun", serif !important;
// font-size: 14px !important;
// }
/* 标签与值单元格样式 */
.label-cell {
font-weight: bold !important;
background-color: #f5f5f5 !important;
}
// /* 标签与值单元格样式 */
// .label-cell {
// font-weight: bold !important;
// background-color: #f5f5f5 !important;
// }
.value-cell {
background-color: #fff !important;
}
// .value-cell {
// background-color: #fff !important;
// }
/* 列宽分配(根据实际列数调整) */
td { width: 25% !important; } /* 4列布局 */
td[colspan="2"] { width: 50% !important; }
td[colspan="3"] { width: 75% !important; }
td[colspan="4"] { width: 100% !important; }
`;
// /* 列宽分配(根据实际列数调整) */
// td { width: 25% !important; } /* 4列布局 */
// td[colspan="2"] { width: 50% !important; }
// td[colspan="3"] { width: 75% !important; }
// td[colspan="4"] { width: 100% !important; }
// `;
// 4. 调用print-js打印
printJS({
@@ -195,8 +195,8 @@ export default {
type: 'html', // 打印类型为HTML
header: null, // 不显示页眉
footer: null, // 不显示页脚
style: printStyles, // 注入打印样式
scanStyles: false, // 禁用自动扫描页面样式(避免冲突)
// style: printStyles, // 注入打印样式
scanStyles: true, // 禁用自动扫描页面样式(避免冲突)
targetStyles: ['*'], // 允许所有样式生效
printContainer: true, // 打印指定容器
onError: (error) => { // 错误处理