diff --git a/client/lib/screens/stock_in/stock_in_form_screen.dart b/client/lib/screens/stock_in/stock_in_form_screen.dart index 82789de..57bf413 100644 --- a/client/lib/screens/stock_in/stock_in_form_screen.dart +++ b/client/lib/screens/stock_in/stock_in_form_screen.dart @@ -27,7 +27,10 @@ import '../../widgets/ds/ds_toast.dart'; /// 明细为可键盘操作的内联网格(名称/系列/规格可搜索+新增,生产日期/批次/数量/单价/售价内联编辑)。 class StockInFormScreen extends ConsumerStatefulWidget { final int? editOrderId; - const StockInFormScreen({super.key, this.editOrderId}); + + /// 仅供 golden 测试钉死单据日期(默认 DateTime.now() 会让 golden 随日期漂移)。 + final DateTime? initialDate; + const StockInFormScreen({super.key, this.editOrderId, this.initialDate}); @override ConsumerState createState() => _StockInFormScreenState(); @@ -39,7 +42,7 @@ class _StockInFormScreenState extends ConsumerState { final _warehouseFocus = FocusNode(); int? _warehouseId; int? _partnerId; - DateTime _orderDate = DateTime.now(); + late DateTime _orderDate = widget.initialDate ?? DateTime.now(); bool _submitting = false; bool _loadingEdit = false; StockInOrder? _loadedOrder; diff --git a/client/lib/screens/stock_out/stock_out_form_screen.dart b/client/lib/screens/stock_out/stock_out_form_screen.dart index 2bf55cc..b53bdf4 100644 --- a/client/lib/screens/stock_out/stock_out_form_screen.dart +++ b/client/lib/screens/stock_out/stock_out_form_screen.dart @@ -142,7 +142,10 @@ class _ItemRow { /// 明细行经「从库存批量选择」添加,商品/系列/规格/可用只读,仅数量、售价可内联编辑。 class StockOutFormScreen extends ConsumerStatefulWidget { final int? editOrderId; - const StockOutFormScreen({super.key, this.editOrderId}); + + /// 仅供 golden 测试钉死单据日期(默认 DateTime.now() 会让 golden 随日期漂移)。 + final DateTime? initialDate; + const StockOutFormScreen({super.key, this.editOrderId, this.initialDate}); @override ConsumerState createState() => _StockOutFormScreenState(); @@ -154,7 +157,7 @@ class _StockOutFormScreenState extends ConsumerState { final _warehouseFocus = FocusNode(); int? _warehouseId; int? _partnerId; - DateTime _orderDate = DateTime.now(); + late DateTime _orderDate = widget.initialDate ?? DateTime.now(); bool _submitting = false; bool _loadingEdit = false; Map _inventoryMap = {}; diff --git a/client/test/golden/stock_in_form_golden_test.dart b/client/test/golden/stock_in_form_golden_test.dart index 3af73a0..b5579db 100644 --- a/client/test/golden/stock_in_form_golden_test.dart +++ b/client/test/golden/stock_in_form_golden_test.dart @@ -73,7 +73,7 @@ void main() { goldenAcrossThemes( 'stock-in form 录单(桌面)', goldenPrefix: 'stock_in_form', - child: () => const Scaffold(body: StockInFormScreen()), + child: () => Scaffold(body: StockInFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(1280, 920), ); @@ -81,7 +81,7 @@ void main() { goldenAcrossThemes( 'stock-in form 录单(移动)', goldenPrefix: 'stock_in_form_mobile', - child: () => const Scaffold(body: StockInFormScreen()), + child: () => Scaffold(body: StockInFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(390, 1400), ); diff --git a/client/test/golden/stock_out_form_golden_test.dart b/client/test/golden/stock_out_form_golden_test.dart index 12e199a..434641c 100644 --- a/client/test/golden/stock_out_form_golden_test.dart +++ b/client/test/golden/stock_out_form_golden_test.dart @@ -53,7 +53,7 @@ void main() { goldenAcrossThemes( 'stock-out form 录单(桌面)', goldenPrefix: 'stock_out_form', - child: () => const Scaffold(body: StockOutFormScreen()), + child: () => Scaffold(body: StockOutFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(1280, 920), ); @@ -61,7 +61,7 @@ void main() { goldenAcrossThemes( 'stock-out form 录单(移动)', goldenPrefix: 'stock_out_form_mobile', - child: () => const Scaffold(body: StockOutFormScreen()), + child: () => Scaffold(body: StockOutFormScreen(initialDate: DateTime(2026, 7, 4))), overrides: _overrides, logical: const Size(390, 1400), );