feat: 商品详情页、XLS导入修复、分页选择器、导出功能
后端: - 新增 product_images 表,支持每商品最多5张图(服务端压缩至1200px/JPEG85%) - products 表新增 public_id(UUID)、description 字段 - 新增商品详情接口、二维码接口、公开商品接口(无鉴权) - 修复 XLS 导入:OLE2 magic bytes 检测 + 临时文件解析,兼容 extrame/xls - 修复商品/名称/系列/规格三张表导入数据为0(LastCol()=0 bug) - 所有导入接口返回 total/imported/skipped 统计 - config 新增 StorageConfig,支持 STORAGE_* 环境变量覆盖 - 种子数据修复:products 补 public_id、新增 product_images TRUNCATE、schema.sql 表名修正 前端: - 商品详情页:图片上传/删除、描述内联编辑、二维码弹窗、公开链接复制 - 公开商品页:无鉴权路由 /product/:public_id,Flutter Web SPA - 商品详情列表(批次追踪)商品名超链接跳转详情页 - 导航「商品管理」改名「商品详情」 - 所有列表表格新增每页条数选择(10/20/50/100) - 表格列头内嵌筛选(FilterableColumnHeader) - 导出 Excel 功能(入库/出库/库存/财务/批次/往来单位) - 网络恢复自动刷新 + 离线缓存展示 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ class Partner {
|
||||
final String? phone;
|
||||
final String? address;
|
||||
final String? bankAccount;
|
||||
final String status;
|
||||
final String? remark;
|
||||
|
||||
const Partner({
|
||||
@@ -18,6 +19,7 @@ class Partner {
|
||||
this.phone,
|
||||
this.address,
|
||||
this.bankAccount,
|
||||
this.status = 'enabled',
|
||||
this.remark,
|
||||
});
|
||||
|
||||
@@ -30,6 +32,7 @@ class Partner {
|
||||
phone: json['phone'] as String?,
|
||||
address: json['address'] as String?,
|
||||
bankAccount: json['bank_account'] as String?,
|
||||
status: json['status'] as String? ?? 'enabled',
|
||||
remark: json['remark'] as String?,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import 'product_image.dart';
|
||||
|
||||
class Product {
|
||||
final int id;
|
||||
final String publicId;
|
||||
final String code;
|
||||
final String? barcode;
|
||||
final String name;
|
||||
@@ -11,11 +14,14 @@ class Product {
|
||||
final double? purchasePrice;
|
||||
final double? salePrice;
|
||||
final int? minStock;
|
||||
final String? description;
|
||||
final String? remark;
|
||||
final Map<String, dynamic>? customFields;
|
||||
final List<ProductImage> images;
|
||||
|
||||
const Product({
|
||||
required this.id,
|
||||
this.publicId = '',
|
||||
required this.code,
|
||||
this.barcode,
|
||||
required this.name,
|
||||
@@ -27,12 +33,15 @@ class Product {
|
||||
this.purchasePrice,
|
||||
this.salePrice,
|
||||
this.minStock,
|
||||
this.description,
|
||||
this.remark,
|
||||
this.customFields,
|
||||
this.images = const [],
|
||||
});
|
||||
|
||||
factory Product.fromJson(Map<String, dynamic> json) => Product(
|
||||
id: (json['id'] as num).toInt(),
|
||||
publicId: json['public_id'] as String? ?? '',
|
||||
code: json['code'] as String? ?? '',
|
||||
barcode: json['barcode'] as String?,
|
||||
name: json['name'] as String,
|
||||
@@ -52,8 +61,13 @@ class Product {
|
||||
minStock: json['min_stock'] != null
|
||||
? (json['min_stock'] as num).toInt()
|
||||
: null,
|
||||
description: json['description'] as String?,
|
||||
remark: json['remark'] as String?,
|
||||
customFields: json['custom_fields'] as Map<String, dynamic>?,
|
||||
images: (json['images'] as List<dynamic>?)
|
||||
?.map((e) => ProductImage.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
@@ -68,6 +82,7 @@ class Product {
|
||||
if (purchasePrice != null) 'purchase_price': purchasePrice,
|
||||
if (salePrice != null) 'sale_price': salePrice,
|
||||
if (minStock != null) 'min_stock': minStock,
|
||||
'description': description ?? '',
|
||||
if (remark != null) 'remark': remark,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
class ProductImage {
|
||||
final int id;
|
||||
final int productId;
|
||||
final String url;
|
||||
final int sortOrder;
|
||||
|
||||
const ProductImage({
|
||||
required this.id,
|
||||
required this.productId,
|
||||
required this.url,
|
||||
required this.sortOrder,
|
||||
});
|
||||
|
||||
factory ProductImage.fromJson(Map<String, dynamic> json) => ProductImage(
|
||||
id: (json['id'] as num).toInt(),
|
||||
productId: (json['product_id'] as num).toInt(),
|
||||
url: json['url'] as String,
|
||||
sortOrder: (json['sort_order'] as num? ?? 0).toInt(),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
class ProductNameOption {
|
||||
final int id;
|
||||
final String? code;
|
||||
final String name;
|
||||
final String? remark;
|
||||
|
||||
const ProductNameOption({
|
||||
required this.id,
|
||||
this.code,
|
||||
required this.name,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
factory ProductNameOption.fromJson(Map<String, dynamic> json) =>
|
||||
ProductNameOption(
|
||||
id: (json['id'] as num).toInt(),
|
||||
code: json['code'] as String?,
|
||||
name: json['name'] as String,
|
||||
remark: json['remark'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
class ProductSeriesOption {
|
||||
final int id;
|
||||
final String? code;
|
||||
final String name;
|
||||
final String? remark;
|
||||
|
||||
const ProductSeriesOption({
|
||||
required this.id,
|
||||
this.code,
|
||||
required this.name,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
factory ProductSeriesOption.fromJson(Map<String, dynamic> json) =>
|
||||
ProductSeriesOption(
|
||||
id: (json['id'] as num).toInt(),
|
||||
code: json['code'] as String?,
|
||||
name: json['name'] as String,
|
||||
remark: json['remark'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
class ProductSpecOption {
|
||||
final int id;
|
||||
final String? code;
|
||||
final String name;
|
||||
final int quantity;
|
||||
final String? remark;
|
||||
|
||||
const ProductSpecOption({
|
||||
required this.id,
|
||||
this.code,
|
||||
required this.name,
|
||||
this.quantity = 0,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
factory ProductSpecOption.fromJson(Map<String, dynamic> json) =>
|
||||
ProductSpecOption(
|
||||
id: (json['id'] as num).toInt(),
|
||||
code: json['code'] as String?,
|
||||
name: json['name'] as String,
|
||||
quantity: (json['quantity'] as num?)?.toInt() ?? 0,
|
||||
remark: json['remark'] as String?,
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ class StockInItem {
|
||||
// Denormalized for display
|
||||
final String? productName;
|
||||
final String? productCode;
|
||||
final String? productSeries;
|
||||
final String? productSpec;
|
||||
final String? productUnit;
|
||||
|
||||
@@ -20,6 +21,7 @@ class StockInItem {
|
||||
this.batchNo,
|
||||
this.productName,
|
||||
this.productCode,
|
||||
this.productSeries,
|
||||
this.productSpec,
|
||||
this.productUnit,
|
||||
});
|
||||
@@ -35,6 +37,7 @@ class StockInItem {
|
||||
batchNo: json['batch_no'] as String?,
|
||||
productName: (json['product'] as Map<String, dynamic>?)?['name'] as String?,
|
||||
productCode: (json['product'] as Map<String, dynamic>?)?['code'] as String?,
|
||||
productSeries: (json['product'] as Map<String, dynamic>?)?['series'] as String?,
|
||||
productSpec: (json['product'] as Map<String, dynamic>?)?['spec'] as String?,
|
||||
productUnit: (json['product'] as Map<String, dynamic>?)?['unit'] as String?,
|
||||
);
|
||||
@@ -57,6 +60,9 @@ class StockInOrder {
|
||||
final int? partnerId;
|
||||
final String? partnerName;
|
||||
final int? operatorId;
|
||||
final String? operatorName;
|
||||
final int? reviewerId;
|
||||
final String? reviewerName;
|
||||
final String status; // draft | pending | approved | rejected
|
||||
final String? orderDate;
|
||||
final double? totalAmount;
|
||||
@@ -72,6 +78,9 @@ class StockInOrder {
|
||||
this.partnerId,
|
||||
this.partnerName,
|
||||
this.operatorId,
|
||||
this.operatorName,
|
||||
this.reviewerId,
|
||||
this.reviewerName,
|
||||
required this.status,
|
||||
this.orderDate,
|
||||
this.totalAmount,
|
||||
@@ -92,6 +101,11 @@ class StockInOrder {
|
||||
operatorId: json['operator_id'] != null
|
||||
? (json['operator_id'] as num).toInt()
|
||||
: null,
|
||||
operatorName: (json['operator'] as Map<String, dynamic>?)?['real_name'] as String?,
|
||||
reviewerId: json['reviewer_id'] != null
|
||||
? (json['reviewer_id'] as num).toInt()
|
||||
: null,
|
||||
reviewerName: (json['reviewer'] as Map<String, dynamic>?)?['real_name'] as String?,
|
||||
status: json['status'] as String,
|
||||
orderDate: json['order_date'] as String?,
|
||||
totalAmount: json['total_amount'] != null
|
||||
|
||||
@@ -6,6 +6,7 @@ class StockOutItem {
|
||||
final double totalPrice;
|
||||
final String? productName;
|
||||
final String? productCode;
|
||||
final String? productSeries;
|
||||
final String? productSpec;
|
||||
final String? productUnit;
|
||||
|
||||
@@ -17,6 +18,7 @@ class StockOutItem {
|
||||
required this.totalPrice,
|
||||
this.productName,
|
||||
this.productCode,
|
||||
this.productSeries,
|
||||
this.productSpec,
|
||||
this.productUnit,
|
||||
});
|
||||
@@ -31,6 +33,7 @@ class StockOutItem {
|
||||
totalPrice: (json['total_price'] as num).toDouble(),
|
||||
productName: (json['product'] as Map<String, dynamic>?)?['name'] as String?,
|
||||
productCode: (json['product'] as Map<String, dynamic>?)?['code'] as String?,
|
||||
productSeries: (json['product'] as Map<String, dynamic>?)?['series'] as String?,
|
||||
productSpec: (json['product'] as Map<String, dynamic>?)?['spec'] as String?,
|
||||
productUnit: (json['product'] as Map<String, dynamic>?)?['unit'] as String?,
|
||||
);
|
||||
@@ -45,6 +48,9 @@ class StockOutOrder {
|
||||
final int? partnerId;
|
||||
final String? partnerName;
|
||||
final int? operatorId;
|
||||
final String? operatorName;
|
||||
final int? reviewerId;
|
||||
final String? reviewerName;
|
||||
final String status; // draft | pending | approved | rejected
|
||||
final String? orderDate;
|
||||
final double? totalAmount;
|
||||
@@ -60,6 +66,9 @@ class StockOutOrder {
|
||||
this.partnerId,
|
||||
this.partnerName,
|
||||
this.operatorId,
|
||||
this.operatorName,
|
||||
this.reviewerId,
|
||||
this.reviewerName,
|
||||
required this.status,
|
||||
this.orderDate,
|
||||
this.totalAmount,
|
||||
@@ -80,6 +89,11 @@ class StockOutOrder {
|
||||
operatorId: json['operator_id'] != null
|
||||
? (json['operator_id'] as num).toInt()
|
||||
: null,
|
||||
operatorName: (json['operator'] as Map<String, dynamic>?)?['real_name'] as String?,
|
||||
reviewerId: json['reviewer_id'] != null
|
||||
? (json['reviewer_id'] as num).toInt()
|
||||
: null,
|
||||
reviewerName: (json['reviewer'] as Map<String, dynamic>?)?['real_name'] as String?,
|
||||
status: json['status'] as String,
|
||||
orderDate: json['order_date'] as String?,
|
||||
totalAmount: json['total_amount'] != null
|
||||
|
||||
Reference in New Issue
Block a user