调样式

This commit is contained in:
yanran200730
2024-10-21 21:56:34 +08:00
parent 441510a4e4
commit d9fe8dea7b
3 changed files with 19 additions and 18 deletions

View File

@@ -17,7 +17,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
padding: 10pt 10pt; padding: 10pt 10pt;
border: 1pt solid #000; border: 2pt solid #000;
} }
.temuBarCode-code { .temuBarCode-code {
@@ -30,11 +30,11 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
width: 90%; width: 93%;
} }
.temuBarCode-middle { .temuBarCode-middle {
width: 80%; width: 85%;
height: 60%; height: 60%;
} }
</style> </style>

View File

@@ -274,8 +274,6 @@
return '<style></style>' return '<style></style>'
} }
} }
const list = this.labels
this.hiprintTemplate.print(printData) this.hiprintTemplate.print(printData)
}, },
@@ -284,23 +282,20 @@
node.innerHTML = el.html() node.innerHTML = el.html()
document.querySelector('body').appendChild(node) document.querySelector('body').appendChild(node)
return node.innerHTML const html = node.innerHTML
document.querySelector('body').removeChild(node)
return html
}, },
savePdf() { savePdf() {
const list = this.labels
this.hiprintTemplate.toPdf(printData, '测试导出pdf').then(v => { this.hiprintTemplate.toPdf(printData, '测试导出pdf').then(v => {
console.log(v) console.log(v)
}) })
}, },
getHtml() { getHtml() {
const list = this.labels
console.log(printData)
this.html = this.elementToString(this.hiprintTemplate.getHtml(printData)) this.html = this.elementToString(this.hiprintTemplate.getHtml(printData))
console.log(this.html)
this.isShowPreview = true this.isShowPreview = true
}, },

View File

@@ -12,20 +12,26 @@ export const customProvider = function (options) {
formatter: function (title, options, templateData) { formatter: function (title, options, templateData) {
console.log(options, templateData) console.log(options, templateData)
var elId = 'barCode-' + new Date().getTime() var elId = 'barCode-' + new Date().getTime()
$('body').append('<svg id="' + elId + '" width="100%" display="block" height="100%" class="hibarcode_imgcode" preserveAspectRatio="none slice"></svg>') // eslint-disable-next-line no-undef
$('body').append('<svg id="' + elId + '"></svg>')
console.log(options.width * 0.8) // eslint-disable-next-line no-undef
JsBarcode('#'+ elId, '96778555251', { JsBarcode('#'+ elId, '96778555251', {
format: "CODE128", format: "CODE128B",
width: 2, width: 2,
height: options.height * 0.6, height: options.height * 0.6 + 4,
margin: 0, margin: 0,
displayValue: false displayValue: false
}) })
// eslint-disable-next-line no-undef
const codeHtml = $(`#${elId}`).html() const codeHtml = $(`#${elId}`).html()
// eslint-disable-next-line no-undef
$(`#${elId}`).remove() $(`#${elId}`).remove()
// eslint-disable-next-line no-undef
$('document').on('resize', `#${elId}`, e => {
console.log(e)
});
var html = ` var html = `
<div class="temuBarCode"> <div class="temuBarCode">
<div class="temuBarCode-top"> <div class="temuBarCode-top">
@@ -34,7 +40,7 @@ export const customProvider = function (options) {
</div> </div>
<div class="temuBarCode-middle"> <div class="temuBarCode-middle">
<div class="hiprint-printElement-text-content hiprint-printElement-content temuBarCode-code"> <div class="hiprint-printElement-text-content hiprint-printElement-content temuBarCode-code">
<svg id="${elId}" style="display: block; width="100%" display="block" height="100%" class="hibarcode_imgcode" preserveAspectRatio="none slice"> <svg id="${elId}" style="display: block" width="100%" display="block" height="100%" class="hibarcode_imgcode" preserveAspectRatio="none slice">
${codeHtml} ${codeHtml}
</svg> </svg>
</div> </div>