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');