4.7更改打印标签代码,去掉序列号以及批号

This commit is contained in:
dxc
2026-04-07 16:11:04 +08:00
parent ed081b3e21
commit 875de73a3a
2 changed files with 4 additions and 28 deletions

View File

@ -133,7 +133,7 @@ class LabelPrintService:
| [QR Code] (15mm) | 名: XXXXXX | | [QR Code] (15mm) | 名: XXXXXX |
| | 规: XXXXXX | | | 规: XXXXXX |
| SKU: XXXXX(大/粗)| 属: XXXXXX | | SKU: XXXXX(大/粗)| 属: XXXXXX |
| 库: XXXXX (中/粗)| SN: XXXXXX | | 库: XXXXX (中/粗)| |
--------------------------------------- ---------------------------------------
""" """
# 1. 创建画布 # 1. 创建画布
@ -157,24 +157,6 @@ class LabelPrintService:
typ = str(data.get('material_type', '') or '') typ = str(data.get('material_type', '') or '')
attr = f"{cat}/{typ}" if (cat or typ) else "-" attr = f"{cat}/{typ}" if (cat or typ) else "-"
# 底部编号逻辑
bottom_val = ""
bottom_label = "NO"
if data.get('print_no'):
bottom_val = str(data.get('print_no'))
l_type = data.get('print_label', '')
bottom_label = 'SN' if l_type == '' else 'BN' if l_type == '' else 'NO'
elif data.get('serial_number'):
bottom_label = "SN"
bottom_val = str(data.get('serial_number'))
elif data.get('batch_number'):
bottom_label = "BN"
bottom_val = str(data.get('batch_number'))
else:
bottom_val = sku_code
bottom_text_full = f"{bottom_label}:{bottom_val}"
# ==================== 绘制区域划分 ==================== # ==================== 绘制区域划分 ====================
# --- A. 左侧区域 (二维码 + SKU + 库位) --- # --- A. 左侧区域 (二维码 + SKU + 库位) ---
@ -223,7 +205,7 @@ class LabelPrintService:
stroke_fill='black' stroke_fill='black'
) )
# --- B. 右侧区域 (名称、规格、属性、编号) --- # --- B. 右侧区域 (名称、规格、属性) ---
# 右侧起始 X # 右侧起始 X
right_start_x = LabelPrintService.MARGIN_LEFT + LabelPrintService.QR_SIZE_PX + LabelPrintService.GAP_COLUMNS right_start_x = LabelPrintService.MARGIN_LEFT + LabelPrintService.QR_SIZE_PX + LabelPrintService.GAP_COLUMNS
@ -251,12 +233,6 @@ class LabelPrintService:
current_right_y = LabelPrintService.draw_text_wrap( current_right_y = LabelPrintService.draw_text_wrap(
d, f"属:{attr}", right_start_x, current_right_y, font_text, right_max_width, line_spacing=LINE_SPACING d, f"属:{attr}", right_start_x, current_right_y, font_text, right_max_width, line_spacing=LINE_SPACING
) )
current_right_y += LINE_SPACING
# 4. 序列号/批号
LabelPrintService.draw_text_wrap(
d, bottom_text_full, right_start_x, current_right_y, font_text, right_max_width, line_spacing=LINE_SPACING
)
return img return img

View File

@ -1,6 +1,6 @@
{ {
"label_printer": { "label_printer": {
"ip": "192.168.9.14", "ip": "192.168.9.78",
"port": 9100 "port": 9100
}, },
"network_printer": { "network_printer": {