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}
+