32bd64d676
- 心跳读取 /auth/ping 回带的授权概况,直接刷新横幅/状态栏/只读门禁,省去单独轮询 /license/info - 账号被停用/删除(401 USER_DISABLED)即强制重新登录 - 令牌持久化经串行队列 + 会话代号守卫,杜绝续期写入与登出交叉把失效 token 写回 - 写操作门禁(write_guard)+ 授权文案(license_copy)按 grace/readonly/locked 分阶段降级 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
2.2 KiB
Dart
55 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../core/theme/app_theme.dart';
|
|
import 'write_guard.dart';
|
|
|
|
/// 入/出库单行内操作按钮,列表表格与移动端卡片、入库与出库两屏共用。
|
|
///
|
|
/// 此前 stock_in / stock_out 各自逐字重复了「详情/打印/结清/修改/删除/提交/通过/拒绝」
|
|
/// 的状态门控(draft/pending/approved)与 WriteGuard 包裹脚手架,仅单据类型、路由、
|
|
/// 打印函数与回调不同。这里把**相同的结构**收敛到单一来源,差异通过回调注入:
|
|
///
|
|
/// - [afterPrint]:紧随「打印」之后的附加按钮(入库的「打标签」;出库传空)。
|
|
/// - 各 `on*` 回调由调用方绑定到对应单据的确认/跳转逻辑。
|
|
List<Widget> buildOrderRowActions({
|
|
required bool readonly,
|
|
required String status,
|
|
required int orderId,
|
|
required VoidCallback onDetail,
|
|
required VoidCallback onPrint,
|
|
required VoidCallback onSettle,
|
|
required VoidCallback onEdit,
|
|
required VoidCallback onDelete,
|
|
required VoidCallback onSubmit,
|
|
required VoidCallback onApprove,
|
|
required VoidCallback onReject,
|
|
List<Widget> afterPrint = const [],
|
|
}) {
|
|
TextButton btn(String text, Color color, VoidCallback onPressed, {Key? key}) =>
|
|
TextButton(
|
|
key: key,
|
|
onPressed: onPressed,
|
|
child: Text(text, style: TextStyle(fontSize: 12, color: color)),
|
|
);
|
|
return [
|
|
btn('详情', AppTheme.primary, onDetail),
|
|
btn('打印', AppTheme.primary, onPrint),
|
|
...afterPrint,
|
|
if (!readonly && status == 'approved')
|
|
WriteGuard(child: btn('结清', AppTheme.accent, onSettle)),
|
|
if (!readonly && status == 'draft') ...[
|
|
WriteGuard(child: btn('修改', AppTheme.primary, onEdit)),
|
|
WriteGuard(child: btn('删除', AppTheme.danger, onDelete)),
|
|
WriteGuard(child: btn('提交', AppTheme.primary, onSubmit)),
|
|
],
|
|
if (!readonly && status == 'pending') ...[
|
|
WriteGuard(
|
|
child: btn('通过', AppTheme.success, onApprove,
|
|
key: Key('btn_approve_$orderId'))),
|
|
WriteGuard(
|
|
child: btn('拒绝', AppTheme.danger, onReject,
|
|
key: Key('btn_reject_$orderId'))),
|
|
],
|
|
];
|
|
}
|