feat: 自动更新、系统设置、安全修复
后端: - 新增 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>
This commit is contained in:
@@ -27,33 +27,38 @@ class DataTableCard extends StatelessWidget {
|
||||
children: [
|
||||
if (toolbar != null)
|
||||
Container(
|
||||
height: 52,
|
||||
color: AppTheme.surface,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: toolbar!,
|
||||
),
|
||||
if (toolbar != null) const Divider(height: 1),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: DataTable(
|
||||
headingRowColor: WidgetStateProperty.all(
|
||||
const Color(0xFFF0F4FF)),
|
||||
headingTextStyle: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppTheme.primaryDark,
|
||||
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,
|
||||
),
|
||||
),
|
||||
dataTextStyle: const TextStyle(
|
||||
fontSize: 13, color: AppTheme.textPrimary),
|
||||
columnSpacing: 24,
|
||||
horizontalMargin: 16,
|
||||
dataRowMinHeight: 40,
|
||||
dataRowMaxHeight: 48,
|
||||
dividerThickness: 0.5,
|
||||
columns: columns,
|
||||
rows: rows,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../core/theme/app_theme.dart';
|
||||
|
||||
/// Compact button → dialog with checkboxes for multi-select filtering
|
||||
class MultiSelectDropdown extends StatelessWidget {
|
||||
final String label;
|
||||
final List<String> options;
|
||||
final Set<String> selected;
|
||||
final ValueChanged<Set<String>> onChanged;
|
||||
|
||||
const MultiSelectDropdown({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.options,
|
||||
required this.selected,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final active = selected.isNotEmpty;
|
||||
return OutlinedButton(
|
||||
onPressed: options.isEmpty ? null : () => _show(context),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: active ? AppTheme.primary : AppTheme.textSecondary,
|
||||
side: BorderSide(color: active ? AppTheme.primary : AppTheme.border),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.filter_list, size: 13),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
active ? '$label (${selected.length})' : label,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
if (active) ...[
|
||||
const SizedBox(width: 4),
|
||||
GestureDetector(
|
||||
onTap: () => onChanged({}),
|
||||
child: const Icon(Icons.close, size: 12),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _show(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierColor: Colors.black12,
|
||||
builder: (_) => _MultiSelectDialog(
|
||||
label: label,
|
||||
options: options,
|
||||
initial: selected,
|
||||
onApply: onChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MultiSelectDialog extends StatefulWidget {
|
||||
final String label;
|
||||
final List<String> options;
|
||||
final Set<String> initial;
|
||||
final ValueChanged<Set<String>> onApply;
|
||||
|
||||
const _MultiSelectDialog({
|
||||
required this.label,
|
||||
required this.options,
|
||||
required this.initial,
|
||||
required this.onApply,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_MultiSelectDialog> createState() => _MultiSelectDialogState();
|
||||
}
|
||||
|
||||
class _MultiSelectDialogState extends State<_MultiSelectDialog> {
|
||||
late Set<String> _selected;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selected = Set.from(widget.initial);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(widget.label, style: const TextStyle(fontSize: 15)),
|
||||
contentPadding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
content: SizedBox(
|
||||
width: 220,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(children: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
setState(() => _selected = Set.from(widget.options)),
|
||||
child: const Text('全选', style: TextStyle(fontSize: 12)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => setState(() => _selected = {}),
|
||||
child: const Text('清空', style: TextStyle(fontSize: 12)),
|
||||
),
|
||||
]),
|
||||
const Divider(height: 1),
|
||||
...widget.options.map((opt) => CheckboxListTile(
|
||||
title: Text(opt, style: const TextStyle(fontSize: 13)),
|
||||
value: _selected.contains(opt),
|
||||
dense: true,
|
||||
onChanged: (v) => setState(() {
|
||||
if (v == true) {
|
||||
_selected.add(opt);
|
||||
} else {
|
||||
_selected.remove(opt);
|
||||
}
|
||||
}),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
widget.onApply(_selected);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('应用'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Column definition for column visibility toggle
|
||||
class ColDef {
|
||||
final String key;
|
||||
final String label;
|
||||
final bool required; // if true, cannot be hidden
|
||||
/// Screen width below which this column is automatically hidden
|
||||
final double? minWidth;
|
||||
|
||||
const ColDef(this.key, this.label, {this.required = false, this.minWidth});
|
||||
}
|
||||
|
||||
/// Button that lets users toggle column visibility
|
||||
class ColumnToggleButton extends StatelessWidget {
|
||||
final List<ColDef> columns;
|
||||
final Set<String> hidden;
|
||||
final ValueChanged<Set<String>> onChanged;
|
||||
|
||||
const ColumnToggleButton({
|
||||
super.key,
|
||||
required this.columns,
|
||||
required this.hidden,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return OutlinedButton(
|
||||
onPressed: () => _show(context),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppTheme.textSecondary,
|
||||
side: const BorderSide(color: AppTheme.border),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.view_column_outlined, size: 13),
|
||||
SizedBox(width: 4),
|
||||
Text('显示字段', style: TextStyle(fontSize: 12)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _show(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierColor: Colors.black12,
|
||||
builder: (_) => _ColumnToggleDialog(
|
||||
columns: columns,
|
||||
initial: hidden,
|
||||
onApply: onChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ColumnToggleDialog extends StatefulWidget {
|
||||
final List<ColDef> columns;
|
||||
final Set<String> initial;
|
||||
final ValueChanged<Set<String>> onApply;
|
||||
|
||||
const _ColumnToggleDialog({
|
||||
required this.columns,
|
||||
required this.initial,
|
||||
required this.onApply,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_ColumnToggleDialog> createState() => _ColumnToggleDialogState();
|
||||
}
|
||||
|
||||
class _ColumnToggleDialogState extends State<_ColumnToggleDialog> {
|
||||
late Set<String> _hidden;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_hidden = Set.from(widget.initial);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('显示字段', style: TextStyle(fontSize: 15)),
|
||||
contentPadding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
content: SizedBox(
|
||||
width: 220,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: widget.columns
|
||||
.map((col) => CheckboxListTile(
|
||||
title: Text(col.label,
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
value: !_hidden.contains(col.key),
|
||||
dense: true,
|
||||
onChanged: col.required
|
||||
? null // required columns cannot be hidden
|
||||
: (v) => setState(() {
|
||||
if (v == true) {
|
||||
_hidden.remove(col.key);
|
||||
} else {
|
||||
_hidden.add(col.key);
|
||||
}
|
||||
}),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
widget.onApply(_hidden);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('应用'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user