feat: extend boxing page for accessory boxing support
Add pending accessories section to both single-code and multi-code boxing modes. Accessories display with orange styling and a "加入本箱" button that calls saveBoxRecord with item_type=accessory. Extend API service with PendingAccessory model, itemType fields on data classes, and optional accessory_id parameter on saveBoxRecord. Show accessories with visual indicator (wrench icon + orange background) in boxing detail page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,8 @@ class MultiCodeBody extends StatelessWidget {
|
||||
final ValueChanged<ManyToOnePackedItem> onStartDeletePackedItem;
|
||||
final ValueChanged<ManyToOnePackedItem> onDeletePackedItem;
|
||||
final VoidCallback onCancelDeletePackedItem;
|
||||
final List<PendingAccessory> pendingAccessories;
|
||||
final ValueChanged<PendingAccessory> onSubmitAccessory;
|
||||
|
||||
const MultiCodeBody({
|
||||
super.key,
|
||||
@@ -69,6 +71,8 @@ class MultiCodeBody extends StatelessWidget {
|
||||
required this.onStartDeletePackedItem,
|
||||
required this.onDeletePackedItem,
|
||||
required this.onCancelDeletePackedItem,
|
||||
required this.pendingAccessories,
|
||||
required this.onSubmitAccessory,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -87,7 +91,7 @@ class MultiCodeBody extends StatelessWidget {
|
||||
),
|
||||
const _MultiListHeader(),
|
||||
Expanded(
|
||||
child: visibleItems.isEmpty
|
||||
child: visibleItems.isEmpty && pendingAccessories.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'尚未装入任何物料',
|
||||
@@ -99,22 +103,32 @@ class MultiCodeBody extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: visibleItems.length,
|
||||
itemCount: visibleItems.length + pendingAccessories.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = visibleItems[index];
|
||||
return MultiPackedRow(
|
||||
item: item,
|
||||
editing: editingPackedItemId == item.boxItemId,
|
||||
deleting: deletingPackedItemId == item.boxItemId,
|
||||
if (index < visibleItems.length) {
|
||||
final item = visibleItems[index];
|
||||
return MultiPackedRow(
|
||||
item: item,
|
||||
editing: editingPackedItemId == 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,
|
||||
editingQuantity: editingPackedQuantity,
|
||||
onEditingQuantityChanged: onEditingPackedQuantityChanged,
|
||||
onSave: () => onSavePackedItem(item),
|
||||
onCancelEdit: onCancelEditPackedItem,
|
||||
onStartEdit: () => onStartEditPackedItem(item),
|
||||
onStartDelete: () => onStartDeletePackedItem(item),
|
||||
onDelete: () => onDeletePackedItem(item),
|
||||
onCancelDelete: onCancelDeletePackedItem,
|
||||
onSubmit: () => onSubmitAccessory(acc),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -604,3 +618,72 @@ 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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user