【修复】模板内temu标签组件bug
This commit is contained in:
@@ -376,3 +376,7 @@ table.hiprint-printElement-tableTarget {
|
||||
width: 80%;
|
||||
height: 60%;
|
||||
}
|
||||
|
||||
.temuBarCode-code svg {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.temuBarCode-code svg {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.temuBarCode-top,
|
||||
.temuBarCode-bottom {
|
||||
display: flex;
|
||||
|
||||
@@ -9,38 +9,35 @@ export const customProvider = function (options) {
|
||||
title: 'temu条码',
|
||||
data: 'XS888888888',
|
||||
type: 'html',
|
||||
formatter: function (data, options, templateData, e, x, target) {
|
||||
formatter: function (data, options, templateData) {
|
||||
console.log(data, options, templateData)
|
||||
const elId = options.elId || 'barCode-' + new Date().getTime()
|
||||
|
||||
const codeWidth = parseInt((options.width - 22) * 0.85)
|
||||
// eslint-disable-next-line no-undef
|
||||
$('body').append('<svg id="' + elId + '"></svg>')
|
||||
$('body').append(`<div id="codewrapper-${elId}" style="width: ${codeWidth}pt"><svg id="${elId}" width="100%" display="block" height="100%" class="hibarcode_imgcode" preserveAspectRatio="none slice"></svg></div>`)
|
||||
// eslint-disable-next-line no-undef
|
||||
JsBarcode('#'+ elId, '96778555251', {
|
||||
format: "CODE128B",
|
||||
width: 2,
|
||||
height: parseInt(hinnn.pt.toPx(options.height - 20).toString()) * 0.6 - 3,
|
||||
height: parseInt(hinnn.pt.toPx(options.height - 22).toString()) * 0.6,
|
||||
margin: 0,
|
||||
displayValue: false
|
||||
})
|
||||
options.elId = `${elId}`
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const codeHtml = $(`#${elId}`).html()
|
||||
const codeHtml = $(`#codewrapper-${elId}`).html()
|
||||
// eslint-disable-next-line no-undef
|
||||
$(`#${elId}`).remove()
|
||||
$(`body>#codewrapper-${elId}`).remove()
|
||||
// eslint-disable-next-line no-undef
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
JsBarcode('#'+ elId, '96778555251', {
|
||||
format: "CODE128B",
|
||||
width: 2,
|
||||
height: parseInt(hinnn.pt.toPx(options.height - 20).toString()) * 0.6 - 3,
|
||||
height: parseInt(hinnn.pt.toPx(options.height - 22).toString()) * 0.6,
|
||||
margin: 0,
|
||||
displayValue: false
|
||||
})
|
||||
|
||||
const codeWidth = $(`#temuBarCode-${elId} .temuBarCode-code`).width()
|
||||
$(`#${elId}`).css('width', codeWidth + 'px')
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -48,7 +45,7 @@ export const customProvider = function (options) {
|
||||
if (node) {
|
||||
resizeObserver.observe(node)
|
||||
}
|
||||
}, 20)
|
||||
}, 0)
|
||||
var html = `
|
||||
<div class="temuBarCode" id="temuBarCode-${elId}">
|
||||
<div class="temuBarCode-top">
|
||||
@@ -56,10 +53,8 @@ export const customProvider = function (options) {
|
||||
<div class="hiprint-printElement-text-content hiprint-printElement-content">AA 20PCS+AAA 20PCS</div>
|
||||
</div>
|
||||
<div class="temuBarCode-middle">
|
||||
<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">
|
||||
${codeHtml}
|
||||
</svg>
|
||||
<div class="hiprint-printElement-text-content hiprint-printElement-content temuBarCode-code" style="width: 100%">
|
||||
${codeHtml}
|
||||
</div>
|
||||
</div>
|
||||
<div class="temuBarCode-bottom">
|
||||
|
||||
Reference in New Issue
Block a user