feat: handle off-shelf registration results

This commit is contained in:
Misaka_Company
2026-05-13 12:43:22 +08:00
parent b975b15ba7
commit b32c9c5aad
3 changed files with 145 additions and 18 deletions

View File

@@ -49,8 +49,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
}
void _onKeyEvent(KeyEvent event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.enter) {
_submit();
}
}
@@ -195,11 +194,24 @@ class _RegistrationPageState extends State<RegistrationPage> {
_locationType = null;
}
});
final msg = _isLocked ? '货位已锁定,请扫描下一张执行卡' : '上架成功';
_showStatusOverride(msg, StatusDotColor.green, const Duration(milliseconds: 1500));
final msg = result.isOffShelfSuccess
? '下架成功'
: (_isLocked ? '货位已锁定,请扫描下一张执行卡' : '上架成功');
_showStatusOverride(
msg,
StatusDotColor.green,
const Duration(milliseconds: 1500),
);
} else if (result.isDuplicate) {
_feedbackService.trigger(FeedbackEvent.duplicateError);
_showDuplicateDialog(zongpaiNo, result.duplicateInfo);
} else if (result.isAlreadyOffShelf) {
_feedbackService.trigger(FeedbackEvent.submitFailure);
_showStatusOverride(
result.errorMessage ?? '该总排号已下架至转运区域,不可重新上架',
StatusDotColor.red,
const Duration(seconds: 2),
);
} else {
final isNetwork = result.errorMessage == '网络异常,请检查网络连接';
_feedbackService.trigger(
@@ -215,6 +227,7 @@ class _RegistrationPageState extends State<RegistrationPage> {
Future<void> _submitBatch(String baseUrl) async {
int successCount = 0;
int offShelfCount = 0;
final failed = <String>[];
final toRemove = <String>[];
@@ -226,6 +239,9 @@ class _RegistrationPageState extends State<RegistrationPage> {
);
if (result.success) {
successCount++;
if (result.isOffShelfSuccess) {
offShelfCount++;
}
toRemove.add(zp);
} else {
failed.add(zp);
@@ -238,6 +254,19 @@ class _RegistrationPageState extends State<RegistrationPage> {
_showDuplicateDialog(zp, result.duplicateInfo);
return;
}
if (result.isAlreadyOffShelf) {
setState(() {
_zongpaiNos.removeWhere((e) => toRemove.contains(e));
_isSubmitting = false;
});
_feedbackService.trigger(FeedbackEvent.submitFailure);
_showStatusOverride(
result.errorMessage ?? '该总排号已下架至转运区域,不可重新上架',
StatusDotColor.red,
const Duration(seconds: 2),
);
return;
}
}
}
@@ -250,8 +279,11 @@ class _RegistrationPageState extends State<RegistrationPage> {
if (failed.isEmpty) {
_feedbackService.trigger(FeedbackEvent.submitSuccess);
final msg = offShelfCount == successCount
? '批量下架成功($successCount 条)'
: '批量上架成功($successCount 条)';
_showStatusOverride(
'批量上架成功($successCount 条)',
msg,
StatusDotColor.green,
const Duration(milliseconds: 1500),
);
@@ -492,7 +524,9 @@ class _RegistrationPageState extends State<RegistrationPage> {
width: double.infinity,
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade400),
border: Border.all(
color: Colors.grey.shade400,
),
borderRadius: BorderRadius.circular(8),
),
child: const Text(
@@ -509,7 +543,9 @@ class _RegistrationPageState extends State<RegistrationPage> {
const SizedBox(height: 6),
itemBuilder: (context, index) {
return Dismissible(
key: ValueKey('${_zongpaiNos[index]}-$index'),
key: ValueKey(
'${_zongpaiNos[index]}-$index',
),
direction: DismissDirection.endToStart,
onDismissed: (_) => _removeZongpai(index),
background: Container(