ce1cbf404c
后端: - fix(backend): InventoryLog 增加 Product/Warehouse 关联,Logs 接口加 Preload 修复流水记录显示"-" - feat(backend): 新增 /inventory/batches 批次追踪接口 - feat(backend): 新增财务记录、编号规则接口(finance、number_rule handler) - fix(backend): service/stock_test.go 修复 model.Date 类型错误 前端: - feat(client): 入库/出库管理 Tab 调换顺序(审核在前),审核 Tab 加新建按钮,列表 Tab 无按钮 - feat(client): 入库单/出库单增加详情弹窗,显示完整单据信息和商品明细 - feat(client): 完善出库单新建表单(StockOutFormScreen),支持选客户/仓库/商品 - fix(client): StockInItem/StockOutItem.fromJson 修复读取嵌套 product 对象而非平铺字段 - feat(client): 批次追踪页面(BatchTrackingScreen)及侧边栏入口 - feat(client): 财务管理、盘点、编号规则接入真实后端 API - fix(client): 入库/出库审核通过后 invalidate inventoryListProvider 刷新库存 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../core/api/api_client.dart';
|
|
import '../core/auth/auth_state.dart';
|
|
import '../core/models/page_result.dart';
|
|
import '../models/finance.dart';
|
|
import '../repositories/finance_repository.dart';
|
|
|
|
final financeRepositoryProvider = Provider<FinanceRepository>((ref) {
|
|
return FinanceRepository(ref.watch(apiClientProvider));
|
|
});
|
|
|
|
final financeListProvider =
|
|
AsyncNotifierProvider<FinanceListNotifier, PageResult<FinanceRecord>>(
|
|
FinanceListNotifier.new,
|
|
);
|
|
|
|
class FinanceListNotifier extends AsyncNotifier<PageResult<FinanceRecord>> {
|
|
int _page = 1;
|
|
String _type = '';
|
|
String _month = '';
|
|
|
|
@override
|
|
Future<PageResult<FinanceRecord>> build() {
|
|
ref.watch(authStateProvider.select((s) => s.user?.shopId));
|
|
return _fetch();
|
|
}
|
|
|
|
Future<PageResult<FinanceRecord>> _fetch() {
|
|
return ref.read(financeRepositoryProvider).listRecords(
|
|
type: _type.isEmpty ? null : _type,
|
|
month: _month.isEmpty ? null : _month,
|
|
page: _page,
|
|
);
|
|
}
|
|
|
|
void setType(String type) {
|
|
_type = type;
|
|
_page = 1;
|
|
reload();
|
|
}
|
|
|
|
void setMonth(String month) {
|
|
_month = month;
|
|
_page = 1;
|
|
reload();
|
|
}
|
|
|
|
void setPage(int page) {
|
|
_page = page;
|
|
reload();
|
|
}
|
|
|
|
void reload() {
|
|
state = const AsyncValue.loading();
|
|
_fetch().then(
|
|
(result) => state = AsyncValue.data(result),
|
|
onError: (e, st) => state = AsyncValue.error(e, st),
|
|
);
|
|
}
|
|
}
|