| | |
| | | import PrintCustomLabel from '@/components/pp/PrintCustomLabelDetails.vue' |
| | | import PrintCustomLabelSemi from '@/components/pp/PrintCustomLabelSemi.vue' |
| | | import {Printer} from "@element-plus/icons-vue/global"; |
| | | import {View} from "@element-plus/icons-vue"; |
| | | |
| | | const { t } = useI18n() |
| | | const company = companyInfo() |
| | |
| | | |
| | | |
| | | const TgaStyleSet = ref([ |
| | | { |
| | | tid: 'INSIDE', title: '此面为室内面', data: '', type: 'text', |
| | | options: { |
| | | testData: '', |
| | | width:55, |
| | | height: 16, |
| | | fontSize: 6.75, |
| | | textAlign: "left", |
| | | textContentVerticalAlign: "middle" |
| | | } |
| | | }, |
| | | { |
| | | tid: 'OUTSIDE', title: '此面为室外面', data: '', type: 'text', |
| | | options: { |
| | | testData: '', |
| | | width:55, |
| | | height: 16, |
| | | fontSize: 6.75, |
| | | textAlign: "left", |
| | | textContentVerticalAlign: "middle" |
| | | } |
| | | }, |
| | | { |
| | | tid: 'orderId', title: '订单号', data: '', type: 'text', |
| | | options: { |
| | |
| | | } |
| | | }, |
| | | |
| | | /*{ |
| | | tid: 'table', |
| | | field: 'table', |
| | | title: '自定义表格', |
| | | type: 'table', |
| | | //columns:[[null,null,null,null,null,null]], |
| | | "options": { |
| | | "left": 20, |
| | | "top": 20, |
| | | "height": 56, |
| | | "width": 555, |
| | | "field": "table", |
| | | "tableHeaderRepeat": "none", |
| | | "tableBorder": "noBorder", |
| | | "tableBodyRowBorder": "noBorder", |
| | | "tableBodyCellBorder": "noBorder", |
| | | "fields": [ |
| | | { |
| | | "text": "商品名称", |
| | | "field": "orderId" |
| | | }, |
| | | { |
| | | "text": "商品编码", |
| | | "field": "orderNumber" |
| | | } |
| | | ], |
| | | |
| | | }, |
| | | "columns": [ |
| | | [ |
| | | { |
| | | "width": 138.75, |
| | | "title": "商品名称", |
| | | "field": "orderId", |
| | | "checked": true, |
| | | "columnId": "orderId", |
| | | "fixed": false, |
| | | "rowspan": 1, |
| | | "colspan": 1, |
| | | "renderFormatter": "function(value,row,index,options){return `订单号:${row.orderId || '测试商品名'}<br>条码:${row.barcode || '123456'}`}" |
| | | }, |
| | | ] |
| | | ] |
| | | }*/ |
| | | |
| | | ]) |
| | | |
| | | const tags = ref([]) |
| | | const activeName = ref(null) |
| | | |
| | | |
| | | // 注册默认面板 |
| | | hiprint.init({ |
| | | providers: [new TagStyleSet(TgaStyleSet.value)] |
| | | }); |
| | | |
| | | |
| | | |
| | | // 必须在 dom 加载完成之后给刚刚绑定上的元素添加上拖拽事件 |
| | | onMounted(async () => { |
| | | let table = { |
| | | tid: 'table', |
| | | field: 'table', |
| | | title: '自定义表格', |
| | | type: 'table', |
| | | "options": { |
| | | "left": 20, |
| | | "top": 20, |
| | | "height": 56, |
| | | "width": 555, |
| | | "field": "table", |
| | | "tableHeaderRepeat": "none", |
| | | "tableBorder": "noBorder", |
| | | "tableBodyRowBorder": "noBorder", |
| | | "tableBodyCellBorder": "noBorder", |
| | | "gridColumnsGutter": 3, |
| | | "fields": [ |
| | | ], |
| | | |
| | | }, |
| | | columns:[[null,null,null,null,null,null]] |
| | | |
| | | } |
| | | let list = [] |
| | | TgaStyleSet.value.forEach(item => { |
| | | let para = { |
| | | text: item.title, |
| | | field: item.options.field |
| | | } |
| | | list.push(para) |
| | | }) |
| | | table.options.fields = list |
| | | TgaStyleSet.value.push(table) |
| | | await getTags() |
| | | |
| | | await hiprint.init({ |
| | | //host: 'http://10.153.19.26:17521', |
| | | providers: [new TagStyleSet(TgaStyleSet.value)] |
| | | }); |
| | | |
| | | |
| | | // 注册默认面板 |
| | | |
| | | await buildDesigner() |
| | | }) |
| | | |
| | |
| | | if(type==='list'){ |
| | | hiprintTemplate.value.setPaper(size.width, size.height) |
| | | }else{ |
| | | console.log(autoPaper.value.width, autoPaper.value.height) |
| | | if (autoPaper.value.width==null ||autoPaper.value.width=='' || autoPaper.value.height==null || autoPaper.value.height==''){ |
| | | ElMessage.warning("请输入完整宽高") |
| | | } |
| | |
| | | inputValue:tag.value.name |
| | | }).then(({ value }) => { |
| | | tag.value.name = value |
| | | tag.value.value = JSON.stringify(hiprintTemplate.value.getJson()) |
| | | let json = $ref(hiprintTemplate.value.getJson()) |
| | | if(json.panels[0].printElements[0].options.field==='table' && json.panels[0].printElements.length===1){ |
| | | let funct = "function(value,row,index,options){return `" |
| | | json.panels[0].printElements[0].options.columns[0].forEach(item => { |
| | | if(item.field){ |
| | | funct += item.title+':${row.'+item.field+' || "" } <br>' |
| | | } |
| | | }) |
| | | funct+='`}' |
| | | json.panels[0].printElements[0].options.columns[0][0].renderFormatter = funct |
| | | }else{ |
| | | ElMessage.warning('保存失败,请检查是否只有一个表格') |
| | | return |
| | | } |
| | | |
| | | |
| | | tag.value.value = JSON.stringify(json) |
| | | request.post('tagStyle/saveTag',tag.value).then(res => { |
| | | if(res.code === '200' && res.data===true){ |
| | | ElMessage.success(t('basicData.msg.saveSuccess')) |
| | |
| | | const titleList = ref({}) |
| | | titleList.value=JSON.parse(JSON.stringify(hiprintTemplate.value.getJson())) |
| | | const printElements = titleList.value.panels[0].printElements; |
| | | const result = printElements.map(element => ({ |
| | | title: element.options.title, |
| | | name: element.options.field |
| | | })); |
| | | let a = [] |
| | | printElements.forEach(element => { |
| | | if(element.options.field==='table'){ |
| | | element.options.columns[0].forEach(elements => { |
| | | if(elements.field){ |
| | | a.push({ |
| | | title: elements.title, |
| | | name: elements.field |
| | | } |
| | | ) |
| | | } |
| | | }) |
| | | }else{ |
| | | a.push({ |
| | | title: element.options.title, |
| | | name: element.options.field |
| | | }) |
| | | } |
| | | }) |
| | | labelRow.value.titleList = a |
| | | |
| | | labelRow.value.titleList=result |
| | | labelRow.value.list =props.list |
| | | labelRow.value.faceOrientation = faceOrientation |
| | | labelRow.value.type = type |
| | |
| | | dialogTableVisibleCustomLabel.value = true |
| | | } |
| | | } |
| | | // request.post(`/processCard/getSelectPrintCustomLabelDetails/${type}/${lableType.value}`, data.value).then((res) => { |
| | | // if (res.code == 200) { |
| | | // produceList.value = deepClone(res.data.title) |
| | | // list.value = deepClone(res.data.data) |
| | | // const data = produceList.value[0].value |
| | | // dataList = JSON.parse(`[${data}]`); |
| | | // labelList = dataList[0] |
| | | // console.log(labelList.printElements) |
| | | // for (let i = 0; i < list.value.length; i++) { |
| | | // let count = list.value[i].data.length |
| | | // for (let j = 0; j < count; j++) { |
| | | // for (let k = 0; k < list.value[i].data[j].quantity; k++) { |
| | | // lastList.value.push(list.value[i].data[j]) |
| | | // } |
| | | // } |
| | | // } |
| | | // } else { |
| | | // ElMessage.warning(res.msg) |
| | | // router.push("/login") |
| | | // } |
| | | // hiprintTemplate.value.print(lastList.value) |
| | | // }) |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | const printOrder = () => { |
| | | const printOrder = (type) => { |
| | | const list = hiprintTemplate.value.getJson() |
| | | list.panels[0].printElements.forEach(element => { |
| | | element.options.fontFamily = 'Arial' |
| | | }) |
| | | hiprintTemplate.value.print(lastList.value) |
| | | let object = lastList.value |
| | | //判断是否为表格 |
| | | if(list.panels[0].printElements[0].options.field==='table'){ |
| | | object = {table:lastList.value} |
| | | } |
| | | |
| | | if(type===1){ |
| | | hiprintTemplate.value.print2(object) |
| | | }else{ |
| | | hiprintTemplate.value.print(object) |
| | | } |
| | | |
| | | } |
| | | |
| | | </script> |
| | |
| | | destroy-on-close |
| | | style="width: 80%;height:75% "> |
| | | <template #header="{ close, titleId, titleClass }"> |
| | | <el-button @click="printOrder" :icon="Printer" circle/> |
| | | <el-button @click="printOrder(1)" :icon="Printer" circle/> |
| | | <el-button @click="printOrder(2)" :icon="View" circle/> |
| | | </template> |
| | | <print-custom-label id="childLabel" |
| | | destroy-on-close |