add carton from mix_box & from cargos

This commit is contained in:
Thinzar Win
2021-01-09 19:11:47 +06:30
parent 0bbd568adc
commit 9d2f9a671f
16 changed files with 583 additions and 322 deletions

View File

@@ -1,3 +1,4 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/carton_size.dart';
@@ -46,6 +47,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
List<DeliveryAddress> _deliveryAddresses = [];
List<CargoType> _cargoTypes = [];
CartonSize selectedCatonSize;
bool isFromPackages;
bool isFromCargos;
@override
void initState() {
@@ -55,6 +58,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
_load() {
_carton = widget.carton;
isFromPackages = _carton.cartonType == carton_from_packages;
isFromCargos = _carton.cartonType == carton_from_cargos;
_getDeliverAddresses();
if (widget.isNew) {
_lengthCtl.text = "0";
@@ -73,8 +78,10 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
_getDeliverAddresses() async {
var addressModel =
Provider.of<DeliveryAddressModel>(context, listen: false);
this._deliveryAddresses =
await addressModel.getDeliveryAddresses(_carton.userID);
this._deliveryAddresses = isFromPackages
? await addressModel.getDeliveryAddresses(_carton.userID)
: await addressModel.getDeliveryAddresses(_carton.receiverID);
}
_getCartonSize() {
@@ -321,9 +328,21 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
carton.id = _carton.id;
carton.cartonType = _carton.cartonType;
carton.fcsShipmentID = _carton.fcsShipmentID;
carton.userID = _carton.userID;
carton.cargoTypes = _cargoTypes;
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
if (isFromPackages) {
carton.userID = _carton.userID;
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
}
if (isFromCargos) {
carton.receiverID = _carton.receiverID;
carton.receiverFCSID = _carton.receiverFCSID;
carton.receiverName = _carton.receiverName;
carton.senderID = _carton.senderID;
carton.senderFCSID = _carton.senderFCSID;
carton.senderName = _carton.senderName;
}
carton.length = l;
carton.width = w;
carton.height = h;