eac3e8825c
- 库存查询加规格、系列服务端筛选(后端 IN 条件,前端从 product-options API 加载全量选项) - 库存查询新增「入库时间」列,导出 Excel 同步带上 - 入库单商品明细:隐藏商品编码列,生产日期从选填折叠区移至主行常显 - 筛选弹窗重构:顶部搜索框实时过滤 + 滚动列表(ConstrainedBox maxHeight)根治溢出 - 已选项以 Chip 标签置顶展示,每个标签带 × 可单独取消 - FilterableColumnHeader 筛选图标改为常驻,不再需要 hover 才显示 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
91 lines
2.7 KiB
Dart
91 lines
2.7 KiB
Dart
import 'package:dio/dio.dart';
|
|
import '../core/api/api_client.dart';
|
|
import '../core/exceptions.dart';
|
|
import '../core/models/page_result.dart';
|
|
import '../models/inventory.dart';
|
|
|
|
class InventoryRepository {
|
|
final ApiClient _client;
|
|
|
|
const InventoryRepository(this._client);
|
|
|
|
Future<PageResult<Inventory>> listInventory({
|
|
int? warehouseId,
|
|
String? keyword,
|
|
List<String>? series,
|
|
List<String>? spec,
|
|
int page = 1,
|
|
int pageSize = 50,
|
|
}) async {
|
|
try {
|
|
final params = <String, dynamic>{
|
|
'page': page,
|
|
'page_size': pageSize,
|
|
if (warehouseId != null) 'warehouse_id': warehouseId,
|
|
if (keyword != null && keyword.isNotEmpty) 'keyword': keyword,
|
|
if (series != null && series.isNotEmpty) 'series': series.join(','),
|
|
if (spec != null && spec.isNotEmpty) 'spec': spec.join(','),
|
|
};
|
|
final resp = await _client.get('/inventory', params: params);
|
|
return PageResult.fromJson(
|
|
resp.data as Map<String, dynamic>,
|
|
Inventory.fromJson,
|
|
);
|
|
} on DioException catch (e) {
|
|
throw AppException(
|
|
e.response?.data?['error'] as String? ?? '获取库存失败',
|
|
statusCode: e.response?.statusCode,
|
|
);
|
|
}
|
|
}
|
|
|
|
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<void> updateRemark(int id, String remark) async {
|
|
try {
|
|
await _client.put('/inventory/$id/remark', data: {'remark': remark});
|
|
} on DioException catch (e) {
|
|
throw AppException(
|
|
e.response?.data?['error'] as String? ?? '更新备注失败',
|
|
statusCode: e.response?.statusCode,
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<PageResult<InventoryLog>> listLogs({
|
|
int? warehouseId,
|
|
int? productId,
|
|
int page = 1,
|
|
int pageSize = 50,
|
|
}) async {
|
|
try {
|
|
final params = <String, dynamic>{
|
|
'page': page,
|
|
'page_size': pageSize,
|
|
if (warehouseId != null) 'warehouse_id': warehouseId,
|
|
if (productId != null) 'product_id': productId,
|
|
};
|
|
final resp = await _client.get('/inventory/logs', params: params);
|
|
return PageResult.fromJson(
|
|
resp.data as Map<String, dynamic>,
|
|
InventoryLog.fromJson,
|
|
);
|
|
} on DioException catch (e) {
|
|
throw AppException(
|
|
e.response?.data?['error'] as String? ?? '获取流水失败',
|
|
statusCode: e.response?.statusCode,
|
|
);
|
|
}
|
|
}
|
|
}
|