5187702fc5
Deploy Client / build-client-web (push) Successful in 47s
Deploy Client / build-windows (push) Successful in 1m56s
Deploy Client / build-macos (push) Successful in 2m15s
Deploy Client / build-android (push) Successful in 1m20s
Deploy Client / build-ios (push) Successful in 2m47s
Deploy Client / release-deploy-client (push) Successful in 1m51s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
78 lines
2.5 KiB
Dart
78 lines
2.5 KiB
Dart
import 'dart:typed_data';
|
|
import 'package:flutter/material.dart';
|
|
import '../../models/stock_in.dart';
|
|
import '../../models/stock_out.dart';
|
|
import '../errors/error_reporter.dart';
|
|
import 'label_data.dart';
|
|
export 'label_data.dart';
|
|
import 'print_util_stub.dart'
|
|
if (dart.library.js_interop) 'print_util_web.dart';
|
|
|
|
Future<void> printProductLabel({
|
|
required Uint8List qrBytes,
|
|
required String name,
|
|
required String code,
|
|
String? spec,
|
|
String? series,
|
|
String? batchNo,
|
|
String? productionDate,
|
|
String? remark,
|
|
String shopName = '',
|
|
String shopAddress = '',
|
|
String shopPhone = '',
|
|
String? printerName,
|
|
}) =>
|
|
printProductLabelImpl(
|
|
qrBytes: qrBytes,
|
|
name: name,
|
|
code: code,
|
|
spec: spec,
|
|
series: series,
|
|
batchNo: batchNo,
|
|
productionDate: productionDate,
|
|
remark: remark,
|
|
shopName: shopName,
|
|
shopAddress: shopAddress,
|
|
shopPhone: shopPhone,
|
|
printerName: printerName,
|
|
);
|
|
|
|
/// 渲染标签预览图(PNG 字节);Web 平台返回 null。
|
|
Future<Uint8List?> renderLabelPreview(LabelData label) =>
|
|
renderLabelPreviewImpl(label);
|
|
|
|
/// 枚举当前系统所有可用打印机名;Web 平台返回空列表。
|
|
Future<List<String>> listLabelPrinters() => listLabelPrintersImpl();
|
|
|
|
/// 自动检测默认热敏打印机(名字含 deli/dl-888);找不到或 Web 返回 null。
|
|
Future<String?> detectDefaultPrinter() => detectDefaultPrinterImpl();
|
|
|
|
Future<void> printStockInOrder(StockInOrder order) =>
|
|
printStockInOrderImpl(order);
|
|
|
|
Future<void> printStockOutOrder(StockOutOrder order) =>
|
|
printStockOutOrderImpl(order);
|
|
|
|
/// 生成入库单 PDF 字节(桌面端真实排版,供打印预览光栅化用);Web 端不支持。
|
|
Future<Uint8List> buildStockInOrderPdf(StockInOrder order) =>
|
|
buildStockInOrderPdfImpl(order);
|
|
|
|
/// 生成出库单 PDF 字节(桌面端真实排版,供打印预览光栅化用);Web 端不支持。
|
|
Future<Uint8List> buildStockOutOrderPdf(StockOutOrder order) =>
|
|
buildStockOutOrderPdfImpl(order);
|
|
|
|
/// 统一打印入口:catch 任意异常,上报并弹 SnackBar 给用户。
|
|
/// 用法:await safePrint(context, () => printStockInOrder(order));
|
|
Future<void> safePrint(BuildContext context, Future<void> Function() fn) async {
|
|
try {
|
|
await fn();
|
|
} catch (e, st) {
|
|
reportError(e, st);
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text('打印失败:$e'), backgroundColor: Colors.red),
|
|
);
|
|
}
|
|
}
|
|
}
|