update cargo type form from rate, update carton info and form

This commit is contained in:
tzw
2024-09-25 21:49:09 +06:30
parent 1be18c08a9
commit 02e079c514
51 changed files with 1407 additions and 643 deletions

View File

@@ -1,5 +1,6 @@
// ignore_for_file: deprecated_member_use
import 'package:fcs/domain/entities/carton.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
@@ -20,6 +21,7 @@ import '../widgets/step_widget.dart';
import 'cargo_widget.dart';
import 'carton_size_widget.dart';
import 'carton_submit.dart';
import 'model/carton_model.dart';
import 'model/package_selection_model.dart';
import 'package_selection_widget.dart';
@@ -55,7 +57,7 @@ class _CartonPackageFormState extends State<CartonPackageForm> {
double _width = 0;
double _height = 0;
String _selectedDeliveryType = delivery_caton;
String _selectedLastMile = delivery_caton;
String _billToValue = billToSender;
FcsShipment? _shipment;
@@ -134,7 +136,7 @@ class _CartonPackageFormState extends State<CartonPackageForm> {
if (step.stepType == StepType.SIZE) {
return Expanded(
child: CartonSizeWidget(
deliveryType: _selectedDeliveryType,
lastMile: _selectedLastMile,
billType: _billToValue,
sender: widget.sender,
consignee: widget.consignee,
@@ -147,10 +149,10 @@ class _CartonPackageFormState extends State<CartonPackageForm> {
onPrevious: () {
Navigator.pop(context);
},
onContinue: (deliveryType, billType, shipment, cartonSizeType,
onContinue: (lastMile, billType, shipment, cartonSizeType,
{standardSize, length, width, height}) {
setState(() {
_selectedDeliveryType = deliveryType;
_selectedLastMile = lastMile;
_billToValue = billType;
_shipment = shipment;
_cartonSizeType = cartonSizeType;
@@ -217,7 +219,7 @@ class _CartonPackageFormState extends State<CartonPackageForm> {
length: _length,
width: _width,
height: _height,
deliveryType: _selectedDeliveryType,
lastMile: _selectedLastMile,
shipment: _shipment!,
packages: _packages,
cargoTypes: _cargoTypes,
@@ -240,7 +242,41 @@ class _CartonPackageFormState extends State<CartonPackageForm> {
_isLoading = true;
});
try {
Navigator.pop(context, true);
double length = 0;
double width = 0;
double height = 0;
if (_cartonSizeType == standardCarton) {
if (_standardSize != null) {
length = _standardSize!.length;
width = _standardSize!.width;
height = _standardSize!.height;
}
} else if (_cartonSizeType == customCarton) {
length = _length;
width = _width;
height = _height;
} else {
length = 0;
width = 0;
height = 0;
}
var carton = Carton(
cartonType: carton_from_packages,
senderID: widget.sender.id,
consigneeID: widget.consignee.id,
billTo: _billToValue,
lastMile: _selectedLastMile,
fcsShipmentID: _shipment?.id,
length: length,
width: width,
height: height,
packages: _packages,
cargoTypes: _cargoTypes,
surchareItems: _surchareItems);
var c = await context.read<CartonModel>().createCarton(carton);
Navigator.pop(context, c);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {