bb4f17cf7a
后端: - 新增 GET /version 版本检查端点(version.go + version.yaml) - 新增 GET /license/info 接口,返回门店授权信息 - 修复 GenerateOrderNo 并发重复单号:事务内加 FOR UPDATE 行锁 - 修复 ApproveStockOut 超卖竞态:预检和库存更新均加 FOR UPDATE - 修复 Product Create 并发 code 冲突:加重试逻辑,schema 加 UNIQUE KEY - 修复 Product Update 全字段覆盖:改用 selective Updates() - 挂载 ReadOnly 中间件(全局)+ AdminOnly(用户管理路由) - version.go 配置缺失时返回 500 而非静默降级 前端: - 新增自动更新检测(update_provider.dart)+ shell 更新 banner/弹窗 - 新增系统设置"关于"标签页:版本、授权、开发信息、意见反馈 - 新增离线缓存:所有 AsyncNotifierProvider 支持断网浏览历史数据 - 新增门店信息弹窗(点击左上角 logo 或右上角门店号触发) - 提取 AppConfig 统一管理 BASE_URL,支持 --dart-define 注入 - update_provider.dart 加 kIsWeb 保护,修复 Web 平台崩溃 - dev.sh 新增 stop 命令,修复 stop 误杀前端进程问题 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
145 lines
4.4 KiB
Dart
145 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../core/theme/app_theme.dart';
|
|
|
|
class DataTableCard extends StatelessWidget {
|
|
final List<DataColumn> columns;
|
|
final List<DataRow> rows;
|
|
final Widget? toolbar;
|
|
final int? totalCount;
|
|
final int page;
|
|
final int pageSize;
|
|
final ValueChanged<int>? onPageChanged;
|
|
|
|
const DataTableCard({
|
|
super.key,
|
|
required this.columns,
|
|
required this.rows,
|
|
this.toolbar,
|
|
this.totalCount,
|
|
this.page = 1,
|
|
this.pageSize = 20,
|
|
this.onPageChanged,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
if (toolbar != null)
|
|
Container(
|
|
color: AppTheme.surface,
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
child: toolbar!,
|
|
),
|
|
if (toolbar != null) const Divider(height: 1),
|
|
Expanded(
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) => SingleChildScrollView(
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: ConstrainedBox(
|
|
constraints:
|
|
BoxConstraints(minWidth: constraints.maxWidth),
|
|
child: DataTable(
|
|
headingRowColor: WidgetStateProperty.all(
|
|
const Color(0xFFF0F4FF)),
|
|
headingTextStyle: const TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppTheme.primaryDark,
|
|
),
|
|
dataTextStyle: const TextStyle(
|
|
fontSize: 13, color: AppTheme.textPrimary),
|
|
columnSpacing: 24,
|
|
horizontalMargin: 16,
|
|
dataRowMinHeight: 40,
|
|
dataRowMaxHeight: 56,
|
|
dividerThickness: 0.5,
|
|
columns: columns,
|
|
rows: rows,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// Pagination
|
|
if (totalCount != null)
|
|
Container(
|
|
height: 48,
|
|
color: AppTheme.surface,
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
'共 $totalCount 条记录',
|
|
style: const TextStyle(
|
|
fontSize: 13, color: AppTheme.textSecondary),
|
|
),
|
|
const Spacer(),
|
|
_PaginationBar(
|
|
page: page,
|
|
total: totalCount!,
|
|
pageSize: pageSize,
|
|
onPageChanged: onPageChanged,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _PaginationBar extends StatelessWidget {
|
|
final int page;
|
|
final int total;
|
|
final int pageSize;
|
|
final ValueChanged<int>? onPageChanged;
|
|
|
|
const _PaginationBar({
|
|
required this.page,
|
|
required this.total,
|
|
required this.pageSize,
|
|
this.onPageChanged,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final totalPages = (total / pageSize).ceil().clamp(1, 9999);
|
|
return Row(
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.first_page, size: 18),
|
|
onPressed: page > 1 ? () => onPageChanged?.call(1) : null,
|
|
padding: EdgeInsets.zero,
|
|
constraints: const BoxConstraints(minWidth: 28, minHeight: 28),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.chevron_left, size: 18),
|
|
onPressed: page > 1 ? () => onPageChanged?.call(page - 1) : null,
|
|
padding: EdgeInsets.zero,
|
|
constraints: const BoxConstraints(minWidth: 28, minHeight: 28),
|
|
),
|
|
Text('$page / $totalPages',
|
|
style: const TextStyle(fontSize: 13)),
|
|
IconButton(
|
|
icon: const Icon(Icons.chevron_right, size: 18),
|
|
onPressed:
|
|
page < totalPages ? () => onPageChanged?.call(page + 1) : null,
|
|
padding: EdgeInsets.zero,
|
|
constraints: const BoxConstraints(minWidth: 28, minHeight: 28),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.last_page, size: 18),
|
|
onPressed: page < totalPages
|
|
? () => onPageChanged?.call(totalPages)
|
|
: null,
|
|
padding: EdgeInsets.zero,
|
|
constraints: const BoxConstraints(minWidth: 28, minHeight: 28),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|