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

@@ -20,8 +20,8 @@ import 'package:provider/provider.dart';
import 'fcs_shipment_editor.dart';
class FcsShipmentInfo extends StatefulWidget {
final FcsShipment? fcsShipment;
FcsShipmentInfo({this.fcsShipment});
final FcsShipment fcsShipment;
FcsShipmentInfo({required this.fcsShipment});
@override
_FcsShipmentInfoState createState() => _FcsShipmentInfoState();
@@ -29,7 +29,7 @@ class FcsShipmentInfo extends StatefulWidget {
class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
var dateFormatter = new DateFormat('dd MMM yyyy');
FcsShipment? _fcsShipment;
late FcsShipment _fcsShipment;
bool _isLoading = false;
TextEditingController _shipmentNumberController = new TextEditingController();
TextEditingController _cutoffDateController = new TextEditingController();
@@ -49,21 +49,21 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
}
_load() {
_shipmentNumberController.text = _fcsShipment?.shipmentNumber ?? "";
if (_fcsShipment?.cutoffDate != null)
_shipmentNumberController.text = _fcsShipment.shipmentNumber ?? "";
if (_fcsShipment.cutoffDate != null)
_cutoffDateController.text =
dateFormatter.format(_fcsShipment!.cutoffDate!);
if (_fcsShipment?.arrivalDate != null)
_arrivalDateController.text =
dateFormatter.format(_fcsShipment!.arrivalDate!);
if (_fcsShipment?.departureDate != null)
dateFormatter.format(_fcsShipment.cutoffDate!);
if (_fcsShipment.etaDate != null)
_arrivalDateController.text = dateFormatter.format(_fcsShipment.etaDate!);
if (_fcsShipment.departureDate != null)
_departureDateControler.text =
dateFormatter.format(_fcsShipment!.departureDate!);
_shipmentTypeControler.text = _fcsShipment!.shipTypeName ?? "";
_consigneeController.text = _fcsShipment!.consignee ?? "";
_portController.text = _fcsShipment!.port ?? "";
_destinationController.text = _fcsShipment!.destination ?? "";
_statusController.text = _fcsShipment!.status ?? "";
dateFormatter.format(_fcsShipment.departureDate!);
_shipmentTypeControler.text = _fcsShipment.shipmentTypeName ?? "";
_consigneeController.text = _fcsShipment.consigneeName ?? '';
_portController.text = _fcsShipment.loadingPortName ?? '';
_destinationController.text = _fcsShipment.destinationPortName ?? '';
_statusController.text = _fcsShipment.status ?? "";
}
@override
@@ -176,7 +176,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
labelColor: primaryColor,
arrowColor: primaryColor,
actions: [
_fcsShipment?.status == fcs_shipment_pending_status
_fcsShipment.status == fcs_shipment_pending_status
? IconButton(
icon: Icon(Icons.edit, color: primaryColor),
onPressed: _edit,
@@ -212,20 +212,20 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
portBox,
destinationBox,
const SizedBox(height: 30),
_fcsShipment?.status == fcs_shipment_pending_status
_fcsShipment.status == fcs_shipment_pending_status
? processBtn
: Container(),
_fcsShipment?.status == fcs_shipment_pending_status
_fcsShipment.status == fcs_shipment_pending_status
? Container(
padding: EdgeInsets.only(top: 3), child: cancelBtn)
: Container(),
_fcsShipment?.status == fcs_shipment_processed_status
_fcsShipment.status == fcs_shipment_processed_status
? shipBtn
: Container(),
_fcsShipment?.status == fcs_shipment_shipped_status
_fcsShipment.status == fcs_shipment_shipped_status
? arriveBtn
: Container(),
_fcsShipment?.status == fcs_shipment_arrived_status
_fcsShipment.status == fcs_shipment_arrived_status
? invoiceBtn
: Container(),
SizedBox(height: 20)
@@ -244,8 +244,8 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
);
if (updated ?? false) {
var shipmentModel = Provider.of<FcsShipmentModel>(context, listen: false);
if (_fcsShipment != null && _fcsShipment!.id != null) {
FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment!.id!);
if (_fcsShipment.id != null) {
FcsShipment? f = await shipmentModel.getFcsShipment(_fcsShipment.id!);
if (f == null) return;
setState(() {
_fcsShipment = f;
@@ -294,7 +294,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
_isLoading = true;
});
try {
await context.read<FcsShipmentModel>().process(_fcsShipment!.id!);
await context.read<FcsShipmentModel>().process(_fcsShipment.id!);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -316,7 +316,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
_isLoading = true;
});
try {
await context.read<FcsShipmentModel>().ship(_fcsShipment!.id!);
await context.read<FcsShipmentModel>().ship(_fcsShipment.id!);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -338,7 +338,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
_isLoading = true;
});
try {
await context.read<FcsShipmentModel>().arrive(_fcsShipment!.id!);
await context.read<FcsShipmentModel>().arrive(_fcsShipment.id!);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -360,7 +360,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
_isLoading = true;
});
try {
await context.read<FcsShipmentModel>().invoice(_fcsShipment!.id!);
await context.read<FcsShipmentModel>().invoice(_fcsShipment.id!);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -376,7 +376,7 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
_isLoading = true;
});
try {
await context.read<FcsShipmentModel>().cancel(_fcsShipment!.id!);
await context.read<FcsShipmentModel>().cancel(_fcsShipment.id!);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -402,11 +402,11 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
} else if (id == 4) {
reportName = "manifest";
}
_fcsShipment!.reportName = reportName;
_fcsShipment.reportName = reportName;
FcsShipmentModel fcsShipmentModel =
Provider.of<FcsShipmentModel>(context, listen: false);
String url = await fcsShipmentModel.report(_fcsShipment!);
String url = await fcsShipmentModel.report(_fcsShipment);
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => PDFScreen(
title: "",