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

@@ -42,6 +42,8 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
TextEditingController portController = TextEditingController();
TextEditingController destinationController = TextEditingController();
TextEditingController statusController = TextEditingController();
int _packageCount = 0;
int _cartonCount = 0;
@override
void initState() {
@@ -50,25 +52,56 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
_load();
}
_load() {
shipmentNumberController.text = _fcsShipment.shipmentNumber ?? "";
if (_fcsShipment.cutoffDate != null) {
cutoffDateController.text =
dateFormatter.format(_fcsShipment.cutoffDate!);
}
if (_fcsShipment.etaDate != null) {
arrivalDateController.text = dateFormatter.format(_fcsShipment.etaDate!);
}
if (_fcsShipment.departureDate != null) {
departureDateControler.text =
dateFormatter.format(_fcsShipment.departureDate!);
}
_load() async {
try {
_isLoading = true;
shipmentNumberController.text = _fcsShipment.shipmentNumber ?? "";
if (_fcsShipment.cutoffDate != null) {
cutoffDateController.text =
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.shipmentTypeName ?? "";
consigneeController.text = _fcsShipment.consigneeName ?? '';
portController.text = _fcsShipment.loadingPortName ?? '';
destinationController.text = _fcsShipment.destinationPortName ?? '';
statusController.text = _fcsShipment.status ?? "";
shipmentTypeControler.text = _fcsShipment.shipmentTypeName ?? "";
consigneeController.text = _fcsShipment.consigneeName ?? '';
portController.text = _fcsShipment.loadingPortName ?? '';
destinationController.text = _fcsShipment.destinationPortName ?? '';
statusController.text = _fcsShipment.status ?? "";
await Future.wait([_loadPackageCount(), _loadCartonCount()]);
} finally {
_isLoading = false;
}
if (mounted) {
setState(() {});
}
}
Future<void> _loadPackageCount() async {
int? count = await context
.read<FcsShipmentModel>()
.getPackageCount(fcsShipmentId: _fcsShipment.id ?? "");
_packageCount = count ?? 0;
if (mounted) {
setState(() {});
}
}
Future<void> _loadCartonCount() async {
int? count = await context
.read<FcsShipmentModel>()
.getCartonCount(fcsShipmentId: _fcsShipment.id ?? "");
_cartonCount = count ?? 0;
if (mounted) {
setState(() {});
}
}
@override
@@ -90,13 +123,13 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
);
final cartonBox = DisplayText(
text: numberFormatter.format(_fcsShipment.cartonCount),
text: numberFormatter.format(_cartonCount),
labelTextKey: "FCSshipment.carton",
iconData: MaterialCommunityIcons.package,
);
final packageBox = DisplayText(
text: numberFormatter.format(_fcsShipment.packageCount),
text: numberFormatter.format(_packageCount),
labelTextKey: "FCSshipment.package",
iconData: Octicons.package,
);
@@ -196,7 +229,6 @@ class _FcsShipmentInfoState extends State<FcsShipmentInfo> {
style: TextStyle(fontSize: 15, color: Colors.black))
],
),
backgroundColor: Colors.white,
labelColor: primaryColor,
arrowColor: primaryColor,