| | |
| | | import {CircleCheck, Download, Printer} from "@element-plus/icons-vue/global"; |
| | | import TagStyleDesigner from "@/components/pp/TagStyleDesigner.vue"; |
| | | import {hiprint} from "vue-plugin-hiprint"; |
| | | import {createTemplate} from "@/hook/createTemplateTag" |
| | | |
| | | const company = companyInfo() |
| | | |
| | |
| | | const data = ref({ |
| | | printList: [] |
| | | }) |
| | | |
| | | let hiprintTemplate = ref(null) |
| | | onMounted(async () => { |
| | | await getTags(); |
| | | await hiprint.init(); |
| | | hiprintTemplate.value = new hiprint.PrintTemplate({}); |
| | | hiprintTemplate.value.design("#hiprint-printTemplate1",{grid:true}); |
| | | |
| | | }) |
| | | let hiprintTemplate = ref() |
| | | |
| | | |
| | | const tags = ref([]) |
| | | |
| | |
| | | }) |
| | | |
| | | const changeTag = () => { |
| | | hiprintTemplate.value = new hiprint.PrintTemplate({}); |
| | | const json = JSON.parse(tag.value.value) |
| | | |
| | | const json = tag.value.value |
| | | hiprintTemplate.value.update(json) |
| | | } |
| | | |
| | | const getTags = () => { |
| | | request.get('tagStyle/getTagList').then(res => { |
| | | res.data.forEach(item => { |
| | | item.value = JSON.parse(item.value) |
| | | }) |
| | | tags.value = res.data |
| | | }) |
| | | } |
| | | const printOrder = (type) => { |
| | | const list = hiprintTemplate.value.getJson() |
| | | const list = JSON.parse(JSON.stringify(hiprintTemplate.value.getJson())) |
| | | list.panels[0].printElements.forEach(element => { |
| | | element.options.fontFamily = 'Arial' |
| | | if( element.options.field !== undefined){ |
| | | if(type===3 ){ |
| | | element.options.hideTitle = true |
| | | } |
| | | } |
| | | if(type!==3){ |
| | | element.options.hideTitle = false |
| | | if( element.options.field === undefined){ |
| | | element.options.hideTitle = true |
| | | } |
| | | } |
| | | }) |
| | | |
| | | //hiprintTemplate.value.update(list) |
| | | let object = lastList.value |
| | | //判断是否为表格 |
| | | let columnsNum = null |
| | |
| | | object = {table:lastList.value} |
| | | columnsNum = (list.panels[0].printElements[0].options.gridColumns || 1) |
| | | } |
| | | //判断是否有 嵌套自定义纸张 |
| | | if(tag.value.tagHeight && tag.value.tagWidth){ |
| | | const print =createTemplate(hiprintTemplate.value.getJson(),object,tag.value.tagWidth,tag.value.tagHeight) |
| | | hiprintTemplate.value.update(print.template) |
| | | object = print.printData |
| | | } |
| | | hiprintTemplate.value.print(object) |
| | | |
| | | } |