From ee826eca7ffc8983434880def0b0a6951b993300 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Tue, 26 May 2026 21:20:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(print):=20=E5=95=86=E5=93=81=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=94=B9=E4=B8=BA=E7=AB=96=E5=90=91=2020mm=C3=9738mm?= =?UTF-8?q?=20=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原设计 4in×2in 横向与实际标签纸不符,导致内容旋转 90°。按实测尺寸重设为竖向 20mm×38mm,重新排布:酒行名顶部深色背景→商品名→QR码→规格/批次/生产日期→联系方式底部。 Co-Authored-By: Claude Sonnet 4.6 --- client/lib/core/utils/print_util_web.dart | 156 ++++++++-------------- 1 file changed, 58 insertions(+), 98 deletions(-) diff --git a/client/lib/core/utils/print_util_web.dart b/client/lib/core/utils/print_util_web.dart index 5ea2955..42520bb 100644 --- a/client/lib/core/utils/print_util_web.dart +++ b/client/lib/core/utils/print_util_web.dart @@ -30,30 +30,16 @@ Future printProductLabelImpl({ }) async { final base64Img = base64Encode(qrBytes); - final specVal = (spec ?? '').isNotEmpty ? spec! : '—'; - final seriesVal = (series ?? '').isNotEmpty ? series! : '—'; - final batchVal = (batchNo ?? '').isNotEmpty ? batchNo! : '—'; - final dateVal = (productionDate ?? '').isNotEmpty + final specVal = (spec ?? '').isNotEmpty ? spec! : '—'; + final batchVal = (batchNo ?? '').isNotEmpty ? batchNo! : '—'; + final dateVal = (productionDate ?? '').isNotEmpty ? (productionDate!.length > 10 ? productionDate.substring(0, 10) : productionDate) : '—'; - final footerContact = [ - if (shopAddress.isNotEmpty) shopAddress, + final contactLine = [ if (shopPhone.isNotEmpty) shopPhone, - ].join(' · '); - - // 标签生成时间 - final now = DateTime.now(); - final genTime = - '${now.year}-${now.month.toString().padLeft(2,'0')}-${now.day.toString().padLeft(2,'0')}' - ' ${now.hour.toString().padLeft(2,'0')}:${now.minute.toString().padLeft(2,'0')}'; - - final remarkRow = (remark ?? '').isNotEmpty - ? '''
- 备 注 - $remark -
''' - : ''; + if (shopAddress.isNotEmpty) shopAddress, + ].join(' '); final html = ''' @@ -62,79 +48,71 @@ Future printProductLabelImpl({ @@ -143,41 +121,23 @@ body { width: 4in; height: 2in; overflow: hidden; background: #fff; }
$shopName - Certificate of Authenticity
-
-
-
$name
+
$name
-
- 规 格 - $specVal - 系 列 - $seriesVal -
- -
- 批 号 - $batchVal - 生产日期 - $dateVal -
- - $remarkRow -
- -
- -
扫码溯源 · TRACE
-
+
+ +
扫码溯源
-
- ${footerContact.isNotEmpty ? footerContact : shopName} - $genTime +
+
$specVal
+
$batchVal
+
$dateVal
+
${contactLine.isNotEmpty ? contactLine : shopName}
+