feat: 商品追踪页面 + 出库提交库存校验
后端: - feat(backend): 重命名 Batches→Products 接口,新增库存状态(在售/已卖出)和买家信息 - feat(backend): 出库单创建/提交时校验仓库库存,不足则返回明确错误信息 - fix(backend): 出库创建 status 判断逻辑修复(空值默认 draft) 前端: - feat(client): 批次追踪改为商品追踪,新增状态列(在售/已卖出)和买家/时间列 - fix(client): 无批次号时显示"无批次"而非空 - refactor(client): BatchRecord → ProductTrackingRecord,repository 接口更新 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,8 +43,8 @@ class Inventory {
|
||||
}
|
||||
}
|
||||
|
||||
// 批次追踪:已审核入库单的明细行
|
||||
class BatchRecord {
|
||||
// 商品追踪:已审核入库单的明细行,含库存状态和买家信息
|
||||
class ProductTrackingRecord {
|
||||
final int id;
|
||||
final int productId;
|
||||
final String? productName;
|
||||
@@ -58,8 +58,13 @@ class BatchRecord {
|
||||
final String? orderDate;
|
||||
final String? warehouseName;
|
||||
final String? supplierName;
|
||||
// 库存状态
|
||||
final double currentQty;
|
||||
final String status; // in_stock | sold_out
|
||||
final String? buyerName;
|
||||
final String? soldAt;
|
||||
|
||||
const BatchRecord({
|
||||
const ProductTrackingRecord({
|
||||
required this.id,
|
||||
required this.productId,
|
||||
this.productName,
|
||||
@@ -73,14 +78,20 @@ class BatchRecord {
|
||||
this.orderDate,
|
||||
this.warehouseName,
|
||||
this.supplierName,
|
||||
required this.currentQty,
|
||||
required this.status,
|
||||
this.buyerName,
|
||||
this.soldAt,
|
||||
});
|
||||
|
||||
factory BatchRecord.fromJson(Map<String, dynamic> json) {
|
||||
bool get isSoldOut => status == 'sold_out';
|
||||
|
||||
factory ProductTrackingRecord.fromJson(Map<String, dynamic> json) {
|
||||
final product = json['product'] as Map<String, dynamic>?;
|
||||
final order = json['order'] as Map<String, dynamic>?;
|
||||
final warehouse = order?['warehouse'] as Map<String, dynamic>?;
|
||||
final partner = order?['partner'] as Map<String, dynamic>?;
|
||||
return BatchRecord(
|
||||
return ProductTrackingRecord(
|
||||
id: (json['id'] as num).toInt(),
|
||||
productId: (json['product_id'] as num).toInt(),
|
||||
productName: product?['name'] as String?,
|
||||
@@ -94,6 +105,12 @@ class BatchRecord {
|
||||
orderDate: order?['order_date'] as String?,
|
||||
warehouseName: warehouse?['name'] as String?,
|
||||
supplierName: partner?['name'] as String?,
|
||||
currentQty: json['current_qty'] != null
|
||||
? (json['current_qty'] as num).toDouble()
|
||||
: 0,
|
||||
status: json['status'] as String? ?? 'in_stock',
|
||||
buyerName: json['buyer_name'] as String?,
|
||||
soldAt: json['sold_at'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user