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:
@@ -16,6 +16,7 @@ final financeListProvider =
|
||||
|
||||
class FinanceListNotifier extends AsyncNotifier<PageResult<FinanceRecord>> {
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
String _type = '';
|
||||
String _month = '';
|
||||
|
||||
@@ -30,6 +31,7 @@ class FinanceListNotifier extends AsyncNotifier<PageResult<FinanceRecord>> {
|
||||
type: _type.isEmpty ? null : _type,
|
||||
month: _month.isEmpty ? null : _month,
|
||||
page: _page,
|
||||
pageSize: _pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,6 +52,12 @@ class FinanceListNotifier extends AsyncNotifier<PageResult<FinanceRecord>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
state = const AsyncValue.loading();
|
||||
_fetch().then(
|
||||
|
||||
@@ -17,6 +17,7 @@ final inventoryListProvider =
|
||||
|
||||
class InventoryListNotifier extends AsyncNotifier<PageResult<Inventory>> {
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
int? _warehouseId;
|
||||
String _keyword = '';
|
||||
PageResult<Inventory>? _cache;
|
||||
@@ -40,7 +41,7 @@ class InventoryListNotifier extends AsyncNotifier<PageResult<Inventory>> {
|
||||
warehouseId: _warehouseId,
|
||||
keyword: _keyword.isEmpty ? null : _keyword,
|
||||
page: _page,
|
||||
pageSize: 50,
|
||||
pageSize: _pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,6 +50,12 @@ class InventoryListNotifier extends AsyncNotifier<PageResult<Inventory>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void setWarehouseId(int? id) {
|
||||
_warehouseId = id;
|
||||
_page = 1;
|
||||
@@ -83,6 +90,7 @@ final inventoryLogProvider =
|
||||
|
||||
class InventoryLogNotifier extends AsyncNotifier<PageResult<InventoryLog>> {
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
PageResult<InventoryLog>? _cache;
|
||||
|
||||
@override
|
||||
@@ -102,7 +110,7 @@ class InventoryLogNotifier extends AsyncNotifier<PageResult<InventoryLog>> {
|
||||
Future<PageResult<InventoryLog>> _fetch() {
|
||||
return ref.read(inventoryRepositoryProvider).listLogs(
|
||||
page: _page,
|
||||
pageSize: 50,
|
||||
pageSize: _pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,6 +119,12 @@ class InventoryLogNotifier extends AsyncNotifier<PageResult<InventoryLog>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
state = const AsyncValue.loading();
|
||||
_fetch().then((result) {
|
||||
|
||||
@@ -25,6 +25,7 @@ final customerListProvider =
|
||||
class PartnerListNotifier extends AsyncNotifier<PageResult<Partner>> {
|
||||
final String? type;
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
String _keyword = '';
|
||||
PageResult<Partner>? _cache;
|
||||
|
||||
@@ -49,6 +50,7 @@ class PartnerListNotifier extends AsyncNotifier<PageResult<Partner>> {
|
||||
type: type,
|
||||
keyword: _keyword.isEmpty ? null : _keyword,
|
||||
page: _page,
|
||||
pageSize: _pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,6 +59,12 @@ class PartnerListNotifier extends AsyncNotifier<PageResult<Partner>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void setKeyword(String keyword) {
|
||||
_keyword = keyword;
|
||||
_page = 1;
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../core/api/api_client.dart';
|
||||
import '../core/auth/auth_state.dart';
|
||||
import '../models/product_option.dart';
|
||||
import '../providers/connectivity_provider.dart';
|
||||
import '../repositories/product_option_repository.dart';
|
||||
|
||||
final productOptionRepositoryProvider = Provider<ProductOptionRepository>((ref) {
|
||||
return ProductOptionRepository(ref.watch(apiClientProvider));
|
||||
});
|
||||
|
||||
// ── 商品名称 ─────────────────────────────────────────────────
|
||||
|
||||
final productNameListProvider =
|
||||
AsyncNotifierProvider<ProductNameListNotifier, List<ProductNameOption>>(
|
||||
ProductNameListNotifier.new,
|
||||
);
|
||||
|
||||
class ProductNameListNotifier extends AsyncNotifier<List<ProductNameOption>> {
|
||||
@override
|
||||
Future<List<ProductNameOption>> build() async {
|
||||
ref.watch(authStateProvider.select((s) => s.user?.shopId));
|
||||
ref.watch(networkRecoveryCountProvider);
|
||||
return ref.read(productOptionRepositoryProvider).listNames();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
state = const AsyncValue.loading();
|
||||
ref.read(productOptionRepositoryProvider).listNames().then(
|
||||
(data) => state = AsyncValue.data(data),
|
||||
onError: (e, st) => state = AsyncValue.error(e, st),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> create(Map<String, dynamic> data) async {
|
||||
await ref.read(productOptionRepositoryProvider).createName(data);
|
||||
reload();
|
||||
}
|
||||
|
||||
Future<void> delete(int id) async {
|
||||
await ref.read(productOptionRepositoryProvider).deleteName(id);
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
// ── 商品系列 ─────────────────────────────────────────────────
|
||||
|
||||
final productSeriesListProvider =
|
||||
AsyncNotifierProvider<ProductSeriesListNotifier, List<ProductSeriesOption>>(
|
||||
ProductSeriesListNotifier.new,
|
||||
);
|
||||
|
||||
class ProductSeriesListNotifier extends AsyncNotifier<List<ProductSeriesOption>> {
|
||||
@override
|
||||
Future<List<ProductSeriesOption>> build() async {
|
||||
ref.watch(authStateProvider.select((s) => s.user?.shopId));
|
||||
ref.watch(networkRecoveryCountProvider);
|
||||
return ref.read(productOptionRepositoryProvider).listSeries();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
state = const AsyncValue.loading();
|
||||
ref.read(productOptionRepositoryProvider).listSeries().then(
|
||||
(data) => state = AsyncValue.data(data),
|
||||
onError: (e, st) => state = AsyncValue.error(e, st),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> create(Map<String, dynamic> data) async {
|
||||
await ref.read(productOptionRepositoryProvider).createSeries(data);
|
||||
reload();
|
||||
}
|
||||
|
||||
Future<void> delete(int id) async {
|
||||
await ref.read(productOptionRepositoryProvider).deleteSeries(id);
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
// ── 商品规格 ─────────────────────────────────────────────────
|
||||
|
||||
final productSpecListProvider =
|
||||
AsyncNotifierProvider<ProductSpecListNotifier, List<ProductSpecOption>>(
|
||||
ProductSpecListNotifier.new,
|
||||
);
|
||||
|
||||
class ProductSpecListNotifier extends AsyncNotifier<List<ProductSpecOption>> {
|
||||
@override
|
||||
Future<List<ProductSpecOption>> build() async {
|
||||
ref.watch(authStateProvider.select((s) => s.user?.shopId));
|
||||
ref.watch(networkRecoveryCountProvider);
|
||||
return ref.read(productOptionRepositoryProvider).listSpecs();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
state = const AsyncValue.loading();
|
||||
ref.read(productOptionRepositoryProvider).listSpecs().then(
|
||||
(data) => state = AsyncValue.data(data),
|
||||
onError: (e, st) => state = AsyncValue.error(e, st),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> create(Map<String, dynamic> data) async {
|
||||
await ref.read(productOptionRepositoryProvider).createSpec(data);
|
||||
reload();
|
||||
}
|
||||
|
||||
Future<void> delete(int id) async {
|
||||
await ref.read(productOptionRepositoryProvider).deleteSpec(id);
|
||||
reload();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ final productListProvider =
|
||||
|
||||
class ProductListNotifier extends AsyncNotifier<PageResult<Product>> {
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
String _keyword = '';
|
||||
int? _categoryId;
|
||||
PageResult<Product>? _cache;
|
||||
@@ -39,7 +40,7 @@ class ProductListNotifier extends AsyncNotifier<PageResult<Product>> {
|
||||
final repo = ref.read(productRepositoryProvider);
|
||||
return repo.list(
|
||||
page: _page,
|
||||
pageSize: 20,
|
||||
pageSize: _pageSize,
|
||||
keyword: _keyword.isEmpty ? null : _keyword,
|
||||
categoryId: _categoryId,
|
||||
);
|
||||
@@ -50,6 +51,12 @@ class ProductListNotifier extends AsyncNotifier<PageResult<Product>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void setKeyword(String keyword) {
|
||||
_keyword = keyword;
|
||||
_page = 1;
|
||||
|
||||
@@ -18,6 +18,7 @@ final stockInListProvider =
|
||||
|
||||
class StockInListNotifier extends AsyncNotifier<PageResult<StockInOrder>> {
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
String _status = '';
|
||||
String? _startDate;
|
||||
String? _endDate;
|
||||
@@ -43,6 +44,7 @@ class StockInListNotifier extends AsyncNotifier<PageResult<StockInOrder>> {
|
||||
startDate: _startDate,
|
||||
endDate: _endDate,
|
||||
page: _page,
|
||||
pageSize: _pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,6 +53,12 @@ class StockInListNotifier extends AsyncNotifier<PageResult<StockInOrder>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void setStatus(String status) {
|
||||
_status = status;
|
||||
_page = 1;
|
||||
|
||||
@@ -18,6 +18,7 @@ final stockOutListProvider =
|
||||
|
||||
class StockOutListNotifier extends AsyncNotifier<PageResult<StockOutOrder>> {
|
||||
int _page = 1;
|
||||
int _pageSize = 20;
|
||||
String _status = '';
|
||||
String? _startDate;
|
||||
String? _endDate;
|
||||
@@ -43,6 +44,7 @@ class StockOutListNotifier extends AsyncNotifier<PageResult<StockOutOrder>> {
|
||||
startDate: _startDate,
|
||||
endDate: _endDate,
|
||||
page: _page,
|
||||
pageSize: _pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,6 +53,12 @@ class StockOutListNotifier extends AsyncNotifier<PageResult<StockOutOrder>> {
|
||||
reload();
|
||||
}
|
||||
|
||||
void setPageSize(int pageSize) {
|
||||
_pageSize = pageSize;
|
||||
_page = 1;
|
||||
reload();
|
||||
}
|
||||
|
||||
void setStatus(String status) {
|
||||
_status = status;
|
||||
_page = 1;
|
||||
|
||||
Reference in New Issue
Block a user