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) { console.log(data, options, templateData) const elId = options.elId || 'barCode-' + new Date().getTime() const codeWidth = parseInt((options.width - 22) * 0.85) options.elId = `${elId}` // 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 - 22).toString()) * 0.6, margin: 0, displayValue: false }) // eslint-disable-next-line no-undef const codeHtml = $(`#codewrapper-${elId}`).html() // eslint-disable-next-line no-undef $(`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 - 22).toString()) * 0.6, margin: 0, displayValue: false }) }) setTimeout(() => { const node = document.getElementById(`temuBarCode-${elId}`) if (node) { resizeObserver.observe(node) } }, 0) var html = `
(AA+AAA)*20PCS
AA 20PCS+AAA 20PCS
${codeHtml}
1034130097
Made in China
` return html }, options: { width: 316, height: 120, elId: '', 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) options.elId = `${elId}` // 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 - 22).toString()) * 0.6, margin: 0, displayValue: false }) // eslint-disable-next-line no-undef const codeHtml = $(`#codewrapper-${elId}`).html() // eslint-disable-next-line no-undef $(`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 - 22).toString()) * 0.6, margin: 0, displayValue: false }) }) setTimeout(() => { const node = document.getElementById(`temuBarCode-${elId}`) if (node) { resizeObserver.observe(node) } }, 0) var html = `
(AA+AAA)*20PCS
AA 20PCS+AAA 20PCS
${codeHtml}
1034130097
Made in China
` return html }, }, printElementType: { } }, { tid: 'providerModule1.barcode', title: '条形码', data: 'XS888888888', type: 'text', options: { field: 'barcode', testData: 'XS888888888', height: 32, fontSize: 12, lineHeight: 18, textAlign: 'left', textType: 'barcode', hideTitle: false } }, { tid: 'providerModule1.qrcode', title: '二维码', data: 'XS888888888', type: 'text', options: { field: '', testData: '', height: 32, fontSize: 12, lineHeight: 18, textType: 'qrcode', hideTitle: false } }, { tid: 'providerModule1.image', title: 'Logo', data: 'https://foruda.gitee.com/avatar/1677050350324030848/5400665_ccsimple_1591166830.png!avatar200', type: 'image' } ]) ]) } return { addElementTypes } }