diff --git a/public/css/print-lock.css b/public/css/print-lock.css index 2523ed9..bded019 100644 --- a/public/css/print-lock.css +++ b/public/css/print-lock.css @@ -376,3 +376,7 @@ table.hiprint-printElement-tableTarget { width: 80%; height: 60%; } + +.temuBarCode-code svg { + width: 100%; +} diff --git a/public/index.html b/public/index.html index 9d8208a..483ff27 100644 --- a/public/index.html +++ b/public/index.html @@ -25,6 +25,10 @@ height: 100%; } + .temuBarCode-code svg { + width: 100%; + } + .temuBarCode-top, .temuBarCode-bottom { display: flex; diff --git a/src/components/print/customProvider.js b/src/components/print/customProvider.js index 50378e1..377f58e 100644 --- a/src/components/print/customProvider.js +++ b/src/components/print/customProvider.js @@ -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('') + $('body').append(`
`) // 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 = `
@@ -56,10 +53,8 @@ export const customProvider = function (options) {
AA 20PCS+AAA 20PCS
-
- - ${codeHtml} - +
+ ${codeHtml}