|
|
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|
|
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
|
|
import '../../core/i18n/app_localizations.dart';
|
|
|
import '../../core/theme/app_colors_extension.dart';
|
|
|
+import '../widgets/loading_dialog.dart';
|
|
|
|
|
|
/// 审核流处理工具。
|
|
|
///
|
|
|
@@ -33,20 +34,40 @@ class AuditFlowHelper {
|
|
|
if (!hasFlow) return;
|
|
|
|
|
|
if (autoSubmit) {
|
|
|
- if (!skipOnAutoSubmit) await onShSubmit();
|
|
|
+ if (!skipOnAutoSubmit) {
|
|
|
+ // ignore: use_build_context_synchronously
|
|
|
+ await _runWithLoading(context, l10n, onShSubmit);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// ignore: use_build_context_synchronously
|
|
|
final shouldSubmit = await _showDialog(colors, context, l10n);
|
|
|
if (shouldSubmit == true) {
|
|
|
- await onShSubmit();
|
|
|
+ // ignore: use_build_context_synchronously
|
|
|
+ await _runWithLoading(context, l10n, onShSubmit);
|
|
|
}
|
|
|
} catch (_) {
|
|
|
// getBillAuditConfig 或 SHSubmit 失败均不阻塞流程
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// SHSubmit 执行期间显示 loading,成功失败均自动隐藏。
|
|
|
+ static Future<void> _runWithLoading(
|
|
|
+ BuildContext context,
|
|
|
+ AppLocalizations l10n,
|
|
|
+ Future<void> Function() onShSubmit,
|
|
|
+ ) async {
|
|
|
+ // ignore: use_build_context_synchronously
|
|
|
+ LoadingDialog.show(context, text: l10n.get('submitting'));
|
|
|
+ try {
|
|
|
+ await onShSubmit();
|
|
|
+ } finally {
|
|
|
+ // ignore: use_build_context_synchronously
|
|
|
+ LoadingDialog.hide(context);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
static Future<bool?> _showDialog(
|
|
|
AppColorsExtension colors,
|
|
|
BuildContext context,
|