From d050ea43d2d4647ae57f03fb58167954bd747810 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Thu, 3 Jul 2025 14:30:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/labelSetting/label_setting.js | 6 + src/utils/zplUtil.js | 14 +- src/utils/zplUtil2.js | 59 ++ .../com_add_update_customer_label.vue | 2 +- .../com_add_update_default_label.vue | 2 +- .../labelSetting/com_add_update_label.vue | 26 +- src/views/modules/labelSetting/label_draw.vue | 244 ++++++-- .../modules/labelSetting/label_draw2.vue | 566 ++++++++++++++++++ .../modules/labelSetting/label_setting.vue | 25 +- 9 files changed, 880 insertions(+), 64 deletions(-) create mode 100644 src/utils/zplUtil2.js create mode 100644 src/views/modules/labelSetting/label_draw2.vue diff --git a/src/api/labelSetting/label_setting.js b/src/api/labelSetting/label_setting.js index ad8780f..de32150 100644 --- a/src/api/labelSetting/label_setting.js +++ b/src/api/labelSetting/label_setting.js @@ -5,3 +5,9 @@ export const getLabelSettingList = data => createAPI('/label/setting/getLabelSet // 删除标签的信息 export const deleteLabelSetting = data => createAPI('/label/setting/deleteLabelSetting','post',data) + +// 添加标签的信息 +export const saveZplElements = data => createAPI('/label/setting/saveZplElements','post',data) + +// 修改标签的信息 +export const getZplElements = data => createAPI('/label/setting/getZplElements','post',data) diff --git a/src/utils/zplUtil.js b/src/utils/zplUtil.js index 3deb558..a6b09e1 100644 --- a/src/utils/zplUtil.js +++ b/src/utils/zplUtil.js @@ -1,5 +1,6 @@ -export function generateZPL(elements) { +export function generateZPL(elements,zplHOrP) { const zpl = ['^XA']; + zpl.push(zplHOrP) elements.forEach(el => { const x = Math.round(el.x); const y = Math.round(el.y * 1.5); // 画布到 ZPL 像素转换 @@ -10,6 +11,17 @@ export function generateZPL(elements) { zpl.push(el.newline ? `^FO${x},${y}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` : `^FO${x},${y}^FD${el.data}^FS`); + if (el.bold) { + zpl.push(el.newline + ? `^FO${x+1},${y}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x+1},${y}^FD${el.data}^FS`); + zpl.push(el.newline + ? `^FO${x},${y+1}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x},${y+1}^FD${el.data}^FS`); + zpl.push(el.newline + ? `^FO${x+1},${y+1}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x+1},${y+1}^FD${el.data}^FS`); + } break; case 'barcode': diff --git a/src/utils/zplUtil2.js b/src/utils/zplUtil2.js new file mode 100644 index 0000000..09b0dc4 --- /dev/null +++ b/src/utils/zplUtil2.js @@ -0,0 +1,59 @@ +export function generateZPL(elements,zplHOrP) { + const zpl = ['^XA']; + //zpl.push('^POI'); + zpl.push(zplHOrP) + elements.forEach(el => { + const x = Math.round(el.y * 1.3); + const y = Math.round((750-el.x) * 1.5); // 你之前的转换比例保持不变 + + switch (el.type) { + case 'text': + zpl.push(`^CI28^LH0,^JUS^CWJ,E:SIMSUN.FNT^CFJ,${el.fontSize},${el.fontSize}`); + zpl.push(el.newline + ? `^FO${x},${y}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x},${y}^FD${el.data}^FS`); + if (el.bold) { + zpl.push(el.newline + ? `^FO${x+1},${y}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x+1},${y}^FD${el.data}^FS`); + zpl.push(el.newline + ? `^FO${x},${y+1}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x},${y+1}^FD${el.data}^FS`); + zpl.push(el.newline + ? `^FO${x+1},${y+1}^FB${el.lineWidth},${el.lineRows},0^CFJ,${el.fontSize}^FD${el.data}^FS` + : `^FO${x+1},${y+1}^FD${el.data}^FS`); + } + break; + + case 'barcode': + zpl.push(`^FO${x},${y}^BY${el.width}^BCB,${el.height},Y,N,N^FD${el.data}^FS`); + break; + + case 'qrcode': + zpl.push(`^FO${x},${y}^BQB,2,${el.height},^FDLA,${el.data}^FS`); + break; + + case 'onecode': + zpl.push(`^FO${x},${y}^BY${el.width}^BCB,${el.height},^FD${el.data}^FS`); + break; + + case 'pic': + if (el.data) { + zpl.push(`^FO${x},${y}^GFA,${el.data}`); + } + break; + + case 'hLine': + const y1 = Math.round(1200-el.x)-el.width; + zpl.push(`^FO${x},${y1}^FWR^GB${el.height},${el.width},3,B^FS`); + break; + case 'vLine': + zpl.push(`^FO${x},${y}^FWR^GB${el.height},${el.width},3,B^FS`); + break; + + + } + }); + zpl.push('^XZ'); + return zpl.join('\n'); +} diff --git a/src/views/modules/labelSetting/com_add_update_customer_label.vue b/src/views/modules/labelSetting/com_add_update_customer_label.vue index c612edd..1bbcc83 100644 --- a/src/views/modules/labelSetting/com_add_update_customer_label.vue +++ b/src/views/modules/labelSetting/com_add_update_customer_label.vue @@ -180,7 +180,7 @@ export default { //重置人员信息 this.pageData.username = this.userId; //判断是否启用多语言 - this.getMultiLanguageList(); + //this.getMultiLanguageList(); //重置标题 this.titleCon = this.labels.titleCon; }, diff --git a/src/views/modules/labelSetting/com_add_update_default_label.vue b/src/views/modules/labelSetting/com_add_update_default_label.vue index 15d9209..63a3138 100644 --- a/src/views/modules/labelSetting/com_add_update_default_label.vue +++ b/src/views/modules/labelSetting/com_add_update_default_label.vue @@ -156,7 +156,7 @@ export default { //重置是否需要检验 this.pageData.checkFlag = 'Y'; //判断是否启用多语言 - this.getMultiLanguageList(); + //this.getMultiLanguageList(); //重置标题 this.titleCon = this.labels.titleCon; }, diff --git a/src/views/modules/labelSetting/com_add_update_label.vue b/src/views/modules/labelSetting/com_add_update_label.vue index e02a757..ce42815 100644 --- a/src/views/modules/labelSetting/com_add_update_label.vue +++ b/src/views/modules/labelSetting/com_add_update_label.vue @@ -7,36 +7,40 @@ - + - + - - + + + + + + + + - + - + - - - + - + @@ -85,6 +89,7 @@ export default { labelClass: '', remark: '', addFlag: false, + printDirection : '横向打印', }, labelNoReadOnly: false, dataListLoading: false, @@ -104,6 +109,7 @@ export default { labelType: '标签类型:', labelName: '报表文件名:', labelClass: '标签种类:', + printDirection: '打印方向:', remark: '备注:', confirmLabel: '确认', cancelLabel: '取消', diff --git a/src/views/modules/labelSetting/label_draw.vue b/src/views/modules/labelSetting/label_draw.vue index b52d235..e5c552f 100644 --- a/src/views/modules/labelSetting/label_draw.vue +++ b/src/views/modules/labelSetting/label_draw.vue @@ -2,7 +2,13 @@
-

工具栏

+ + 显示网格 + 吸附到网格 + + + +

工具栏

     文本
@@ -21,7 +27,17 @@      竖线
-
+
+ +
+ 拖入组件开始设计 +
+
+ 属性以及预览区域 +
宽度高度等属性需遵循ZPL指令协议,比如:二维码最大高度是10,大于10不生效
-

属性配置

+

属性配置

-

- -

-



+ + 数据源 +

+ +

+ + + 文本宽度: +
-

- +

+
-

-

- + + 数据源

+

+
-

- + + 数据源

+
@@ -118,9 +143,15 @@
-
+
删除 - 保存 + 保存

+ + + + + + 预览

ZPL预览图 @@ -130,15 +161,35 @@
{{ generatedZPL }}
+ + + +
+ {{ key }} +
+
+ +
+ + 确定 + 关闭 + +
+ + diff --git a/src/views/modules/labelSetting/label_setting.vue b/src/views/modules/labelSetting/label_setting.vue index f5dd19f..8887c0e 100644 --- a/src/views/modules/labelSetting/label_setting.vue +++ b/src/views/modules/labelSetting/label_setting.vue @@ -51,13 +51,14 @@ fixed="left" header-align="center" align="center" - width="200" + width="280" :label=labels.operationLabel> @@ -173,11 +174,11 @@ export default { serialNumber: '100008001LabelLabelName', tableId: '100008001Label', tableName: '标签自定义列表', - columnProp: 'labelName', + columnProp: 'printDirection', headerAlign: 'center', align: 'center', - columnLabel: '报表文件名', - columnWidth: 220, + columnLabel: '打印方向', + columnWidth: 140, columnHidden: false, columnImage: false, columnSortable: true, @@ -257,6 +258,7 @@ export default { deleteLabel: '删除', printParameterLabel: '打印参数', printContentLabel: '标签内容定义', + printDrawLabel: '标签内容绘制', sureDeleteThisRecord: '确定要删除该记录吗?', tipsLabel: '提示', confirmLabel: '确定', @@ -359,12 +361,23 @@ export default { /*标签打印定义功能*/ labelContentModal(row){ let currentData = row; - //打开组件 去做修改业务 + //打开组件 去做修改业务 this.$nextTick(() => { this.$refs.comShowLabelContent.init(currentData); }) }, + labelDrawModal(row){ + let currentData = row; + if (currentData.printDirection === '横向打印') { + this.$router.push({ name: 'labelSetting-label_draw2', + params: {labelSetting: currentData}}) + } else { + this.$router.push({ name: 'labelSetting-label_draw', + params: {labelSetting: currentData}}) + } + }, + /* 设置选中行的参数 */ setCurrentRow(row, column, event) { this.currentRow = JSON.parse(JSON.stringify(row)) @@ -437,7 +450,7 @@ export default { //获取按钮的权限 this.getButtonAuthData(); //刷新页面的多语言信息 - this.getMultiLanguageList(); + //this.getMultiLanguageList(); }