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>
148 lines
4.5 KiB
Dart
148 lines
4.5 KiB
Dart
class Inventory {
|
|
final int warehouseId;
|
|
final String? warehouseName;
|
|
final int productId;
|
|
final String? productName;
|
|
final String? productCode;
|
|
final String? productSpec;
|
|
final String? productUnit;
|
|
final String? productBrand;
|
|
final int? minStock;
|
|
final double quantity;
|
|
|
|
const Inventory({
|
|
required this.warehouseId,
|
|
this.warehouseName,
|
|
required this.productId,
|
|
this.productName,
|
|
this.productCode,
|
|
this.productSpec,
|
|
this.productUnit,
|
|
this.productBrand,
|
|
this.minStock,
|
|
required this.quantity,
|
|
});
|
|
|
|
factory Inventory.fromJson(Map<String, dynamic> json) {
|
|
final warehouse = json['warehouse'] as Map<String, dynamic>?;
|
|
final product = json['product'] as Map<String, dynamic>?;
|
|
return Inventory(
|
|
warehouseId: (json['warehouse_id'] as num).toInt(),
|
|
warehouseName: warehouse?['name'] as String?,
|
|
productId: (json['product_id'] as num).toInt(),
|
|
productName: product?['name'] as String?,
|
|
productCode: product?['code'] as String?,
|
|
productSpec: product?['spec'] as String?,
|
|
productUnit: product?['unit'] as String?,
|
|
productBrand: product?['brand'] as String?,
|
|
minStock: product?['min_stock'] != null
|
|
? (product!['min_stock'] as num).toInt()
|
|
: null,
|
|
quantity: (json['quantity'] as num).toDouble(),
|
|
);
|
|
}
|
|
}
|
|
|
|
// 批次追踪:已审核入库单的明细行
|
|
class BatchRecord {
|
|
final int id;
|
|
final int productId;
|
|
final String? productName;
|
|
final String? productCode;
|
|
final String? productSpec;
|
|
final String? productUnit;
|
|
final String? batchNo;
|
|
final double quantity;
|
|
final double unitPrice;
|
|
final String? orderNo;
|
|
final String? orderDate;
|
|
final String? warehouseName;
|
|
final String? supplierName;
|
|
|
|
const BatchRecord({
|
|
required this.id,
|
|
required this.productId,
|
|
this.productName,
|
|
this.productCode,
|
|
this.productSpec,
|
|
this.productUnit,
|
|
this.batchNo,
|
|
required this.quantity,
|
|
required this.unitPrice,
|
|
this.orderNo,
|
|
this.orderDate,
|
|
this.warehouseName,
|
|
this.supplierName,
|
|
});
|
|
|
|
factory BatchRecord.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(
|
|
id: (json['id'] as num).toInt(),
|
|
productId: (json['product_id'] as num).toInt(),
|
|
productName: product?['name'] as String?,
|
|
productCode: product?['code'] as String?,
|
|
productSpec: product?['spec'] as String?,
|
|
productUnit: product?['unit'] as String?,
|
|
batchNo: json['batch_no'] as String?,
|
|
quantity: (json['quantity'] as num).toDouble(),
|
|
unitPrice: (json['unit_price'] as num).toDouble(),
|
|
orderNo: order?['order_no'] as String?,
|
|
orderDate: order?['order_date'] as String?,
|
|
warehouseName: warehouse?['name'] as String?,
|
|
supplierName: partner?['name'] as String?,
|
|
);
|
|
}
|
|
}
|
|
|
|
class InventoryLog {
|
|
final int warehouseId;
|
|
final String? warehouseName;
|
|
final int productId;
|
|
final String? productName;
|
|
final String direction; // in | out
|
|
final double quantity;
|
|
final double? qtyBefore;
|
|
final double? qtyAfter;
|
|
final String? refType;
|
|
final int? refId;
|
|
final String? createdAt;
|
|
|
|
const InventoryLog({
|
|
required this.warehouseId,
|
|
this.warehouseName,
|
|
required this.productId,
|
|
this.productName,
|
|
required this.direction,
|
|
required this.quantity,
|
|
this.qtyBefore,
|
|
this.qtyAfter,
|
|
this.refType,
|
|
this.refId,
|
|
this.createdAt,
|
|
});
|
|
|
|
factory InventoryLog.fromJson(Map<String, dynamic> json) => InventoryLog(
|
|
warehouseId: (json['warehouse_id'] as num).toInt(),
|
|
warehouseName: (json['warehouse'] as Map<String, dynamic>?)?['name'] as String?,
|
|
productId: (json['product_id'] as num).toInt(),
|
|
productName: (json['product'] as Map<String, dynamic>?)?['name'] as String?,
|
|
direction: json['direction'] as String,
|
|
quantity: (json['quantity'] as num).toDouble(),
|
|
qtyBefore: json['qty_before'] != null
|
|
? (json['qty_before'] as num).toDouble()
|
|
: null,
|
|
qtyAfter: json['qty_after'] != null
|
|
? (json['qty_after'] as num).toDouble()
|
|
: null,
|
|
refType: json['ref_type'] as String?,
|
|
refId: json['ref_id'] != null
|
|
? (json['ref_id'] as num).toInt()
|
|
: null,
|
|
createdAt: json['created_at'] as String?,
|
|
);
|
|
}
|