From 8b0175a55ff67eb054744db59ddcaf396306522c Mon Sep 17 00:00:00 2001
From: guoyuji <guoyujie@ng.com>
Date: 星期四, 10 十月 2024 14:29:29 +0800
Subject: [PATCH] 控制页面,多列显示标签等信息
---
north-glass-erp/northglass-erp/src/components/pp/TagStyleDesigner.vue | 199 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 141 insertions(+), 58 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/components/pp/TagStyleDesigner.vue b/north-glass-erp/northglass-erp/src/components/pp/TagStyleDesigner.vue
index 8840050..ef7ec50 100644
--- a/north-glass-erp/northglass-erp/src/components/pp/TagStyleDesigner.vue
+++ b/north-glass-erp/northglass-erp/src/components/pp/TagStyleDesigner.vue
@@ -11,6 +11,7 @@
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()
@@ -128,28 +129,6 @@
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: {
@@ -538,21 +517,105 @@
}
},
+ /*{
+ 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()
})
@@ -583,7 +646,6 @@
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("璇疯緭鍏ュ畬鏁村楂�")
}
@@ -606,7 +668,23 @@
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'))
@@ -652,12 +730,27 @@
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
@@ -675,40 +768,29 @@
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>
@@ -801,7 +883,8 @@
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
--
Gitblit v1.8.0