import { hiprint } from 'vue-plugin-hiprint' export const customProvider = function (options) { const addElementTypes = function (context) { context.removePrintElementTypes('customProvider') context.addPrintElementTypes('customProvider', [ new hiprint.PrintElementTypeGroup('', [ { tid: 'providerModule1.html', title: 'temu条码', data: 'XS888888888', type: 'html', formatter: function (data, options, templateData, e, x, target) { console.log(data, options, templateData) const elId = options.elId || 'barCode-' + new Date().getTime() // eslint-disable-next-line no-undef $('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, margin: 0, displayValue: false }) options.elId = `${elId}` // eslint-disable-next-line no-undef const codeHtml = $(`#${elId}`).html() // eslint-disable-next-line no-undef $(`#${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, margin: 0, displayValue: false }) const codeWidth = $(`#temuBarCode-${elId} .temuBarCode-code`).width() $(`#${elId}`).css('width', codeWidth + 'px') }) setTimeout(() => { const node = document.getElementById(`temuBarCode-${elId}`) if (node) { resizeObserver.observe(node) } }, 20) var html = `