update carton info
This commit is contained in:
@@ -344,6 +344,8 @@
|
|||||||
"box.bill_to":"Bill to",
|
"box.bill_to":"Bill to",
|
||||||
"box.delvery_carton":"Delivery carton",
|
"box.delvery_carton":"Delivery carton",
|
||||||
"box.pick_up_carton":"Pick-up carton",
|
"box.pick_up_carton":"Pick-up carton",
|
||||||
|
"box.delete.btn":"Delete carton",
|
||||||
|
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
|
|||||||
@@ -343,6 +343,7 @@
|
|||||||
"box.bill_to":"Bill to",
|
"box.bill_to":"Bill to",
|
||||||
"box.delvery_carton":"Delivery carton",
|
"box.delvery_carton":"Delivery carton",
|
||||||
"box.pick_up_carton":"Pick-up carton",
|
"box.pick_up_carton":"Pick-up carton",
|
||||||
|
"box.delete.btn":"Delete carton",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Carton {
|
|||||||
String? cartonSizeID;
|
String? cartonSizeID;
|
||||||
String? cartonSizeName;
|
String? cartonSizeName;
|
||||||
double cartonWeight;
|
double cartonWeight;
|
||||||
String? billToValue;
|
String? billTo;
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
|
|
||||||
int rate;
|
int rate;
|
||||||
@@ -149,7 +149,7 @@ class Carton {
|
|||||||
this.packages = const [],
|
this.packages = const [],
|
||||||
this.cargoTypes = const [],
|
this.cargoTypes = const [],
|
||||||
this.cartonNumber,
|
this.cartonNumber,
|
||||||
this.billToValue,
|
this.billTo,
|
||||||
this.fcsShipmentID,
|
this.fcsShipmentID,
|
||||||
this.fcsShipmentNumber,
|
this.fcsShipmentNumber,
|
||||||
this.packageIDs = const [],
|
this.packageIDs = const [],
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
|||||||
import '../main/util.dart';
|
import '../main/util.dart';
|
||||||
import 'carton_editor_for_package.dart';
|
import 'carton_editor_for_package.dart';
|
||||||
import 'carton_info.dart';
|
import 'carton_info.dart';
|
||||||
import 'mix_carton/mix_carton_editor.dart';
|
import 'mix_carton/mix_carton_form.dart';
|
||||||
import 'carton_row.dart';
|
import 'carton_row.dart';
|
||||||
|
|
||||||
class CartonEditor extends StatefulWidget {
|
class CartonEditor extends StatefulWidget {
|
||||||
@@ -164,7 +164,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => const MixCartonEditor()));
|
builder: (context) => const MixCartonForm()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Icon(Icons.add_circle, color: primaryColor),
|
child: Icon(Icons.add_circle, color: primaryColor),
|
||||||
@@ -307,7 +307,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CartonInfo(box: c)),
|
CupertinoPageRoute(builder: (context) => CartonInfo(carton: c)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: CartonRow(box: c));
|
child: CartonRow(box: c));
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ import 'package:fcs/domain/entities/carton.dart';
|
|||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/carton/carton_image_upload.dart';
|
import 'package:fcs/pages/carton/carton_image_upload.dart';
|
||||||
import 'package:fcs/pages/carton/carton_submit.dart';
|
|
||||||
import 'package:fcs/pages/carton_size/model/carton_size_model.dart';
|
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -20,196 +17,149 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import '../widgets/local_button.dart';
|
||||||
import 'carton_editor.dart';
|
import 'mix_carton/mix_carton_editor.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
||||||
final NumberFormat numberFormatter = NumberFormat("#,###");
|
|
||||||
|
|
||||||
class CartonInfo extends StatefulWidget {
|
class CartonInfo extends StatefulWidget {
|
||||||
final Package? package;
|
final Carton carton;
|
||||||
final Carton box;
|
CartonInfo({required this.carton});
|
||||||
final String? billToValue;
|
|
||||||
final CartonSubmit? cartonSubmit;
|
|
||||||
|
|
||||||
CartonInfo(
|
|
||||||
{required this.box, this.billToValue, this.package, this.cartonSubmit});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CartonInfoState createState() => _CartonInfoState();
|
_CartonInfoState createState() => _CartonInfoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CartonInfoState extends State<CartonInfo> {
|
class _CartonInfoState extends State<CartonInfo> {
|
||||||
bool _isLoading = false;
|
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||||
Carton? _box;
|
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||||
|
|
||||||
CartonSubmit? _cartonSubmit;
|
|
||||||
|
|
||||||
MultiImgController multiImgController = MultiImgController();
|
MultiImgController multiImgController = MultiImgController();
|
||||||
TextEditingController _widthController = new TextEditingController();
|
|
||||||
TextEditingController _heightController = new TextEditingController();
|
|
||||||
TextEditingController _lengthController = new TextEditingController();
|
|
||||||
TextEditingController _cartonSizeController = new TextEditingController();
|
|
||||||
double volumetricRatio = 0;
|
|
||||||
double shipmentWeight = 0;
|
|
||||||
String? selectMixBoxType;
|
|
||||||
|
|
||||||
bool isMixBox = false;
|
bool _isLoading = false;
|
||||||
bool isFromShipments = false;
|
late Carton _carton;
|
||||||
bool isFromPackages = false;
|
|
||||||
bool isSmallBag = false;
|
|
||||||
bool isFromCartons = false;
|
|
||||||
|
|
||||||
bool isCutomDuty = false;
|
List<CargoType> _cargoTypes = [];
|
||||||
final List<CargoType> cargoTypes = [];
|
List<CargoType> _surchareItems = [];
|
||||||
final List<CargoType> surchareItems = [];
|
List<Carton> _mixCartons = [];
|
||||||
final List<Carton> cartons = [];
|
List<Package> _packages = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
_carton = widget.carton;
|
||||||
|
_init();
|
||||||
super.initState();
|
super.initState();
|
||||||
_box = widget.box;
|
|
||||||
_box?.billToValue = "Bill to sender";
|
|
||||||
|
|
||||||
//initPackage(widget.package!);
|
|
||||||
//for shipment weight
|
|
||||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
|
||||||
.rate
|
|
||||||
.volumetricRatio;
|
|
||||||
_lengthController.addListener(_calShipmentWeight);
|
|
||||||
_widthController.addListener(_calShipmentWeight);
|
|
||||||
_heightController.addListener(_calShipmentWeight);
|
|
||||||
multiImgController.setImageUrls = _box!.photos;
|
|
||||||
// _updateBoxData();
|
|
||||||
_loadPackages();
|
|
||||||
_loadMixCartons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateBoxData() {
|
_init() async {
|
||||||
_widthController.text = _box!.width.toString();
|
_carton.billTo = billToSender;
|
||||||
_heightController.text = _box!.height.toString();
|
_carton.cartonType = carton_from_packages;
|
||||||
_lengthController.text = _box!.length.toString();
|
multiImgController.setImageUrls = _carton.photos;
|
||||||
_cartonSizeController.text = _box!.cartonSizeName ?? "";
|
_cargoTypes = _carton.cargoTypes.where((e) => !e.isCutomDuty).toList();
|
||||||
isMixBox = _box!.cartonType == carton_mix_box;
|
_surchareItems = _carton.cargoTypes.where((e) => e.isCutomDuty).toList();
|
||||||
isFromShipments = _box!.cartonType == carton_from_shipments;
|
if (_carton.cartonType == carton_from_packages) {
|
||||||
isFromPackages = _box!.cartonType == carton_from_packages;
|
_packages = await context
|
||||||
isSmallBag = _box!.cartonType == carton_small_bag;
|
.read<PackageModel>()
|
||||||
isFromCartons = _box!.cartonType == carton_from_cartons;
|
.getPackagesByIds(_carton.packageIDs);
|
||||||
|
|
||||||
selectMixBoxType = _box!.mixBoxType;
|
|
||||||
getCartonSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCartonSize() {
|
if (_carton.cartonType == carton_mix_carton) {
|
||||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
_mixCartons = await context
|
||||||
cartonSizeModel.cartonSizes.forEach((c) {
|
.read<CartonModel>()
|
||||||
if (c.length == _box!.length &&
|
.getCartonsByIds(_carton.mixCartonIDs);
|
||||||
c.width == _box!.width &&
|
|
||||||
c.height == _box!.height) {
|
|
||||||
setState(() {
|
|
||||||
_cartonSizeController.text = c.name ?? "";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadPackages() async {
|
if (mounted) {
|
||||||
if (!isFromPackages && !isSmallBag) return;
|
setState(() {});
|
||||||
|
|
||||||
// if (_box!.cartonType == carton_from_packages && _box!.userID == null)
|
|
||||||
// return;
|
|
||||||
PackageModel packageModel =
|
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
|
||||||
List<Package> packages =
|
|
||||||
await packageModel.getPackages(_box!.userID ?? "", [
|
|
||||||
package_processed_status,
|
|
||||||
package_packed_status,
|
|
||||||
package_shipped_status,
|
|
||||||
package_delivered_status
|
|
||||||
]);
|
|
||||||
packages = packages.where((p) => _box!.packageIDs.contains(p.id)).toList();
|
|
||||||
packages.forEach((p) {
|
|
||||||
p.isChecked = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_box!.packages = packages;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadMixCartons() async {
|
|
||||||
if (_box!.cartonType != carton_mix_box) return;
|
|
||||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
|
||||||
List<Carton> catons = [];
|
|
||||||
for (var id in _box!.mixCartonIDs) {
|
|
||||||
Carton c = await cartonModel.getCarton(id);
|
|
||||||
catons.add(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_box!.mixCartons = catons;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_calShipmentWeight() {
|
|
||||||
double l = double.tryParse(_lengthController.text) ?? 0;
|
|
||||||
double w = double.tryParse(_widthController.text) ?? 0;
|
|
||||||
double h = double.tryParse(_heightController.text) ?? 0;
|
|
||||||
setState(() {
|
|
||||||
shipmentWeight = l * w * h / volumetricRatio;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double totalWeight =
|
double totalWeight =
|
||||||
_box!.cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
_carton.cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||||
double totalPieces = surchareItems.fold(0, (sum, value) => sum + value.qty);
|
double totalSurchargeCount =
|
||||||
|
_surchareItems.fold(0, (sum, value) => sum + value.qty);
|
||||||
|
|
||||||
final cartonTypeBox = DisplayText(
|
final cartonTypeBox = DisplayText(
|
||||||
text: _box!.cartonNumber,
|
text: _carton.cartonNumber,
|
||||||
labelTextKey: "box.number",
|
labelTextKey: "box.number",
|
||||||
);
|
);
|
||||||
final cartonQrBox = DisplayText(
|
|
||||||
iconData: AntDesign.qrcode,
|
final cartonQrBox = DisplayText(iconData: AntDesign.qrcode);
|
||||||
);
|
|
||||||
final shipmentBox = DisplayText(
|
final shipmentBox = DisplayText(
|
||||||
text: _box!.fcsShipmentNumber,
|
text: _carton.fcsShipmentNumber,
|
||||||
labelTextKey: "box.fcs_shipment_num",
|
labelTextKey: "box.fcs_shipment_num",
|
||||||
);
|
);
|
||||||
|
|
||||||
final deliveryBox = DisplayText(
|
final deliveryBox = DisplayText(
|
||||||
text: "Delivery Carton",
|
text: "Delivery Carton",
|
||||||
labelTextKey: "box.delivery_type",
|
labelTextKey: "box.delivery_type",
|
||||||
);
|
);
|
||||||
|
|
||||||
final customerNameBox = DisplayText(
|
final senderBox = DisplayText(
|
||||||
text: _box!.userName == null ? "" : _box!.userName,
|
text: _carton.userName == null ? "" : _carton.userName,
|
||||||
subText: Text(_box!.fcsID ?? "", style: textStyle),
|
subText: Text(_carton.fcsID ?? "", style: textStyle),
|
||||||
labelTextKey: "box.name",
|
labelTextKey: "box.name",
|
||||||
);
|
);
|
||||||
|
|
||||||
final consigneeNameBox = DisplayText(
|
final consigneeNameBox = DisplayText(
|
||||||
text: _box!.senderName != null ? _box!.senderName : "",
|
text: _carton.senderName != null ? _carton.senderName : "",
|
||||||
subText: Text(_box!.senderFCSID ?? "", style: textStyle),
|
subText: Text(_carton.senderFCSID ?? "", style: textStyle),
|
||||||
labelTextKey: "processing.consignee.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
);
|
);
|
||||||
|
|
||||||
final packageBox = DisplayText(
|
final billWidget = Expanded(
|
||||||
labelTextKey: "box.package",
|
child: Padding(
|
||||||
);
|
padding: EdgeInsets.only(left: 0, top: 15),
|
||||||
final cartonBox = DisplayText(
|
child: Row(
|
||||||
labelTextKey: "box.shipment.boxes",
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Icon(Ionicons.document_text_outline,
|
||||||
|
color: primaryColor, size: 20),
|
||||||
|
Text("Bill to",
|
||||||
|
style: TextStyle(color: primaryColor, fontSize: 15))
|
||||||
|
],
|
||||||
|
)));
|
||||||
|
|
||||||
|
final userRowBox = Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
senderBox,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_carton.billTo == billToSender ? billWidget : const SizedBox()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
consigneeNameBox,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_carton.billTo == billToConsignee ? billWidget : const SizedBox()
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final cargosBox = Padding(
|
final cargosBox = Padding(
|
||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 15),
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
@@ -232,7 +182,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: _box!.cargoTypes.map((e) {
|
children: _cargoTypes.map((e) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -258,7 +208,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
final surchargeItemBox = Padding(
|
final surchargeItemBox = Padding(
|
||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 15),
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
@@ -269,7 +219,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
fontWeight: FontWeight.normal),
|
fontWeight: FontWeight.normal),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(right: 100),
|
padding: EdgeInsets.only(right: 100),
|
||||||
child: Text("${removeTrailingZeros(totalPieces)} pcs",
|
child: Text("${removeTrailingZeros(totalSurchargeCount)} pcs",
|
||||||
style: TextStyle(color: Colors.black54, fontSize: 15)))
|
style: TextStyle(color: Colors.black54, fontSize: 15)))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -281,7 +231,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: surchareItems.map((e) {
|
children: _surchareItems.map((e) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -303,7 +253,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: surchareItems.map((e) {
|
children: _surchareItems.map((e) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -333,18 +283,37 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
title: "Receipt File",
|
title: "Receipt File",
|
||||||
);
|
);
|
||||||
|
|
||||||
final billWidget = Expanded(
|
final uploadImageBtn = Padding(
|
||||||
child: Padding(
|
padding: EdgeInsets.only(left: 200.0, right: 8.0),
|
||||||
padding: EdgeInsets.only(left: 0, top: 15),
|
child: ElevatedButton(
|
||||||
child: Row(
|
style: ElevatedButton.styleFrom(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
backgroundColor: Color(0xff272262),
|
||||||
children: [
|
elevation: 3,
|
||||||
Icon(Ionicons.document_text_outline,
|
shape:
|
||||||
color: primaryColor, size: 20),
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
|
||||||
Text("Bill to",
|
minimumSize: Size(10, 35),
|
||||||
style: TextStyle(color: primaryColor, fontSize: 15))
|
),
|
||||||
],
|
onPressed: () {
|
||||||
)));
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => CartonImageUpload(box: _carton)),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Upload Images'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final deleteBtn = Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
|
child: LocalButton(
|
||||||
|
color: dangerColor,
|
||||||
|
textKey: "box.delete.btn",
|
||||||
|
callBack: () {
|
||||||
|
_delete();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
@@ -371,146 +340,92 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(child: shipmentBox),
|
||||||
child: shipmentBox,
|
Flexible(child: deliveryBox),
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
child: deliveryBox,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// isMixBox
|
userRowBox,
|
||||||
// ?
|
_packages.isEmpty
|
||||||
// displayMixBox:Container(),
|
? const SizedBox()
|
||||||
|
: Padding(
|
||||||
isMixBox
|
padding: const EdgeInsets.only(top: 15),
|
||||||
? Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Row(
|
|
||||||
//crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
customerNameBox,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_box?.billToValue == billToSender
|
|
||||||
? billWidget
|
|
||||||
: const SizedBox(
|
|
||||||
height: 300.0,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 0),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
LocalText(context, "box.package",
|
||||||
|
color: Colors.black54, fontSize: 15),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Column(
|
||||||
|
children: getPackageList(_packages),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_mixCartons.isEmpty
|
||||||
|
? const SizedBox()
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 15),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
consigneeNameBox,
|
LocalText(context, "box.shipment.boxes",
|
||||||
|
color: Colors.black54, fontSize: 15),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Column(children: getCartonList(_mixCartons)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_cartonSubmit?.billToValue == billToSender
|
_cargoTypes.isEmpty ? const SizedBox() : cargosBox,
|
||||||
? billWidget
|
_surchareItems.isEmpty ? const SizedBox() : surchargeItemBox,
|
||||||
: const SizedBox()
|
uploadImageBtn,
|
||||||
],
|
|
||||||
),
|
|
||||||
))
|
|
||||||
],
|
|
||||||
)
|
|
||||||
// ,
|
|
||||||
|
|
||||||
// Row(
|
|
||||||
// children: getPackageList(_box!.packages),
|
|
||||||
// ),
|
|
||||||
// ])
|
|
||||||
: Container(),
|
|
||||||
isMixBox
|
|
||||||
? Column(
|
|
||||||
children: [
|
|
||||||
packageBox,
|
|
||||||
Row(
|
|
||||||
children: getPackageList(_box!.packages),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
children: [
|
|
||||||
cartonBox,
|
|
||||||
Row(
|
|
||||||
children: getCartonList(_box!.mixCartons),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
isCutomDuty ? surchargeItemBox : cargosBox,
|
|
||||||
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 200.0, right: 8.0),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Color(0xff272262),
|
|
||||||
elevation: 3,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(5.0)),
|
|
||||||
minimumSize: Size(10, 35), //////// HERE
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
CartonImageUpload(box: _box)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Upload Images'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
img,
|
img,
|
||||||
Center(
|
deleteBtn
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Color(0xffff0606),
|
|
||||||
elevation: 3,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(5.0)),
|
|
||||||
minimumSize: Size(300, 45), //////// HERE
|
|
||||||
),
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('Delete Carton',
|
|
||||||
style: TextStyle(fontSize: 20)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]))));
|
]))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Widget> getPackageList(List<Package> list) {
|
||||||
|
return list.map((p) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(top: 0),
|
||||||
|
child: Container(
|
||||||
|
child: Row(children: <Widget>[new Text(p.trackingID ?? "")]),
|
||||||
|
));
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getCartonList(List<Carton> list) {
|
||||||
|
return list.map((c) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(top: 0),
|
||||||
|
child: Container(
|
||||||
|
child: Row(children: <Widget>[new Text(c.cartonNumber ?? '')]),
|
||||||
|
));
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
_gotoEditor() async {
|
_gotoEditor() async {
|
||||||
|
if (_carton.cartonType == carton_mix_carton) {
|
||||||
bool? updated = await Navigator.push<bool>(
|
bool? updated = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)),
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => MixCartonEditor(carton: _carton)),
|
||||||
);
|
);
|
||||||
if (updated ?? false) {
|
|
||||||
// var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
|
||||||
// var c = await cartonModel.getCarton(widget.box.id ?? "");
|
|
||||||
// setState(() {
|
|
||||||
// _box = c;
|
|
||||||
// _loadPackages();
|
|
||||||
// _loadMixCartons();
|
|
||||||
// _updateBoxData();
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
// bool? updated = await Navigator.push<bool>(
|
||||||
|
// context,
|
||||||
|
// CupertinoPageRoute(
|
||||||
|
// builder: (context) => MixCartonEditor(carton: _carton)),
|
||||||
|
// );
|
||||||
|
// if (updated ?? false) {
|
||||||
|
// // var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||||
|
// // var c = await cartonModel.getCarton(widget.box.id ?? "");
|
||||||
|
// // setState(() {
|
||||||
|
// // _box = c;
|
||||||
|
// // _loadPackages();
|
||||||
|
// // _loadMixCartons();
|
||||||
|
// // _updateBoxData();
|
||||||
|
// // });
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
_delete() {
|
_delete() {
|
||||||
@@ -524,9 +439,9 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
// var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||||
await cartonModel.deleteCarton(widget.box);
|
// await cartonModel.deleteCarton(widget.carton);
|
||||||
Navigator.pop(context, true);
|
// Navigator.pop(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -535,40 +450,4 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getPackageList(List<Package> _p) {
|
|
||||||
return _p.map((p) {
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(top: 0),
|
|
||||||
child: Container(
|
|
||||||
//padding:
|
|
||||||
//EdgeInsets.only(top: 0.0),
|
|
||||||
child: Row(children: <Widget>[new Text(p.trackingID ?? '')]),
|
|
||||||
));
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> getCartonList(List<Carton> _c) {
|
|
||||||
return _c.map((c) {
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(top: 0),
|
|
||||||
child: Container(
|
|
||||||
//padding:
|
|
||||||
//EdgeInsets.only(top: 0.0),
|
|
||||||
child: Row(children: <Widget>[new Text(c.cartonNumber ?? '')]),
|
|
||||||
));
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> getCargoList(List<CargoType> _c) {
|
|
||||||
return _c.map((c) {
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(top: 0),
|
|
||||||
child: Container(
|
|
||||||
//padding:
|
|
||||||
//EdgeInsets.only(top: 0.0),
|
|
||||||
child: Row(children: <Widget>[new Text(c.name ?? '')]),
|
|
||||||
));
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class _CartonListState extends State<CartonList> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CartonInfo(box: c)),
|
builder: (context) => CartonInfo(carton: c)),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class CartonListRow extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CartonInfo(box: box)),
|
CupertinoPageRoute(builder: (context) => CartonInfo(carton: box)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ import 'mix_carton_submit.dart';
|
|||||||
import 'type_widget.dart';
|
import 'type_widget.dart';
|
||||||
|
|
||||||
class MixCartonEditor extends StatefulWidget {
|
class MixCartonEditor extends StatefulWidget {
|
||||||
const MixCartonEditor({
|
final Carton carton;
|
||||||
Key? key,
|
const MixCartonEditor({Key? key, required this.carton}) : super(key: key);
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MixCartonEditor> createState() => _MixCartonEditorState();
|
State<MixCartonEditor> createState() => _MixCartonEditorState();
|
||||||
|
|||||||
199
lib/pages/carton/mix_carton/mix_carton_form.dart
Normal file
199
lib/pages/carton/mix_carton/mix_carton_form.dart
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
// ignore_for_file: deprecated_member_use
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../domain/constants.dart';
|
||||||
|
import '../../../domain/entities/carton.dart';
|
||||||
|
import '../../../domain/entities/carton_size.dart';
|
||||||
|
import '../../../domain/entities/fcs_shipment.dart';
|
||||||
|
import '../../../domain/vo/local_step.dart';
|
||||||
|
import '../../../helpers/theme.dart';
|
||||||
|
import '../../main/util.dart';
|
||||||
|
import '../../widgets/local_text.dart';
|
||||||
|
import '../../widgets/progress.dart';
|
||||||
|
import '../../widgets/step_widget.dart';
|
||||||
|
import '../model/carton_selection_model.dart';
|
||||||
|
import 'carton_selection_widget.dart';
|
||||||
|
import 'mix_carton_submit.dart';
|
||||||
|
import 'type_widget.dart';
|
||||||
|
|
||||||
|
class MixCartonForm extends StatefulWidget {
|
||||||
|
const MixCartonForm({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MixCartonForm> createState() => _MixCartonFormState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MixCartonFormState extends State<MixCartonForm> {
|
||||||
|
var dateFormatter = DateFormat('dd MMM yyyy');
|
||||||
|
final NumberFormat numberFormatter = NumberFormat("#,###");
|
||||||
|
List<LocalStep> steps = [
|
||||||
|
LocalStep(lable: 'Type', stepType: StepType.TYPE),
|
||||||
|
LocalStep(lable: 'Cartons', stepType: StepType.CARTONS),
|
||||||
|
LocalStep(lable: 'Submit', stepType: StepType.SUBMIT)
|
||||||
|
];
|
||||||
|
List<Carton> _cartons = [];
|
||||||
|
|
||||||
|
int currentStep = 0;
|
||||||
|
double _length = 0;
|
||||||
|
double _width = 0;
|
||||||
|
double _height = 0;
|
||||||
|
|
||||||
|
FcsShipment? _shipment;
|
||||||
|
String _cartonSizeType = standardCarton;
|
||||||
|
CartonSize? _standardSize;
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
context.read<CartonSelectionModel>().clearSelection();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: () {
|
||||||
|
if (currentStep == 0) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
if (currentStep > 0) {
|
||||||
|
setState(() {
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Future.value(false);
|
||||||
|
},
|
||||||
|
child: LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
elevation: 0,
|
||||||
|
centerTitle: true,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(CupertinoIcons.back,
|
||||||
|
color: primaryColor, size: 25),
|
||||||
|
onPressed: () {
|
||||||
|
if (currentStep == 0) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
if (currentStep > 0) {
|
||||||
|
setState(() {
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(context, 'boxes.new',
|
||||||
|
color: primaryColor, fontSize: 20),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
StepperWidget(
|
||||||
|
labels: steps.map((e) => e.lable).toList(),
|
||||||
|
currentStep: currentStep,
|
||||||
|
eachStepWidth: MediaQuery.of(context).size.width / 3,
|
||||||
|
onChange: (index) {
|
||||||
|
if (index > currentStep) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
currentStep = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
getContent(currentStep)
|
||||||
|
],
|
||||||
|
))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getContent(int index) {
|
||||||
|
var step = steps[index];
|
||||||
|
if (step.stepType == StepType.TYPE) {
|
||||||
|
return Expanded(
|
||||||
|
child: TypeWidget(
|
||||||
|
shipment: _shipment,
|
||||||
|
cartonSizeType: _cartonSizeType,
|
||||||
|
standardSize: _standardSize,
|
||||||
|
length: _length,
|
||||||
|
width: _width,
|
||||||
|
height: _height,
|
||||||
|
onPrevious: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
onContinue: (shipment, cartonSizeType,
|
||||||
|
{standardSize, length, width, height}) {
|
||||||
|
setState(() {
|
||||||
|
_shipment = shipment;
|
||||||
|
_cartonSizeType = cartonSizeType;
|
||||||
|
_standardSize = standardSize;
|
||||||
|
_length = length ?? 0;
|
||||||
|
_width = width ?? 0;
|
||||||
|
_height = height ?? 0;
|
||||||
|
currentStep += 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else if (step.stepType == StepType.CARTONS) {
|
||||||
|
return Expanded(
|
||||||
|
child: CartonSelectionWidget(
|
||||||
|
shipment: _shipment!,
|
||||||
|
cartons: _cartons,
|
||||||
|
onContinue: (cartons) {
|
||||||
|
setState(() {
|
||||||
|
_cartons = List.from(cartons);
|
||||||
|
currentStep += 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPrevious: (cartons) {
|
||||||
|
setState(() {
|
||||||
|
_cartons = List.from(cartons);
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Expanded(
|
||||||
|
child: MixCartonSubmit(
|
||||||
|
cartonSizeType: _cartonSizeType,
|
||||||
|
standardSize: _standardSize,
|
||||||
|
length: _length,
|
||||||
|
width: _width,
|
||||||
|
height: _height,
|
||||||
|
shipment: _shipment!,
|
||||||
|
cartons: _cartons,
|
||||||
|
onCreate: () {
|
||||||
|
_create();
|
||||||
|
},
|
||||||
|
onPrevious: () {
|
||||||
|
setState(() {
|
||||||
|
currentStep -= 1;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_create() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -205,7 +205,7 @@ class CartonModel extends BaseModel {
|
|||||||
return querySnap.docs.map((e) => Carton.fromMap(e.data(), e.id)).toList();
|
return querySnap.docs.map((e) => Carton.fromMap(e.data(), e.id)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Carton> getCarton(String id) async {
|
Future<Carton?> getCarton(String id) async {
|
||||||
String path = "/$cartons_collection";
|
String path = "/$cartons_collection";
|
||||||
var snap = await FirebaseFirestore.instance.collection(path).doc(id).get();
|
var snap = await FirebaseFirestore.instance.collection(path).doc(id).get();
|
||||||
return Carton.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
return Carton.fromMap(snap.data() as Map<String, dynamic>, snap.id);
|
||||||
@@ -226,4 +226,19 @@ class CartonModel extends BaseModel {
|
|||||||
Future<List<Carton>> searchCarton(String term) async {
|
Future<List<Carton>> searchCarton(String term) async {
|
||||||
return Services.instance.cartonService.searchCarton(term);
|
return Services.instance.cartonService.searchCarton(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Carton>> getCartonsByIds(List<String> cartonIds) async {
|
||||||
|
List<Carton> cartons = [];
|
||||||
|
try {
|
||||||
|
for (var e in cartonIds) {
|
||||||
|
Carton? c = await getCarton(e);
|
||||||
|
if (c != null) {
|
||||||
|
cartons.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.warning("Error!! $e");
|
||||||
|
}
|
||||||
|
return cartons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,17 @@ import 'cargo_type_addtion.dart';
|
|||||||
import 'carton_cargo_table.dart';
|
import 'carton_cargo_table.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
|
|
||||||
class PackageCartonEditor extends StatefulWidget {
|
class PackageCartonForm extends StatefulWidget {
|
||||||
final Carton? carton;
|
final Carton? carton;
|
||||||
final bool? isNew;
|
final bool? isNew;
|
||||||
final User? consignee;
|
final User? consignee;
|
||||||
PackageCartonEditor({this.carton, this.isNew, this.consignee});
|
PackageCartonForm({this.carton, this.isNew, this.consignee});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PackageCartonEditorState createState() => _PackageCartonEditorState();
|
_PackageCartonFormState createState() => _PackageCartonFormState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
class _PackageCartonFormState extends State<PackageCartonForm> {
|
||||||
TextEditingController _lengthCtl = new TextEditingController();
|
TextEditingController _lengthCtl = new TextEditingController();
|
||||||
TextEditingController _widthCtl = new TextEditingController();
|
TextEditingController _widthCtl = new TextEditingController();
|
||||||
TextEditingController _heightCtl = new TextEditingController();
|
TextEditingController _heightCtl = new TextEditingController();
|
||||||
@@ -349,9 +349,11 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
Navigator.pop(context, _c);
|
Navigator.pop(context, _c);
|
||||||
} else {
|
} else {
|
||||||
await cartonModel.updateCarton(carton);
|
await cartonModel.updateCarton(carton);
|
||||||
Carton _c = await cartonModel.getCarton(_carton!.id!);
|
Carton? _c = await cartonModel.getCarton(_carton!.id!);
|
||||||
|
if (_c != null) {
|
||||||
Navigator.pop(context, _c);
|
Navigator.pop(context, _c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -49,9 +49,11 @@ class _InvoiceInfoState extends State<InvoiceInfo> {
|
|||||||
List<Carton> cartons = [];
|
List<Carton> cartons = [];
|
||||||
for (var c in _invoice?.cartons ?? []) {
|
for (var c in _invoice?.cartons ?? []) {
|
||||||
var _carton = await cartonModel.getCarton(c.id);
|
var _carton = await cartonModel.getCarton(c.id);
|
||||||
|
if (_carton != null) {
|
||||||
_carton.isChecked = true;
|
_carton.isChecked = true;
|
||||||
cartons.add(_carton);
|
cartons.add(_carton);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_invoice!.cartons = cartons;
|
_invoice!.cartons = cartons;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -359,4 +359,19 @@ class PackageModel extends BaseModel {
|
|||||||
Future<void> packageReturn(Package package) {
|
Future<void> packageReturn(Package package) {
|
||||||
return Services.instance.packageService.packageReturn(package.id!);
|
return Services.instance.packageService.packageReturn(package.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Package>> getPackagesByIds(List<String> packageIds) async {
|
||||||
|
List<Package> packages = [];
|
||||||
|
try {
|
||||||
|
for (var e in packageIds) {
|
||||||
|
Package? p = await getPackage(e);
|
||||||
|
if (p != null) {
|
||||||
|
packages.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.warning("Error!! $e");
|
||||||
|
}
|
||||||
|
return packages;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user