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,52 @@
|
||||
class FinanceRecord {
|
||||
final int id;
|
||||
final String type; // receivable | payable | receipt | payment
|
||||
final double amount;
|
||||
final double balance;
|
||||
final String? refType;
|
||||
final int? refId;
|
||||
final String? partnerName;
|
||||
final String? recordDate;
|
||||
final String? remark;
|
||||
|
||||
const FinanceRecord({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.amount,
|
||||
required this.balance,
|
||||
this.refType,
|
||||
this.refId,
|
||||
this.partnerName,
|
||||
this.recordDate,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
String get typeLabel {
|
||||
switch (type) {
|
||||
case 'receivable':
|
||||
return '应收账款';
|
||||
case 'payable':
|
||||
return '应付账款';
|
||||
case 'receipt':
|
||||
return '收款';
|
||||
case 'payment':
|
||||
return '付款';
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
factory FinanceRecord.fromJson(Map<String, dynamic> json) => FinanceRecord(
|
||||
id: (json['id'] as num).toInt(),
|
||||
type: json['type'] as String,
|
||||
amount: (json['amount'] as num).toDouble(),
|
||||
balance: (json['balance'] as num).toDouble(),
|
||||
refType: json['ref_type'] as String?,
|
||||
refId:
|
||||
json['ref_id'] != null ? (json['ref_id'] as num).toInt() : null,
|
||||
partnerName:
|
||||
(json['partner'] as Map<String, dynamic>?)?['name'] as String?,
|
||||
recordDate: json['record_date'] as String?,
|
||||
remark: json['remark'] as String?,
|
||||
);
|
||||
}
|
||||
@@ -43,6 +43,61 @@ class Inventory {
|
||||
}
|
||||
}
|
||||
|
||||
// 批次追踪:已审核入库单的明细行
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
class NumberRule {
|
||||
final int id;
|
||||
final String type;
|
||||
final String prefix;
|
||||
final int currentNo;
|
||||
final String dateFormat;
|
||||
|
||||
const NumberRule({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.prefix,
|
||||
required this.currentNo,
|
||||
required this.dateFormat,
|
||||
});
|
||||
|
||||
String get typeLabel {
|
||||
switch (type) {
|
||||
case 'stock_in':
|
||||
return '入库单';
|
||||
case 'stock_out':
|
||||
return '出库单';
|
||||
case 'inventory_check':
|
||||
return '盘点单';
|
||||
case 'product':
|
||||
return '商品编码';
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
String get exampleNo {
|
||||
final now = DateTime.now();
|
||||
final date = '${now.year}${now.month.toString().padLeft(2, '0')}${now.day.toString().padLeft(2, '0')}';
|
||||
return '$prefix$date${(currentNo + 1).toString().padLeft(3, '0')}';
|
||||
}
|
||||
|
||||
factory NumberRule.fromJson(Map<String, dynamic> json) => NumberRule(
|
||||
id: (json['id'] as num).toInt(),
|
||||
type: json['type'] as String,
|
||||
prefix: json['prefix'] as String? ?? '',
|
||||
currentNo: (json['current_no'] as num).toInt(),
|
||||
dateFormat: json['date_format'] as String? ?? 'YYYYMMDD',
|
||||
);
|
||||
}
|
||||
@@ -33,10 +33,10 @@ class StockInItem {
|
||||
unitPrice: (json['unit_price'] as num).toDouble(),
|
||||
totalPrice: (json['total_price'] as num).toDouble(),
|
||||
batchNo: json['batch_no'] as String?,
|
||||
productName: json['product_name'] as String?,
|
||||
productCode: json['product_code'] as String?,
|
||||
productSpec: json['product_spec'] as String?,
|
||||
productUnit: json['product_unit'] as String?,
|
||||
productName: (json['product'] as Map<String, dynamic>?)?['name'] as String?,
|
||||
productCode: (json['product'] as Map<String, dynamic>?)?['code'] as String?,
|
||||
productSpec: (json['product'] as Map<String, dynamic>?)?['spec'] as String?,
|
||||
productUnit: (json['product'] as Map<String, dynamic>?)?['unit'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
||||
@@ -29,10 +29,10 @@ class StockOutItem {
|
||||
quantity: (json['quantity'] as num).toDouble(),
|
||||
unitPrice: (json['unit_price'] as num).toDouble(),
|
||||
totalPrice: (json['total_price'] as num).toDouble(),
|
||||
productName: json['product_name'] as String?,
|
||||
productCode: json['product_code'] as String?,
|
||||
productSpec: json['product_spec'] as String?,
|
||||
productUnit: json['product_unit'] as String?,
|
||||
productName: (json['product'] as Map<String, dynamic>?)?['name'] as String?,
|
||||
productCode: (json['product'] as Map<String, dynamic>?)?['code'] as String?,
|
||||
productSpec: (json['product'] as Map<String, dynamic>?)?['spec'] as String?,
|
||||
productUnit: (json['product'] as Map<String, dynamic>?)?['unit'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user