9d5bc18de1
Deploy Client / build-client-web (push) Successful in 38s
Deploy Client / build-macos (push) Successful in 2m10s
Deploy Client / build-android (push) Successful in 56s
Deploy Client / build-ios (push) Successful in 2m35s
Deploy Client / build-windows (push) Successful in 1m49s
Deploy Client / release-deploy-client (push) Successful in 1m23s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
62 lines
2.5 KiB
Dart
62 lines
2.5 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,
|
|
required VoidCallback onWithdraw,
|
|
bool canWithdraw = false,
|
|
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'))),
|
|
// 撤回(审核中→草稿):管理员/超管任意单、操作员本人单可见,用 warn 样式
|
|
if (canWithdraw)
|
|
WriteGuard(
|
|
child: btn('撤回', AppTheme.warning, onWithdraw,
|
|
key: Key('btn_withdraw_$orderId'))),
|
|
],
|
|
];
|
|
}
|