From 53a52cc53060e980781d6eb47acbbac071eb5032 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Fri, 5 Jun 2026 20:05:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(client):=20=E6=89=93=E5=8D=B0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E9=BB=98=E8=AE=A4=E5=90=8D=20=E7=B1=BB=E5=9E=8B=5F?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=EF=BC=88=E6=A0=87=E7=AD=BE/?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95/=E5=87=BA=E5=BA=93=E5=8D=95?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Printing.layoutPdf 传 name:标签_yyyyMMdd_HHmmss / 入库单_... / 出库单_..., 作为打印任务名与「打印到 PDF」的默认文件名。 Co-Authored-By: Claude Opus 4.8 --- client/lib/core/utils/print_util_stub.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/lib/core/utils/print_util_stub.dart b/client/lib/core/utils/print_util_stub.dart index 9bc42bb..dbff37c 100644 --- a/client/lib/core/utils/print_util_stub.dart +++ b/client/lib/core/utils/print_util_stub.dart @@ -17,6 +17,13 @@ Future _loadBoldFont() async { return pw.Font.ttf(data); } +/// 打印任务/另存默认文件名的时间戳:yyyyMMdd_HHmmss +String _fileTs() { + final n = DateTime.now(); + String p(int v) => v.toString().padLeft(2, '0'); + return '${n.year}${p(n.month)}${p(n.day)}_${p(n.hour)}${p(n.minute)}${p(n.second)}'; +} + // ── 设计色彩 token ────────────────────────────────────────────────────────── const _navy = PdfColor(0.122, 0.165, 0.227); // #1F2A3A header/chip const _cream = PdfColor(0.957, 0.925, 0.847); // #F4ECD8 footer/reversed text @@ -191,7 +198,8 @@ Future printProductLabelImpl({ ), )); - await Printing.layoutPdf(onLayout: (_) async => doc.save()); + await Printing.layoutPdf( + name: '标签_${_fileTs()}', onLayout: (_) async => doc.save()); } catch (e, st) { reportError(e, st); throw Exception('打印失败,请检查打印机连接和驱动是否正常。\n详情:$e'); @@ -431,7 +439,8 @@ Future printStockInOrderImpl(StockInOrder order) async { ), ], )); - await Printing.layoutPdf(onLayout: (_) async => doc.save()); + await Printing.layoutPdf( + name: '入库单_${_fileTs()}', onLayout: (_) async => doc.save()); } catch (e, st) { reportError(e, st); throw Exception('打印失败,请检查打印机连接和驱动是否正常。\n详情:$e'); @@ -486,7 +495,8 @@ Future printStockOutOrderImpl(StockOutOrder order) async { ], )); try { - await Printing.layoutPdf(onLayout: (_) async => doc.save()); + await Printing.layoutPdf( + name: '出库单_${_fileTs()}', onLayout: (_) async => doc.save()); } catch (e, st) { reportError(e, st); throw Exception('打印失败,请检查打印机连接和驱动是否正常。\n详情:$e');