Compare commits
1 Commits
9dc714dbeb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99ed3bb9ec |
File diff suppressed because it is too large
Load Diff
@@ -65,8 +65,6 @@ class BoxingApiActions {
|
|||||||
required String zongpaiNo,
|
required String zongpaiNo,
|
||||||
required int boxNo,
|
required int boxNo,
|
||||||
required int quantity,
|
required int quantity,
|
||||||
String itemType = 'product',
|
|
||||||
int? accessoryId,
|
|
||||||
}) async {
|
}) async {
|
||||||
final baseUrl = await _requireBaseUrl();
|
final baseUrl = await _requireBaseUrl();
|
||||||
if (baseUrl == null) return _missingApiUrl();
|
if (baseUrl == null) return _missingApiUrl();
|
||||||
@@ -76,8 +74,6 @@ class BoxingApiActions {
|
|||||||
zongpaiNo: zongpaiNo,
|
zongpaiNo: zongpaiNo,
|
||||||
boxNo: boxNo,
|
boxNo: boxNo,
|
||||||
quantity: quantity,
|
quantity: quantity,
|
||||||
itemType: itemType,
|
|
||||||
accessoryId: accessoryId,
|
|
||||||
);
|
);
|
||||||
return _saveResult(result, fallbackMessage: '提交失败');
|
return _saveResult(result, fallbackMessage: '提交失败');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ extension _BoxingScanPart on _BoxingPageState {
|
|||||||
_currentZongpaiBoxes = result.currentZongpaiBoxes;
|
_currentZongpaiBoxes = result.currentZongpaiBoxes;
|
||||||
_existingBoxes = result.existingBoxes;
|
_existingBoxes = result.existingBoxes;
|
||||||
_maxBoxNo = result.maxBoxNo;
|
_maxBoxNo = result.maxBoxNo;
|
||||||
_pendingAccessories = result.pendingAccessories;
|
|
||||||
_phase = BoxingPhase.scanned;
|
_phase = BoxingPhase.scanned;
|
||||||
_isDuplicateBoxNo = false;
|
_isDuplicateBoxNo = false;
|
||||||
_editingBox = null;
|
_editingBox = null;
|
||||||
|
|||||||
@@ -158,47 +158,4 @@ extension _BoxingSubmitPart on _BoxingPageState {
|
|||||||
const Duration(milliseconds: 1500),
|
const Duration(milliseconds: 1500),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _submitAccessory(PendingAccessory accessory) async {
|
|
||||||
if (_zongpaiNo == null || _isSubmitting) return;
|
|
||||||
|
|
||||||
final boxNo = int.tryParse(_boxNoController.text);
|
|
||||||
if (boxNo == null || boxNo <= 0) {
|
|
||||||
this._showStatusOverride(
|
|
||||||
'请先输入有效箱号',
|
|
||||||
StatusDotColor.red,
|
|
||||||
const Duration(seconds: 2),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() => _isSubmitting = true);
|
|
||||||
|
|
||||||
final action = await _apiActions.saveBoxRecord(
|
|
||||||
zongpaiNo: _zongpaiNo!,
|
|
||||||
boxNo: boxNo,
|
|
||||||
quantity: accessory.quantity,
|
|
||||||
itemType: 'accessory',
|
|
||||||
accessoryId: accessory.accessoryId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!mounted) return;
|
|
||||||
|
|
||||||
setState(() => _isSubmitting = false);
|
|
||||||
|
|
||||||
if (action.success) {
|
|
||||||
_feedbackService.trigger(FeedbackEvent.submitSuccess);
|
|
||||||
// Refresh box info to update pending accessories
|
|
||||||
await this._queryBoxInfo(_zongpaiNo!);
|
|
||||||
if (mounted) {
|
|
||||||
this._showStatusOverride(
|
|
||||||
'${accessory.accessoryType} 已加入箱号 $boxNo',
|
|
||||||
StatusDotColor.green,
|
|
||||||
const Duration(milliseconds: 1500),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this._showActionError(action, fallback: '附件装箱失败');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ class MultiCodeBody extends StatelessWidget {
|
|||||||
final ValueChanged<ManyToOnePackedItem> onStartDeletePackedItem;
|
final ValueChanged<ManyToOnePackedItem> onStartDeletePackedItem;
|
||||||
final ValueChanged<ManyToOnePackedItem> onDeletePackedItem;
|
final ValueChanged<ManyToOnePackedItem> onDeletePackedItem;
|
||||||
final VoidCallback onCancelDeletePackedItem;
|
final VoidCallback onCancelDeletePackedItem;
|
||||||
final List<PendingAccessory> pendingAccessories;
|
|
||||||
final ValueChanged<PendingAccessory> onSubmitAccessory;
|
|
||||||
|
|
||||||
const MultiCodeBody({
|
const MultiCodeBody({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -71,8 +69,6 @@ class MultiCodeBody extends StatelessWidget {
|
|||||||
required this.onStartDeletePackedItem,
|
required this.onStartDeletePackedItem,
|
||||||
required this.onDeletePackedItem,
|
required this.onDeletePackedItem,
|
||||||
required this.onCancelDeletePackedItem,
|
required this.onCancelDeletePackedItem,
|
||||||
required this.pendingAccessories,
|
|
||||||
required this.onSubmitAccessory,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -91,7 +87,7 @@ class MultiCodeBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const _MultiListHeader(),
|
const _MultiListHeader(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: visibleItems.isEmpty && pendingAccessories.isEmpty
|
child: visibleItems.isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'尚未装入任何物料',
|
'尚未装入任何物料',
|
||||||
@@ -103,32 +99,22 @@ class MultiCodeBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
itemCount: visibleItems.length + pendingAccessories.length,
|
itemCount: visibleItems.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index < visibleItems.length) {
|
final item = visibleItems[index];
|
||||||
final item = visibleItems[index];
|
return MultiPackedRow(
|
||||||
return MultiPackedRow(
|
item: item,
|
||||||
item: item,
|
editing: editingPackedItemId == item.boxItemId,
|
||||||
editing: editingPackedItemId == item.boxItemId,
|
deleting: deletingPackedItemId == item.boxItemId,
|
||||||
deleting: deletingPackedItemId == item.boxItemId,
|
|
||||||
isSubmitting: isSubmitting,
|
|
||||||
editingQuantity: editingPackedQuantity,
|
|
||||||
onEditingQuantityChanged:
|
|
||||||
onEditingPackedQuantityChanged,
|
|
||||||
onSave: () => onSavePackedItem(item),
|
|
||||||
onCancelEdit: onCancelEditPackedItem,
|
|
||||||
onStartEdit: () => onStartEditPackedItem(item),
|
|
||||||
onStartDelete: () => onStartDeletePackedItem(item),
|
|
||||||
onDelete: () => onDeletePackedItem(item),
|
|
||||||
onCancelDelete: onCancelDeletePackedItem,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final accIndex = index - visibleItems.length;
|
|
||||||
final acc = pendingAccessories[accIndex];
|
|
||||||
return _MultiAccessoryRow(
|
|
||||||
accessory: acc,
|
|
||||||
isSubmitting: isSubmitting,
|
isSubmitting: isSubmitting,
|
||||||
onSubmit: () => onSubmitAccessory(acc),
|
editingQuantity: editingPackedQuantity,
|
||||||
|
onEditingQuantityChanged: onEditingPackedQuantityChanged,
|
||||||
|
onSave: () => onSavePackedItem(item),
|
||||||
|
onCancelEdit: onCancelEditPackedItem,
|
||||||
|
onStartEdit: () => onStartEditPackedItem(item),
|
||||||
|
onStartDelete: () => onStartDeletePackedItem(item),
|
||||||
|
onDelete: () => onDeletePackedItem(item),
|
||||||
|
onCancelDelete: onCancelDeletePackedItem,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -618,72 +604,3 @@ class _MultiSubmitRow extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MultiAccessoryRow extends StatelessWidget {
|
|
||||||
final PendingAccessory accessory;
|
|
||||||
final bool isSubmitting;
|
|
||||||
final VoidCallback onSubmit;
|
|
||||||
|
|
||||||
const _MultiAccessoryRow({
|
|
||||||
required this.accessory,
|
|
||||||
required this.isSubmitting,
|
|
||||||
required this.onSubmit,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
height: 40,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.orange.shade50,
|
|
||||||
border: Border(bottom: BorderSide(color: Colors.grey.shade200)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.build, size: 14, color: Colors.orange.shade600),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Expanded(
|
|
||||||
flex: 40,
|
|
||||||
child: Text(
|
|
||||||
accessory.accessoryType,
|
|
||||||
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 20,
|
|
||||||
child: Text(
|
|
||||||
'\u00d7${accessory.quantity}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.grey.shade700,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 28,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: isSubmitting ? null : onSubmit,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: isSubmitting
|
|
||||||
? Colors.grey.shade300
|
|
||||||
: Colors.orange.shade600,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text(
|
|
||||||
'加入本箱',
|
|
||||||
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w700),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ class SingleCodeBody extends StatelessWidget {
|
|||||||
final ValueChanged<CurrentZongpaiBoxData> onStartDeleteAssigned;
|
final ValueChanged<CurrentZongpaiBoxData> onStartDeleteAssigned;
|
||||||
final ValueChanged<CurrentZongpaiBoxData> onDeleteAssignedItem;
|
final ValueChanged<CurrentZongpaiBoxData> onDeleteAssignedItem;
|
||||||
final VoidCallback onCancelDeleteAssigned;
|
final VoidCallback onCancelDeleteAssigned;
|
||||||
final List<PendingAccessory> pendingAccessories;
|
|
||||||
final ValueChanged<PendingAccessory> onSubmitAccessory;
|
|
||||||
|
|
||||||
const SingleCodeBody({
|
const SingleCodeBody({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -76,8 +74,6 @@ class SingleCodeBody extends StatelessWidget {
|
|||||||
required this.onStartDeleteAssigned,
|
required this.onStartDeleteAssigned,
|
||||||
required this.onDeleteAssignedItem,
|
required this.onDeleteAssignedItem,
|
||||||
required this.onCancelDeleteAssigned,
|
required this.onCancelDeleteAssigned,
|
||||||
required this.pendingAccessories,
|
|
||||||
required this.onSubmitAccessory,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -118,12 +114,6 @@ class SingleCodeBody extends StatelessWidget {
|
|||||||
onDeleteAssignedItem: onDeleteAssignedItem,
|
onDeleteAssignedItem: onDeleteAssignedItem,
|
||||||
onCancelDeleteAssigned: onCancelDeleteAssigned,
|
onCancelDeleteAssigned: onCancelDeleteAssigned,
|
||||||
),
|
),
|
||||||
if (pendingAccessories.isNotEmpty && !isWaiting)
|
|
||||||
_PendingAccessoriesSection(
|
|
||||||
pendingAccessories: pendingAccessories,
|
|
||||||
isSubmitting: isSubmitting,
|
|
||||||
onSubmitAccessory: onSubmitAccessory,
|
|
||||||
),
|
|
||||||
_SingleBottomArea(
|
_SingleBottomArea(
|
||||||
disabled: isWaiting || isFinished,
|
disabled: isWaiting || isFinished,
|
||||||
boxNoController: boxNoController,
|
boxNoController: boxNoController,
|
||||||
@@ -249,7 +239,9 @@ class _SingleInfoBar extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: isWaiting ? Colors.grey.shade400 : Colors.black87,
|
color: isWaiting
|
||||||
|
? Colors.grey.shade400
|
||||||
|
: Colors.black87,
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
@@ -260,7 +252,9 @@ class _SingleInfoBar extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
isWaiting ? '已有 -- 箱' : '已有 ${existingBoxes.length} 箱',
|
isWaiting
|
||||||
|
? '已有 -- 箱'
|
||||||
|
: '已有 ${existingBoxes.length} 箱',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: isWaiting
|
color: isWaiting
|
||||||
@@ -269,7 +263,9 @@ class _SingleInfoBar extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
isWaiting ? '最大箱号 --' : '最大箱号 $maxBoxNo',
|
isWaiting
|
||||||
|
? '最大箱号 --'
|
||||||
|
: '最大箱号 $maxBoxNo',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: isWaiting
|
color: isWaiting
|
||||||
@@ -580,120 +576,3 @@ class _SingleBottomArea extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PendingAccessoriesSection extends StatelessWidget {
|
|
||||||
final List<PendingAccessory> pendingAccessories;
|
|
||||||
final bool isSubmitting;
|
|
||||||
final ValueChanged<PendingAccessory> onSubmitAccessory;
|
|
||||||
|
|
||||||
const _PendingAccessoriesSection({
|
|
||||||
required this.pendingAccessories,
|
|
||||||
required this.isSubmitting,
|
|
||||||
required this.onSubmitAccessory,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 28,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.orange.shade50,
|
|
||||||
border: Border(bottom: BorderSide(color: Colors.orange.shade200)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.build, size: 14, color: Colors.orange.shade700),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Text(
|
|
||||||
'待装箱附件(${pendingAccessories.length} 项)',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 11,
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: Colors.orange.shade800,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
...pendingAccessories.map(
|
|
||||||
(acc) => _AccessoryRow(
|
|
||||||
accessory: acc,
|
|
||||||
isSubmitting: isSubmitting,
|
|
||||||
onSubmit: () => onSubmitAccessory(acc),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AccessoryRow extends StatelessWidget {
|
|
||||||
final PendingAccessory accessory;
|
|
||||||
final bool isSubmitting;
|
|
||||||
final VoidCallback onSubmit;
|
|
||||||
|
|
||||||
const _AccessoryRow({
|
|
||||||
required this.accessory,
|
|
||||||
required this.isSubmitting,
|
|
||||||
required this.onSubmit,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
height: 36,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.orange.shade50,
|
|
||||||
border: Border(bottom: BorderSide(color: Colors.grey.shade200)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 40,
|
|
||||||
child: Text(
|
|
||||||
accessory.accessoryType,
|
|
||||||
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 20,
|
|
||||||
child: Text(
|
|
||||||
'\u00d7${accessory.quantity}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.grey.shade700,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 28,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: isSubmitting ? null : onSubmit,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: isSubmitting
|
|
||||||
? Colors.grey.shade300
|
|
||||||
: Colors.orange.shade600,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text(
|
|
||||||
'加入本箱',
|
|
||||||
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w700),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -103,40 +103,15 @@ class BoxingDetailPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: box.items.map((item) {
|
children: box.items.map((item) {
|
||||||
final isAccessory = item.itemType == 'accessory';
|
return Padding(
|
||||||
return Container(
|
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 4,
|
|
||||||
horizontal: 4,
|
|
||||||
),
|
|
||||||
margin: const EdgeInsets.symmetric(vertical: 1),
|
|
||||||
decoration: isAccessory
|
|
||||||
? BoxDecoration(
|
|
||||||
color: Colors.orange.shade50,
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (isAccessory)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 6),
|
|
||||||
child: Icon(
|
|
||||||
Icons.build,
|
|
||||||
size: 14,
|
|
||||||
color: Colors.orange.shade700,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
item.zongpaiNo,
|
item.zongpaiNo,
|
||||||
style: TextStyle(
|
style: const TextStyle(fontSize: 14),
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: isAccessory
|
|
||||||
? FontWeight.w600
|
|
||||||
: FontWeight.normal,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -107,9 +107,6 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
|||||||
// 多码凑箱:已完成装箱时可跳转的箱号
|
// 多码凑箱:已完成装箱时可跳转的箱号
|
||||||
int? _completedJumpBoxNo;
|
int? _completedJumpBoxNo;
|
||||||
|
|
||||||
// 待装箱附件
|
|
||||||
List<PendingAccessory> _pendingAccessories = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -247,7 +244,6 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
|||||||
_isDuplicateBoxNo = false;
|
_isDuplicateBoxNo = false;
|
||||||
_statusOverrideText = null;
|
_statusOverrideText = null;
|
||||||
_statusOverrideDot = null;
|
_statusOverrideDot = null;
|
||||||
_pendingAccessories = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === 重复箱号检测 ===
|
// === 重复箱号检测 ===
|
||||||
@@ -419,9 +415,6 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
|||||||
this._deletePackedItem(item),
|
this._deletePackedItem(item),
|
||||||
onCancelDeletePackedItem: () =>
|
onCancelDeletePackedItem: () =>
|
||||||
setState(() => _deletingPackedItemId = null),
|
setState(() => _deletingPackedItemId = null),
|
||||||
pendingAccessories: _pendingAccessories,
|
|
||||||
onSubmitAccessory: (accessory) =>
|
|
||||||
this._submitAccessory(accessory),
|
|
||||||
)
|
)
|
||||||
: SingleCodeBody(
|
: SingleCodeBody(
|
||||||
isWaiting:
|
isWaiting:
|
||||||
@@ -472,9 +465,6 @@ class _BoxingPageState extends State<BoxingPage> with WidgetsBindingObserver {
|
|||||||
this._deleteAssignedItem(item),
|
this._deleteAssignedItem(item),
|
||||||
onCancelDeleteAssigned: () =>
|
onCancelDeleteAssigned: () =>
|
||||||
setState(() => _deletingAssignedItemId = null),
|
setState(() => _deletingAssignedItemId = null),
|
||||||
pendingAccessories: _pendingAccessories,
|
|
||||||
onSubmitAccessory: (accessory) =>
|
|
||||||
this._submitAccessory(accessory),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ import 'package:pad_scanner/services/app_config_service.dart';
|
|||||||
import 'package:pad_scanner/pages/settings_page.dart';
|
import 'package:pad_scanner/pages/settings_page.dart';
|
||||||
import 'package:pad_scanner/pages/registration_page.dart';
|
import 'package:pad_scanner/pages/registration_page.dart';
|
||||||
import 'package:pad_scanner/pages/boxing_page.dart';
|
import 'package:pad_scanner/pages/boxing_page.dart';
|
||||||
import 'package:pad_scanner/pages/accessory_page.dart';
|
|
||||||
import 'package:pad_scanner/services/api_service.dart';
|
import 'package:pad_scanner/services/api_service.dart';
|
||||||
|
|
||||||
/// Module type enum for each available feature card
|
/// Module type enum for each available feature card
|
||||||
enum ModuleType { registration, boxing, accessory, shelfQuery }
|
enum ModuleType { registration, boxing, shelfQuery }
|
||||||
|
|
||||||
/// Module status for PRD state tracking
|
/// Module status for PRD state tracking
|
||||||
enum ModuleStatus { online, developing, planning }
|
enum ModuleStatus { online, developing, planning }
|
||||||
@@ -64,17 +63,9 @@ class _HomePageState extends State<HomePage> {
|
|||||||
status: ModuleStatus.online,
|
status: ModuleStatus.online,
|
||||||
route: '/boxing',
|
route: '/boxing',
|
||||||
),
|
),
|
||||||
FeatureCard(
|
|
||||||
type: ModuleType.accessory,
|
|
||||||
shortcut: '3',
|
|
||||||
icon: Icons.build,
|
|
||||||
title: '附件登记',
|
|
||||||
status: ModuleStatus.developing,
|
|
||||||
route: '/accessory',
|
|
||||||
),
|
|
||||||
FeatureCard(
|
FeatureCard(
|
||||||
type: ModuleType.shelfQuery,
|
type: ModuleType.shelfQuery,
|
||||||
shortcut: '4',
|
shortcut: '3',
|
||||||
icon: Icons.search_outlined,
|
icon: Icons.search_outlined,
|
||||||
title: '货架查询',
|
title: '货架查询',
|
||||||
status: ModuleStatus.planning,
|
status: ModuleStatus.planning,
|
||||||
@@ -110,10 +101,16 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
FeatureCard? _moduleFromShortcut(KeyEvent event) {
|
FeatureCard? _moduleFromShortcut(KeyEvent event) {
|
||||||
final shortcut = _shortcutNumberFromKeyEvent(event);
|
final shortcut = _shortcutNumberFromKeyEvent(event);
|
||||||
if (shortcut == null || shortcut < 1 || shortcut > _modules.length) {
|
if (shortcut == 1) {
|
||||||
return null;
|
return _modules[0];
|
||||||
}
|
}
|
||||||
return _modules[shortcut - 1];
|
if (shortcut == 2) {
|
||||||
|
return _modules[1];
|
||||||
|
}
|
||||||
|
if (shortcut == 3) {
|
||||||
|
return _modules[2];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int? _shortcutNumberFromKeyEvent(KeyEvent event) {
|
int? _shortcutNumberFromKeyEvent(KeyEvent event) {
|
||||||
@@ -133,11 +130,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
event.character == '3') {
|
event.character == '3') {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
if (key == LogicalKeyboardKey.digit4 ||
|
|
||||||
key == LogicalKeyboardKey.numpad4 ||
|
|
||||||
event.character == '4') {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +181,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
case ModuleType.boxing:
|
case ModuleType.boxing:
|
||||||
targetPage = const BoxingPage();
|
targetPage = const BoxingPage();
|
||||||
break;
|
break;
|
||||||
case ModuleType.accessory:
|
|
||||||
targetPage = const AccessoryPage();
|
|
||||||
break;
|
|
||||||
case ModuleType.shelfQuery:
|
case ModuleType.shelfQuery:
|
||||||
return; // 规划中,不导航
|
return; // 规划中,不导航
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ extension _RegistrationDialogsPart on _RegistrationPageState {
|
|||||||
void _showLocationConflictDialog({
|
void _showLocationConflictDialog({
|
||||||
required List<PaichaOverviewItem> onShelfItems,
|
required List<PaichaOverviewItem> onShelfItems,
|
||||||
required List<PaichaOverviewItem> transferredItems,
|
required List<PaichaOverviewItem> transferredItems,
|
||||||
|
List<PaichaOverviewItem> tempStoredItems = const [],
|
||||||
}) {
|
}) {
|
||||||
final contentParts = <Widget>[];
|
final contentParts = <Widget>[];
|
||||||
|
|
||||||
@@ -142,6 +143,29 @@ extension _RegistrationDialogsPart on _RegistrationPageState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tempStoredItems.isNotEmpty) {
|
||||||
|
if (onShelfItems.isNotEmpty || transferredItems.isNotEmpty) {
|
||||||
|
contentParts.add(const Divider());
|
||||||
|
contentParts.add(const SizedBox(height: 4));
|
||||||
|
}
|
||||||
|
contentParts.add(
|
||||||
|
Text(
|
||||||
|
'暂存中',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: const Color(0xFF7B1FA2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
for (final item in tempStoredItems) {
|
||||||
|
contentParts.addAll([
|
||||||
|
Text('总排号:${item.zongpaiNo}'),
|
||||||
|
Text('暂存货位:${item.locationCode ?? "未知"}'),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contentParts.add(const SizedBox(height: 4));
|
contentParts.add(const SizedBox(height: 4));
|
||||||
contentParts.add(
|
contentParts.add(
|
||||||
const Text(
|
const Text(
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ extension _RegistrationOverviewPart on _RegistrationPageState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Find all scanned items that are in temp storage.
|
||||||
|
List<PaichaOverviewItem> _findTempStoredItemsInScanned() {
|
||||||
|
return registration_calculations.findTempStoredItemsInScanned(
|
||||||
|
overview: _overview,
|
||||||
|
zongpaiNos: _zongpaiNos,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<String?> _baseUrl() async {
|
Future<String?> _baseUrl() async {
|
||||||
final configService = AppConfigService();
|
final configService = AppConfigService();
|
||||||
final baseUrl = await configService.getString('api_url') ?? '';
|
final baseUrl = await configService.getString('api_url') ?? '';
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ extension _RegistrationScanPart on _RegistrationPageState {
|
|||||||
_handleZongpaiScan(parsed.value);
|
_handleZongpaiScan(parsed.value);
|
||||||
case CodeType.locationNormal:
|
case CodeType.locationNormal:
|
||||||
case CodeType.locationTransit:
|
case CodeType.locationTransit:
|
||||||
|
case CodeType.locationTempStorage:
|
||||||
_handleLocationScan(parsed.value, parsed.type);
|
_handleLocationScan(parsed.value, parsed.type);
|
||||||
case CodeType.invalid:
|
case CodeType.invalid:
|
||||||
_feedbackService.trigger(FeedbackEvent.scanInvalid);
|
_feedbackService.trigger(FeedbackEvent.scanInvalid);
|
||||||
|
|||||||
@@ -52,4 +52,7 @@ extension _RegistrationStatusPart on _RegistrationPageState {
|
|||||||
_zongpaiNos.isNotEmpty && _locationCode != null && !_isSubmitting;
|
_zongpaiNos.isNotEmpty && _locationCode != null && !_isSubmitting;
|
||||||
|
|
||||||
bool get _isTransitTarget => isTransitTarget(_locationType, _locationCode);
|
bool get _isTransitTarget => isTransitTarget(_locationType, _locationCode);
|
||||||
|
|
||||||
|
bool get _isTempStorageTarget =>
|
||||||
|
isTempStorageTarget(_locationType, _locationCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,23 @@ extension _RegistrationSubmitPart on _RegistrationPageState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For temp storage target: block if any scanned item is transferred or temp_stored
|
||||||
|
// (on_shelf items are allowed — temp storage acts as shelf change)
|
||||||
|
if (_isTempStorageTarget) {
|
||||||
|
final transferredItems = _findTransferredItemsInScanned();
|
||||||
|
final tempStoredItems = _findTempStoredItemsInScanned();
|
||||||
|
if (transferredItems.isNotEmpty || tempStoredItems.isNotEmpty) {
|
||||||
|
setState(() => _isSubmitting = false);
|
||||||
|
_feedbackService.trigger(FeedbackEvent.submitFailure);
|
||||||
|
_showLocationConflictDialog(
|
||||||
|
onShelfItems: [],
|
||||||
|
transferredItems: transferredItems,
|
||||||
|
tempStoredItems: tempStoredItems,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_mode == RegistrationMode.multiCode && _zongpaiNos.length > 1) {
|
if (_mode == RegistrationMode.multiCode && _zongpaiNos.length > 1) {
|
||||||
if (_isTransitTarget && !await _ensureBatchSamePaicha(baseUrl)) {
|
if (_isTransitTarget && !await _ensureBatchSamePaicha(baseUrl)) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
@@ -47,7 +64,7 @@ extension _RegistrationSubmitPart on _RegistrationPageState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Pre-check: block entire batch if any item already has a location binding
|
// Pre-check: block entire batch if any item already has a location binding
|
||||||
if (!_isTransitTarget) {
|
if (!_isTransitTarget && !_isTempStorageTarget) {
|
||||||
final onShelfItems = _findOnShelfItemsInScanned();
|
final onShelfItems = _findOnShelfItemsInScanned();
|
||||||
final transferredItems = _findTransferredItemsInScanned();
|
final transferredItems = _findTransferredItemsInScanned();
|
||||||
if (onShelfItems.isNotEmpty || transferredItems.isNotEmpty) {
|
if (onShelfItems.isNotEmpty || transferredItems.isNotEmpty) {
|
||||||
@@ -117,13 +134,15 @@ extension _RegistrationSubmitPart on _RegistrationPageState {
|
|||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_zongpaiNos.remove(zongpaiNo);
|
_zongpaiNos.remove(zongpaiNo);
|
||||||
if (_mode == RegistrationMode.singleCode) {
|
if (_mode == RegistrationMode.singleCode && !_isTempStorageTarget) {
|
||||||
_locationCode = null;
|
_locationCode = null;
|
||||||
_locationType = null;
|
_locationType = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
final msg = result.isOffShelfSuccess
|
final msg = result.isOffShelfSuccess
|
||||||
? '下架成功'
|
? '下架成功'
|
||||||
|
: _isTempStorageTarget
|
||||||
|
? '变更货架成功'
|
||||||
: (_mode == RegistrationMode.multiCode ? '多码上架模式,请扫描下一张执行卡' : '上架成功');
|
: (_mode == RegistrationMode.multiCode ? '多码上架模式,请扫描下一张执行卡' : '上架成功');
|
||||||
_showStatusOverride(
|
_showStatusOverride(
|
||||||
msg,
|
msg,
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ class RegistrationOverviewStats {
|
|||||||
final int totalCount;
|
final int totalCount;
|
||||||
final int shelvedCount;
|
final int shelvedCount;
|
||||||
final int transferredCount;
|
final int transferredCount;
|
||||||
|
final int tempStoredCount;
|
||||||
|
|
||||||
const RegistrationOverviewStats({
|
const RegistrationOverviewStats({
|
||||||
required this.totalCount,
|
required this.totalCount,
|
||||||
required this.shelvedCount,
|
required this.shelvedCount,
|
||||||
required this.transferredCount,
|
required this.transferredCount,
|
||||||
|
required this.tempStoredCount,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,17 +33,21 @@ RegistrationOverviewStats overviewStats(PaichaOverviewResult? overview) {
|
|||||||
totalCount: 0,
|
totalCount: 0,
|
||||||
shelvedCount: 0,
|
shelvedCount: 0,
|
||||||
transferredCount: 0,
|
transferredCount: 0,
|
||||||
|
tempStoredCount: 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var shelvedCount = 0;
|
var shelvedCount = 0;
|
||||||
var transferredCount = 0;
|
var transferredCount = 0;
|
||||||
|
var tempStoredCount = 0;
|
||||||
for (final item in overview!.items) {
|
for (final item in overview!.items) {
|
||||||
switch (item.status) {
|
switch (item.status) {
|
||||||
case 'on_shelf':
|
case 'on_shelf':
|
||||||
shelvedCount++;
|
shelvedCount++;
|
||||||
case 'transferred':
|
case 'transferred':
|
||||||
transferredCount++;
|
transferredCount++;
|
||||||
|
case 'temp_stored':
|
||||||
|
tempStoredCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +55,7 @@ RegistrationOverviewStats overviewStats(PaichaOverviewResult? overview) {
|
|||||||
totalCount: overview.totalCount,
|
totalCount: overview.totalCount,
|
||||||
shelvedCount: shelvedCount,
|
shelvedCount: shelvedCount,
|
||||||
transferredCount: transferredCount,
|
transferredCount: transferredCount,
|
||||||
|
tempStoredCount: tempStoredCount,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +98,17 @@ List<PaichaOverviewItem> findTransferredItemsInScanned({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<PaichaOverviewItem> findTempStoredItemsInScanned({
|
||||||
|
required PaichaOverviewResult? overview,
|
||||||
|
required Iterable<String> zongpaiNos,
|
||||||
|
}) {
|
||||||
|
return _findScannedItemsByStatus(
|
||||||
|
overview: overview,
|
||||||
|
zongpaiNos: zongpaiNos,
|
||||||
|
status: 'temp_stored',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
bool hasAnyLocatedInScanned({
|
bool hasAnyLocatedInScanned({
|
||||||
required PaichaOverviewResult? overview,
|
required PaichaOverviewResult? overview,
|
||||||
required Iterable<String> zongpaiNos,
|
required Iterable<String> zongpaiNos,
|
||||||
@@ -100,7 +118,9 @@ bool hasAnyLocatedInScanned({
|
|||||||
return overview!.items.any(
|
return overview!.items.any(
|
||||||
(item) =>
|
(item) =>
|
||||||
scannedSet.contains(item.zongpaiNo) &&
|
scannedSet.contains(item.zongpaiNo) &&
|
||||||
(item.status == 'on_shelf' || item.status == 'transferred'),
|
(item.status == 'on_shelf' ||
|
||||||
|
item.status == 'transferred' ||
|
||||||
|
item.status == 'temp_stored'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,10 +128,13 @@ Color registrationBarColor({
|
|||||||
required String status,
|
required String status,
|
||||||
required bool isScanned,
|
required bool isScanned,
|
||||||
required bool isTransitTarget,
|
required bool isTransitTarget,
|
||||||
|
bool isTempStorageTarget = false,
|
||||||
}) {
|
}) {
|
||||||
if (isScanned) {
|
if (isScanned) {
|
||||||
final isConflict = isTransitTarget
|
final isConflict = isTransitTarget
|
||||||
? status == 'transferred'
|
? status == 'transferred'
|
||||||
|
: isTempStorageTarget
|
||||||
|
? (status == 'transferred' || status == 'temp_stored')
|
||||||
: (status == 'on_shelf' || status == 'transferred');
|
: (status == 'on_shelf' || status == 'transferred');
|
||||||
return isConflict ? Colors.red : const Color(0xFF43A047);
|
return isConflict ? Colors.red : const Color(0xFF43A047);
|
||||||
}
|
}
|
||||||
@@ -119,6 +142,8 @@ Color registrationBarColor({
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case 'on_shelf':
|
case 'on_shelf':
|
||||||
return const Color(0xFF2196F3);
|
return const Color(0xFF2196F3);
|
||||||
|
case 'temp_stored':
|
||||||
|
return const Color(0xFF7B1FA2);
|
||||||
case 'transferred':
|
case 'transferred':
|
||||||
return const Color(0xFFFF9800);
|
return const Color(0xFFFF9800);
|
||||||
default:
|
default:
|
||||||
@@ -130,10 +155,13 @@ Color registrationRowBgColor({
|
|||||||
required String status,
|
required String status,
|
||||||
required bool isScanned,
|
required bool isScanned,
|
||||||
required bool isTransitTarget,
|
required bool isTransitTarget,
|
||||||
|
bool isTempStorageTarget = false,
|
||||||
}) {
|
}) {
|
||||||
if (isScanned) {
|
if (isScanned) {
|
||||||
final isConflict = isTransitTarget
|
final isConflict = isTransitTarget
|
||||||
? status == 'transferred'
|
? status == 'transferred'
|
||||||
|
: isTempStorageTarget
|
||||||
|
? (status == 'transferred' || status == 'temp_stored')
|
||||||
: (status == 'on_shelf' || status == 'transferred');
|
: (status == 'on_shelf' || status == 'transferred');
|
||||||
return isConflict ? Colors.red.shade50 : const Color(0xFFF1F8E9);
|
return isConflict ? Colors.red.shade50 : const Color(0xFFF1F8E9);
|
||||||
}
|
}
|
||||||
@@ -141,6 +169,8 @@ Color registrationRowBgColor({
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case 'on_shelf':
|
case 'on_shelf':
|
||||||
return const Color(0xFFE3F2FD);
|
return const Color(0xFFE3F2FD);
|
||||||
|
case 'temp_stored':
|
||||||
|
return const Color(0xFFF3E5F5);
|
||||||
case 'transferred':
|
case 'transferred':
|
||||||
return const Color(0xFFFFF3E0);
|
return const Color(0xFFFFF3E0);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ part of '../../registration_page.dart';
|
|||||||
extension _RegistrationWidgetsPart on _RegistrationPageState {
|
extension _RegistrationWidgetsPart on _RegistrationPageState {
|
||||||
String _locationLabel(CodeType? type) {
|
String _locationLabel(CodeType? type) {
|
||||||
if (type == CodeType.locationTransit) return '转运区域';
|
if (type == CodeType.locationTransit) return '转运区域';
|
||||||
|
if (type == CodeType.locationTempStorage) return '暂存货架';
|
||||||
return '普通货架';
|
return '普通货架';
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _locationLabelColor(CodeType? type) {
|
Color _locationLabelColor(CodeType? type) {
|
||||||
if (type == CodeType.locationTransit) return Colors.orange;
|
if (type == CodeType.locationTransit) return Colors.orange;
|
||||||
|
if (type == CodeType.locationTempStorage) return const Color(0xFF7B1FA2);
|
||||||
return Colors.blue;
|
return Colors.blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +110,12 @@ extension _RegistrationWidgetsPart on _RegistrationPageState {
|
|||||||
const Color(0xFFE65100),
|
const Color(0xFFE65100),
|
||||||
hasData,
|
hasData,
|
||||||
),
|
),
|
||||||
|
_buildStatTag(
|
||||||
|
'暂存 ${stats.tempStoredCount}',
|
||||||
|
const Color(0xFFF3E5F5),
|
||||||
|
const Color(0xFF7B1FA2),
|
||||||
|
hasData,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -293,11 +301,13 @@ extension _RegistrationWidgetsPart on _RegistrationPageState {
|
|||||||
status: item.status,
|
status: item.status,
|
||||||
isScanned: isScanned,
|
isScanned: isScanned,
|
||||||
isTransitTarget: _isTransitTarget,
|
isTransitTarget: _isTransitTarget,
|
||||||
|
isTempStorageTarget: _isTempStorageTarget,
|
||||||
);
|
);
|
||||||
final bgColor = registration_calculations.registrationRowBgColor(
|
final bgColor = registration_calculations.registrationRowBgColor(
|
||||||
status: item.status,
|
status: item.status,
|
||||||
isScanned: isScanned,
|
isScanned: isScanned,
|
||||||
isTransitTarget: _isTransitTarget,
|
isTransitTarget: _isTransitTarget,
|
||||||
|
isTempStorageTarget: _isTempStorageTarget,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
|
|||||||
@@ -118,30 +118,6 @@ class PaichaOverviewResult {
|
|||||||
|
|
||||||
// === 装箱模块数据类 ===
|
// === 装箱模块数据类 ===
|
||||||
|
|
||||||
/// 待装箱附件
|
|
||||||
class PendingAccessory {
|
|
||||||
final int accessoryId;
|
|
||||||
final String accessoryType;
|
|
||||||
final int quantity;
|
|
||||||
final String? locationCode;
|
|
||||||
|
|
||||||
PendingAccessory({
|
|
||||||
required this.accessoryId,
|
|
||||||
required this.accessoryType,
|
|
||||||
required this.quantity,
|
|
||||||
this.locationCode,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory PendingAccessory.fromJson(Map<String, dynamic> json) {
|
|
||||||
return PendingAccessory(
|
|
||||||
accessoryId: json['accessory_id'] as int,
|
|
||||||
accessoryType: json['accessory_type'] as String,
|
|
||||||
quantity: json['quantity'] as int,
|
|
||||||
locationCode: json['location_code']?.toString(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 箱号内单个总排号明细
|
/// 箱号内单个总排号明细
|
||||||
class BoxItemData {
|
class BoxItemData {
|
||||||
final int? boxItemId;
|
final int? boxItemId;
|
||||||
@@ -149,7 +125,6 @@ class BoxItemData {
|
|||||||
final String? workOrderNo;
|
final String? workOrderNo;
|
||||||
final int quantity;
|
final int quantity;
|
||||||
final int? totalQuantity;
|
final int? totalQuantity;
|
||||||
final String itemType;
|
|
||||||
|
|
||||||
BoxItemData({
|
BoxItemData({
|
||||||
this.boxItemId,
|
this.boxItemId,
|
||||||
@@ -157,7 +132,6 @@ class BoxItemData {
|
|||||||
this.workOrderNo,
|
this.workOrderNo,
|
||||||
required this.quantity,
|
required this.quantity,
|
||||||
this.totalQuantity,
|
this.totalQuantity,
|
||||||
this.itemType = 'product',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory BoxItemData.fromJson(Map<String, dynamic> json) {
|
factory BoxItemData.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -167,7 +141,6 @@ class BoxItemData {
|
|||||||
workOrderNo: json['work_order_no']?.toString(),
|
workOrderNo: json['work_order_no']?.toString(),
|
||||||
quantity: json['quantity'] as int,
|
quantity: json['quantity'] as int,
|
||||||
totalQuantity: json['total_quantity'] as int?,
|
totalQuantity: json['total_quantity'] as int?,
|
||||||
itemType: json['item_type'] as String? ?? 'product',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,13 +167,11 @@ class CurrentZongpaiBoxData {
|
|||||||
final int boxItemId;
|
final int boxItemId;
|
||||||
final int boxNo;
|
final int boxNo;
|
||||||
final int quantity;
|
final int quantity;
|
||||||
final String itemType;
|
|
||||||
|
|
||||||
CurrentZongpaiBoxData({
|
CurrentZongpaiBoxData({
|
||||||
required this.boxItemId,
|
required this.boxItemId,
|
||||||
required this.boxNo,
|
required this.boxNo,
|
||||||
required this.quantity,
|
required this.quantity,
|
||||||
this.itemType = 'product',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory CurrentZongpaiBoxData.fromJson(Map<String, dynamic> json) {
|
factory CurrentZongpaiBoxData.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -208,7 +179,6 @@ class CurrentZongpaiBoxData {
|
|||||||
boxItemId: json['box_item_id'] as int,
|
boxItemId: json['box_item_id'] as int,
|
||||||
boxNo: json['box_no'] as int,
|
boxNo: json['box_no'] as int,
|
||||||
quantity: json['quantity'] as int,
|
quantity: json['quantity'] as int,
|
||||||
itemType: json['item_type'] as String? ?? 'product',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,7 +195,6 @@ class BoxInfoResult {
|
|||||||
final List<BoxDetailData> existingBoxes;
|
final List<BoxDetailData> existingBoxes;
|
||||||
final int maxBoxNo;
|
final int maxBoxNo;
|
||||||
final int suggestedBoxNo;
|
final int suggestedBoxNo;
|
||||||
final List<PendingAccessory> pendingAccessories;
|
|
||||||
|
|
||||||
BoxInfoResult({
|
BoxInfoResult({
|
||||||
required this.success,
|
required this.success,
|
||||||
@@ -238,7 +207,6 @@ class BoxInfoResult {
|
|||||||
this.existingBoxes = const [],
|
this.existingBoxes = const [],
|
||||||
this.maxBoxNo = 0,
|
this.maxBoxNo = 0,
|
||||||
this.suggestedBoxNo = 1,
|
this.suggestedBoxNo = 1,
|
||||||
this.pendingAccessories = const [],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory BoxInfoResult.ok(Map<String, dynamic> json) {
|
factory BoxInfoResult.ok(Map<String, dynamic> json) {
|
||||||
@@ -254,11 +222,6 @@ class BoxInfoResult {
|
|||||||
)
|
)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
[];
|
[];
|
||||||
final pendingAccessories =
|
|
||||||
(json['pending_accessories'] as List<dynamic>?)
|
|
||||||
?.map((a) => PendingAccessory.fromJson(a as Map<String, dynamic>))
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
return BoxInfoResult(
|
return BoxInfoResult(
|
||||||
success: true,
|
success: true,
|
||||||
zongpaiNo: json['zongpai_no'] as String?,
|
zongpaiNo: json['zongpai_no'] as String?,
|
||||||
@@ -269,7 +232,6 @@ class BoxInfoResult {
|
|||||||
existingBoxes: boxes,
|
existingBoxes: boxes,
|
||||||
maxBoxNo: json['max_box_no'] as int? ?? 0,
|
maxBoxNo: json['max_box_no'] as int? ?? 0,
|
||||||
suggestedBoxNo: json['suggested_box_no'] as int? ?? 1,
|
suggestedBoxNo: json['suggested_box_no'] as int? ?? 1,
|
||||||
pendingAccessories: pendingAccessories,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,163 +299,6 @@ class BoxDeleteResult {
|
|||||||
BoxDeleteResult({required this.success, this.errorMessage});
|
BoxDeleteResult({required this.success, this.errorMessage});
|
||||||
}
|
}
|
||||||
|
|
||||||
// === 附件模块数据类 ===
|
|
||||||
|
|
||||||
/// 工令号分组(工令号 → 总排号列表)
|
|
||||||
class WorkOrderGroup {
|
|
||||||
final String workOrderNo;
|
|
||||||
final List<String> zongpaiNos;
|
|
||||||
WorkOrderGroup({required this.workOrderNo, required this.zongpaiNos});
|
|
||||||
factory WorkOrderGroup.fromJson(Map<String, dynamic> json) => WorkOrderGroup(
|
|
||||||
workOrderNo: json['work_order_no'] as String,
|
|
||||||
zongpaiNos: (json['zongpai_nos'] as List).map((e) => e as String).toList(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件类型预设
|
|
||||||
class AccessoryTypeInfo {
|
|
||||||
final int id;
|
|
||||||
final String name;
|
|
||||||
final int sortOrder;
|
|
||||||
AccessoryTypeInfo({
|
|
||||||
required this.id,
|
|
||||||
required this.name,
|
|
||||||
required this.sortOrder,
|
|
||||||
});
|
|
||||||
factory AccessoryTypeInfo.fromJson(Map<String, dynamic> json) =>
|
|
||||||
AccessoryTypeInfo(
|
|
||||||
id: json['id'] as int,
|
|
||||||
name: json['name'] as String,
|
|
||||||
sortOrder: json['sort_order'] as int,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件记录
|
|
||||||
class AccessoryRecord {
|
|
||||||
final int id;
|
|
||||||
final String paichanNo;
|
|
||||||
final String zongpaiNo;
|
|
||||||
final String accessoryType;
|
|
||||||
final int quantity;
|
|
||||||
final String? locationCode;
|
|
||||||
final bool isBoxed;
|
|
||||||
final String createdAt;
|
|
||||||
AccessoryRecord({
|
|
||||||
required this.id,
|
|
||||||
required this.paichanNo,
|
|
||||||
required this.zongpaiNo,
|
|
||||||
required this.accessoryType,
|
|
||||||
required this.quantity,
|
|
||||||
this.locationCode,
|
|
||||||
required this.isBoxed,
|
|
||||||
required this.createdAt,
|
|
||||||
});
|
|
||||||
factory AccessoryRecord.fromJson(Map<String, dynamic> json) =>
|
|
||||||
AccessoryRecord(
|
|
||||||
id: json['id'] as int,
|
|
||||||
paichanNo: json['paichan_no'] as String,
|
|
||||||
zongpaiNo: json['zongpai_no'] as String,
|
|
||||||
accessoryType: json['accessory_type'] as String,
|
|
||||||
quantity: json['quantity'] as int,
|
|
||||||
locationCode: json['location_code'] as String?,
|
|
||||||
isBoxed: json['is_boxed'] as bool,
|
|
||||||
createdAt: json['created_at'] as String,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// === 附件模块结果类 ===
|
|
||||||
|
|
||||||
class WorkOrderQueryResult {
|
|
||||||
final bool success;
|
|
||||||
final String? paichanNo;
|
|
||||||
final List<WorkOrderGroup> workOrders;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
WorkOrderQueryResult({
|
|
||||||
required this.success,
|
|
||||||
this.paichanNo,
|
|
||||||
this.workOrders = const [],
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessoryListResult {
|
|
||||||
final bool success;
|
|
||||||
final List<AccessoryRecord> items;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
AccessoryListResult({
|
|
||||||
required this.success,
|
|
||||||
this.items = const [],
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessoryCreateResult {
|
|
||||||
final bool success;
|
|
||||||
final AccessoryRecord? record;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
AccessoryCreateResult({
|
|
||||||
required this.success,
|
|
||||||
this.record,
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessoryUpdateResult {
|
|
||||||
final bool success;
|
|
||||||
final AccessoryRecord? record;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
AccessoryUpdateResult({
|
|
||||||
required this.success,
|
|
||||||
this.record,
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessoryDeleteResult {
|
|
||||||
final bool success;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
AccessoryDeleteResult({
|
|
||||||
required this.success,
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessoryTypeListResult {
|
|
||||||
final bool success;
|
|
||||||
final List<AccessoryTypeInfo> types;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
AccessoryTypeListResult({
|
|
||||||
required this.success,
|
|
||||||
this.types = const [],
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessoryTypeCreateResult {
|
|
||||||
final bool success;
|
|
||||||
final AccessoryTypeInfo? type;
|
|
||||||
final String? errorMessage;
|
|
||||||
final String? errorCode;
|
|
||||||
AccessoryTypeCreateResult({
|
|
||||||
required this.success,
|
|
||||||
this.type,
|
|
||||||
this.errorMessage,
|
|
||||||
this.errorCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class ApiService {
|
class ApiService {
|
||||||
final http.Client _client;
|
final http.Client _client;
|
||||||
final Duration timeout;
|
final Duration timeout;
|
||||||
@@ -618,25 +423,18 @@ class ApiService {
|
|||||||
required String zongpaiNo,
|
required String zongpaiNo,
|
||||||
required int boxNo,
|
required int boxNo,
|
||||||
required int quantity,
|
required int quantity,
|
||||||
String itemType = 'product',
|
|
||||||
int? accessoryId,
|
|
||||||
}) async {
|
}) async {
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/box');
|
final uri = Uri.parse('$baseUrl/CargoTrace/box');
|
||||||
try {
|
try {
|
||||||
final bodyMap = <String, dynamic>{
|
|
||||||
'zongpai_no': zongpaiNo,
|
|
||||||
'box_no': boxNo,
|
|
||||||
'quantity': quantity,
|
|
||||||
'item_type': itemType,
|
|
||||||
};
|
|
||||||
if (accessoryId != null) {
|
|
||||||
bodyMap['accessory_id'] = accessoryId;
|
|
||||||
}
|
|
||||||
final response = await _client
|
final response = await _client
|
||||||
.post(
|
.post(
|
||||||
uri,
|
uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: jsonEncode(bodyMap),
|
body: jsonEncode({
|
||||||
|
'zongpai_no': zongpaiNo,
|
||||||
|
'box_no': boxNo,
|
||||||
|
'quantity': quantity,
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.timeout(timeout);
|
.timeout(timeout);
|
||||||
|
|
||||||
@@ -726,403 +524,6 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === 附件模块 API 方法 ===
|
|
||||||
|
|
||||||
/// 工令号查询 — GET /CargoTrace/accessory/work-orders
|
|
||||||
Future<WorkOrderQueryResult> queryWorkOrders({
|
|
||||||
required String baseUrl,
|
|
||||||
required String paichanNo,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse(
|
|
||||||
'$baseUrl/CargoTrace/accessory/work-orders',
|
|
||||||
).replace(queryParameters: {'paichan_no': paichanNo});
|
|
||||||
try {
|
|
||||||
final response = await _client
|
|
||||||
.get(uri, headers: {'Content-Type': 'application/json'})
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
final workOrders =
|
|
||||||
(body['work_orders'] as List<dynamic>?)
|
|
||||||
?.map(
|
|
||||||
(w) => WorkOrderGroup.fromJson(w as Map<String, dynamic>),
|
|
||||||
)
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
return WorkOrderQueryResult(
|
|
||||||
success: true,
|
|
||||||
paichanNo: body['paichan_no'] as String?,
|
|
||||||
workOrders: workOrders,
|
|
||||||
);
|
|
||||||
case 400:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return WorkOrderQueryResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '请求参数错误',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
case 404:
|
|
||||||
return WorkOrderQueryResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '未找到该排产号对应的工令号信息',
|
|
||||||
errorCode: 'NOT_FOUND',
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return WorkOrderQueryResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '查询失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return WorkOrderQueryResult(success: false, errorMessage: '网络异常,请检查网络连接');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件列表查询 — GET /CargoTrace/accessory
|
|
||||||
Future<AccessoryListResult> listAccessories({
|
|
||||||
required String baseUrl,
|
|
||||||
required String paichanNo,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse(
|
|
||||||
'$baseUrl/CargoTrace/accessory',
|
|
||||||
).replace(queryParameters: {'paichan_no': paichanNo});
|
|
||||||
try {
|
|
||||||
final response = await _client
|
|
||||||
.get(uri, headers: {'Content-Type': 'application/json'})
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
final items =
|
|
||||||
(body['items'] as List<dynamic>?)
|
|
||||||
?.map(
|
|
||||||
(i) => AccessoryRecord.fromJson(i as Map<String, dynamic>),
|
|
||||||
)
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
return AccessoryListResult(success: true, items: items);
|
|
||||||
case 400:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryListResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '请求参数错误',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
case 404:
|
|
||||||
return AccessoryListResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '未找到该排产号信息',
|
|
||||||
errorCode: 'NOT_FOUND',
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryListResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '查询失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryListResult(success: false, errorMessage: '网络异常,请检查网络连接');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件创建(上架) — POST /CargoTrace/accessory
|
|
||||||
Future<AccessoryCreateResult> createAccessory({
|
|
||||||
required String baseUrl,
|
|
||||||
required String paichanNo,
|
|
||||||
required String zongpaiNo,
|
|
||||||
required String accessoryType,
|
|
||||||
required int quantity,
|
|
||||||
String? locationCode,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/accessory');
|
|
||||||
try {
|
|
||||||
final bodyMap = <String, dynamic>{
|
|
||||||
'paichan_no': paichanNo,
|
|
||||||
'zongpai_no': zongpaiNo,
|
|
||||||
'accessory_type': accessoryType,
|
|
||||||
'quantity': quantity,
|
|
||||||
};
|
|
||||||
if (locationCode != null) {
|
|
||||||
bodyMap['location_code'] = locationCode;
|
|
||||||
}
|
|
||||||
final response = await _client
|
|
||||||
.post(
|
|
||||||
uri,
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: jsonEncode(bodyMap),
|
|
||||||
)
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryCreateResult(
|
|
||||||
success: true,
|
|
||||||
record: AccessoryRecord.fromJson(body),
|
|
||||||
);
|
|
||||||
case 400:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '请求参数错误',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
case 404:
|
|
||||||
return AccessoryCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '未找到该排产号对应的工令号信息',
|
|
||||||
errorCode: 'NOT_FOUND',
|
|
||||||
);
|
|
||||||
case 409:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '冲突',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '创建失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '网络异常,请检查网络连接',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件更新 — PATCH /CargoTrace/accessory/{id}
|
|
||||||
Future<AccessoryUpdateResult> updateAccessory({
|
|
||||||
required String baseUrl,
|
|
||||||
required int id,
|
|
||||||
String? accessoryType,
|
|
||||||
int? quantity,
|
|
||||||
String? locationCode,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/accessory/$id');
|
|
||||||
try {
|
|
||||||
final bodyMap = <String, dynamic>{};
|
|
||||||
if (accessoryType != null) bodyMap['accessory_type'] = accessoryType;
|
|
||||||
if (quantity != null) bodyMap['quantity'] = quantity;
|
|
||||||
if (locationCode != null) bodyMap['location_code'] = locationCode;
|
|
||||||
|
|
||||||
final response = await _client
|
|
||||||
.patch(
|
|
||||||
uri,
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: jsonEncode(bodyMap),
|
|
||||||
)
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryUpdateResult(
|
|
||||||
success: true,
|
|
||||||
record: AccessoryRecord.fromJson(body),
|
|
||||||
);
|
|
||||||
case 400:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryUpdateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '请求参数错误',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
case 404:
|
|
||||||
return AccessoryUpdateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '指定附件记录不存在',
|
|
||||||
errorCode: 'NOT_FOUND',
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryUpdateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '更新失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryUpdateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '网络异常,请检查网络连接',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件删除 — DELETE /CargoTrace/accessory/{id}
|
|
||||||
Future<AccessoryDeleteResult> deleteAccessory({
|
|
||||||
required String baseUrl,
|
|
||||||
required int id,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/accessory/$id');
|
|
||||||
try {
|
|
||||||
final response = await _client
|
|
||||||
.delete(uri, headers: {'Content-Type': 'application/json'})
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
return AccessoryDeleteResult(success: true);
|
|
||||||
case 404:
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '指定附件记录不存在',
|
|
||||||
errorCode: 'NOT_FOUND',
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '删除失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '网络异常,请检查网络连接',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件类型列表 — GET /CargoTrace/accessory-type
|
|
||||||
Future<AccessoryTypeListResult> listAccessoryTypes({
|
|
||||||
required String baseUrl,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/accessory-type');
|
|
||||||
try {
|
|
||||||
final response = await _client
|
|
||||||
.get(uri, headers: {'Content-Type': 'application/json'})
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
final types =
|
|
||||||
(body['types'] as List<dynamic>?)
|
|
||||||
?.map(
|
|
||||||
(t) =>
|
|
||||||
AccessoryTypeInfo.fromJson(t as Map<String, dynamic>),
|
|
||||||
)
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
return AccessoryTypeListResult(success: true, types: types);
|
|
||||||
case 400:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryTypeListResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '请求参数错误',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryTypeListResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '查询失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryTypeListResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '网络异常,请检查网络连接',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件类型创建 — POST /CargoTrace/accessory-type
|
|
||||||
Future<AccessoryTypeCreateResult> createAccessoryType({
|
|
||||||
required String baseUrl,
|
|
||||||
required String name,
|
|
||||||
int sortOrder = 0,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/accessory-type');
|
|
||||||
try {
|
|
||||||
final response = await _client
|
|
||||||
.post(
|
|
||||||
uri,
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: jsonEncode({'name': name, 'sort_order': sortOrder}),
|
|
||||||
)
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryTypeCreateResult(
|
|
||||||
success: true,
|
|
||||||
type: AccessoryTypeInfo.fromJson(body),
|
|
||||||
);
|
|
||||||
case 400:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryTypeCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '请求参数错误',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
case 409:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryTypeCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '附件类型已存在',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryTypeCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '创建失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryTypeCreateResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '网络异常,请检查网络连接',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 附件类型删除 — DELETE /CargoTrace/accessory-type/{id}
|
|
||||||
Future<AccessoryDeleteResult> deleteAccessoryType({
|
|
||||||
required String baseUrl,
|
|
||||||
required int id,
|
|
||||||
}) async {
|
|
||||||
final uri = Uri.parse('$baseUrl/CargoTrace/accessory-type/$id');
|
|
||||||
try {
|
|
||||||
final response = await _client
|
|
||||||
.delete(uri, headers: {'Content-Type': 'application/json'})
|
|
||||||
.timeout(timeout);
|
|
||||||
|
|
||||||
switch (response.statusCode) {
|
|
||||||
case 200:
|
|
||||||
return AccessoryDeleteResult(success: true);
|
|
||||||
case 404:
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '指定附件类型不存在',
|
|
||||||
errorCode: 'NOT_FOUND',
|
|
||||||
);
|
|
||||||
case 409:
|
|
||||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: body['message']?.toString() ?? '该类型下存在附件记录,无法删除',
|
|
||||||
errorCode: body['error_code']?.toString(),
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '删除失败 (${response.statusCode})',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return AccessoryDeleteResult(
|
|
||||||
success: false,
|
|
||||||
errorMessage: '网络异常,请检查网络连接',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Test connectivity by making a HEAD request to the base URL.
|
/// Test connectivity by making a HEAD request to the base URL.
|
||||||
Future<bool> testConnection(String baseUrl) async {
|
Future<bool> testConnection(String baseUrl) async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
// lib/services/code_parser.dart
|
// lib/services/code_parser.dart
|
||||||
class CodeParser {
|
class CodeParser {
|
||||||
static final _zongpaiRegex = RegExp(
|
static final _zongpaiRegex = RegExp(r'^\d{2}(B|C|T)\d+$|^\d{2}(BW|CW)\d{4}$');
|
||||||
r'^\d{2}(B|C|T)\d+$|^\d{2}(BW|CW)\d{4}$',
|
static final _locationRegex = RegExp(r'^[A-Z0-9]+-[A-Z0-9]+-[A-Z0-9]+$');
|
||||||
);
|
static final _transitRegex = RegExp(r'^TRANS-');
|
||||||
static final _locationRegex = RegExp(
|
|
||||||
r'^[A-Z0-9]+-[A-Z0-9]+-[A-Z0-9]+$',
|
|
||||||
);
|
|
||||||
static final _transitRegex = RegExp(
|
|
||||||
r'^TRANS-',
|
|
||||||
);
|
|
||||||
|
|
||||||
static ParseResult parse(String code) {
|
static ParseResult parse(String code) {
|
||||||
final trimmed = code.trim();
|
final trimmed = code.trim();
|
||||||
@@ -23,16 +17,30 @@ class CodeParser {
|
|||||||
return ParseResult(type: CodeType.zongpaiNo, value: normalized);
|
return ParseResult(type: CodeType.zongpaiNo, value: normalized);
|
||||||
}
|
}
|
||||||
if (_locationRegex.hasMatch(normalized)) {
|
if (_locationRegex.hasMatch(normalized)) {
|
||||||
|
if (normalized.startsWith('B')) {
|
||||||
|
return ParseResult(
|
||||||
|
type: CodeType.locationTempStorage,
|
||||||
|
value: normalized,
|
||||||
|
);
|
||||||
|
}
|
||||||
return ParseResult(type: CodeType.locationNormal, value: normalized);
|
return ParseResult(type: CodeType.locationNormal, value: normalized);
|
||||||
}
|
}
|
||||||
return ParseResult(type: CodeType.invalid, value: code);
|
return ParseResult(type: CodeType.invalid, value: code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isLocation(CodeType type) =>
|
static bool isLocation(CodeType type) =>
|
||||||
type == CodeType.locationNormal || type == CodeType.locationTransit;
|
type == CodeType.locationNormal ||
|
||||||
|
type == CodeType.locationTransit ||
|
||||||
|
type == CodeType.locationTempStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CodeType { zongpaiNo, locationNormal, locationTransit, invalid }
|
enum CodeType {
|
||||||
|
zongpaiNo,
|
||||||
|
locationNormal,
|
||||||
|
locationTransit,
|
||||||
|
locationTempStorage,
|
||||||
|
invalid,
|
||||||
|
}
|
||||||
|
|
||||||
class ParseResult {
|
class ParseResult {
|
||||||
final CodeType type;
|
final CodeType type;
|
||||||
|
|||||||
@@ -8,13 +8,20 @@ bool isTransitTarget(CodeType? locationType, String? locationCode) {
|
|||||||
(locationCode?.startsWith('TRANS-') ?? false);
|
(locationCode?.startsWith('TRANS-') ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isTempStorageTarget(CodeType? locationType, String? locationCode) {
|
||||||
|
return locationType == CodeType.locationTempStorage ||
|
||||||
|
(locationCode?.startsWith('B') ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
String registrationSubmitLabel({
|
String registrationSubmitLabel({
|
||||||
required bool isTransitTarget,
|
required bool isTransitTarget,
|
||||||
required bool isMultiCode,
|
required bool isMultiCode,
|
||||||
required int zongpaiCount,
|
required int zongpaiCount,
|
||||||
}) {
|
}) {
|
||||||
if (!isTransitTarget) {
|
if (!isTransitTarget) {
|
||||||
return isMultiCode && zongpaiCount > 1 ? '批量上架($zongpaiCount 条)' : '确 认 上 架';
|
return isMultiCode && zongpaiCount > 1
|
||||||
|
? '批量上架($zongpaiCount 条)'
|
||||||
|
: '确 认 上 架';
|
||||||
}
|
}
|
||||||
return isMultiCode && zongpaiCount > 1 ? '批量转运并凑箱($zongpaiCount 条)' : '转运并装箱';
|
return isMultiCode && zongpaiCount > 1 ? '批量转运并凑箱($zongpaiCount 条)' : '转运并装箱';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user