feat: 完成7项功能任务
后端: - 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>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../core/api/api_client.dart';
|
||||
import '../core/exceptions.dart';
|
||||
import '../core/models/page_result.dart';
|
||||
import '../models/finance.dart';
|
||||
|
||||
class FinanceRepository {
|
||||
final ApiClient _client;
|
||||
const FinanceRepository(this._client);
|
||||
|
||||
Future<PageResult<FinanceRecord>> listRecords({
|
||||
String? type,
|
||||
String? month,
|
||||
int page = 1,
|
||||
int pageSize = 50,
|
||||
}) async {
|
||||
try {
|
||||
final params = <String, dynamic>{
|
||||
'page': page,
|
||||
'page_size': pageSize,
|
||||
if (type != null && type.isNotEmpty) 'type': type,
|
||||
if (month != null && month.isNotEmpty) 'month': month,
|
||||
};
|
||||
final resp = await _client.get('/finance/records', params: params);
|
||||
return PageResult.fromJson(
|
||||
resp.data as Map<String, dynamic>,
|
||||
FinanceRecord.fromJson,
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
throw AppException(
|
||||
e.response?.data?['error'] as String? ?? '获取财务记录失败',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,44 @@ class InventoryRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> createCheck(Map<String, dynamic> data) async {
|
||||
try {
|
||||
final resp = await _client.post('/inventory/checks', data: data);
|
||||
return resp.data as Map<String, dynamic>;
|
||||
} on DioException catch (e) {
|
||||
throw AppException(
|
||||
e.response?.data?['error'] as String? ?? '提交盘点失败',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<PageResult<BatchRecord>> listBatches({
|
||||
int? productId,
|
||||
int? warehouseId,
|
||||
int page = 1,
|
||||
int pageSize = 20,
|
||||
}) async {
|
||||
try {
|
||||
final params = <String, dynamic>{
|
||||
'page': page,
|
||||
'page_size': pageSize,
|
||||
if (productId != null) 'product_id': productId,
|
||||
if (warehouseId != null) 'warehouse_id': warehouseId,
|
||||
};
|
||||
final resp = await _client.get('/inventory/batches', params: params);
|
||||
return PageResult.fromJson(
|
||||
resp.data as Map<String, dynamic>,
|
||||
BatchRecord.fromJson,
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
throw AppException(
|
||||
e.response?.data?['error'] as String? ?? '获取批次数据失败',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<PageResult<InventoryLog>> listLogs({
|
||||
int? warehouseId,
|
||||
int? productId,
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../core/api/api_client.dart';
|
||||
import '../core/exceptions.dart';
|
||||
import '../models/number_rule.dart';
|
||||
|
||||
class NumberRuleRepository {
|
||||
final ApiClient _client;
|
||||
const NumberRuleRepository(this._client);
|
||||
|
||||
Future<List<NumberRule>> list() async {
|
||||
try {
|
||||
final resp = await _client.get('/number-rules');
|
||||
final data = resp.data['data'] as List;
|
||||
return data
|
||||
.map((e) => NumberRule.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
} on DioException catch (e) {
|
||||
throw AppException(
|
||||
e.response?.data?['error'] as String? ?? '获取编号规则失败',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<NumberRule> update(int id, Map<String, dynamic> data) async {
|
||||
try {
|
||||
final resp = await _client.put('/number-rules/$id', data: data);
|
||||
return NumberRule.fromJson(resp.data['data'] as Map<String, dynamic>);
|
||||
} on DioException catch (e) {
|
||||
throw AppException(
|
||||
e.response?.data?['error'] as String? ?? '更新编号规则失败',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user