update cargo type input, add package count and carton count for shipment info

This commit is contained in:
tzw
2025-03-26 15:51:47 +06:30
parent db3e290546
commit 17ca3e2a3f
11 changed files with 156 additions and 53 deletions

View File

@@ -47,6 +47,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
List<CargoType> _cargoTypes = [];
List<CargoType> _surchareItems = [];
double _totalWeight = 0;
int currentStep = 0;
double _length = 0;
@@ -89,6 +90,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
widget.carton.cargoTypes.map((e) => e.cloneForCarton()).toList();
_surchareItems =
widget.carton.surchareItems.map((e) => e.cloneForSurchage()).toList();
_totalWeight = _cargoTypes.fold(0, (sum, value) => sum + value.weight);
// check carton size type
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
@@ -252,6 +254,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
consignee: _consignee!,
cargoTypes: _cargoTypes,
surchargeItems: _surchareItems,
totalWeight: _totalWeight,
onContinue: (cargoTypes, customDuties) {
setState(() {
_cargoTypes = List.from(cargoTypes);
@@ -259,8 +262,9 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
currentStep += 1;
});
},
onPrevious: (cargoTypes, customDuties) {
onPrevious: (cargoTypes, customDuties, totalWeight) {
setState(() {
_totalWeight = totalWeight;
_cargoTypes = List.from(cargoTypes);
_surchareItems = List.from(customDuties);
currentStep -= 1;