update carton
This commit is contained in:
@@ -51,7 +51,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
TextEditingController _lengthController = new TextEditingController();
|
||||
List<DeliveryAddress> _deliveryAddresses = [];
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
List<CargoType> _cargoTypes = [];
|
||||
|
||||
@@ -116,7 +115,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
if (isFromPackages) _loadPackages();
|
||||
|
||||
if (!isMixBox) {
|
||||
_getDeliverAddresses();
|
||||
_getCartonSize();
|
||||
}
|
||||
} else {
|
||||
@@ -203,15 +201,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
});
|
||||
}
|
||||
|
||||
_getDeliverAddresses() async {
|
||||
var addressModel =
|
||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||
bool isFromPackages = _carton.cartonType == carton_from_packages;
|
||||
this._deliveryAddresses = isFromPackages
|
||||
? await addressModel.getDeliveryAddresses(_carton.userID)
|
||||
: await addressModel.getDeliveryAddresses(_carton.receiverID);
|
||||
}
|
||||
|
||||
_getCartonSize() {
|
||||
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||
cartonSizeModel.cartonSizes.forEach((c) {
|
||||
@@ -237,7 +226,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
Widget build(BuildContext context) {
|
||||
var boxModel = Provider.of<CartonModel>(context);
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCargos = _selectedCartonType == carton_from_cargos;
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
bool isMixBox = _selectedCartonType == carton_mix_box;
|
||||
|
||||
final shipmentBox = DisplayText(
|
||||
@@ -603,7 +592,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
isFromCargos
|
||||
isFromCartons
|
||||
? Container(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: Row(
|
||||
@@ -646,8 +635,14 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
builder: (context) =>
|
||||
DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
deliveryAddresses:
|
||||
_deliveryAddresses)),
|
||||
user: isFromPackages
|
||||
? User(
|
||||
id: _carton.userID,
|
||||
name: _carton.userName)
|
||||
: User(
|
||||
id: _carton.receiverID,
|
||||
name: _carton
|
||||
.receiverName))),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
@@ -658,7 +653,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
isFromPackages || isFromCargos
|
||||
isFromPackages || isFromCartons
|
||||
? _isNew
|
||||
? createBtn
|
||||
: saveBtn
|
||||
@@ -679,7 +674,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCargos = _selectedCartonType == carton_from_cargos;
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
if (isFromPackages) {
|
||||
_loadPackages();
|
||||
c.value.packages = _carton.packages;
|
||||
@@ -812,7 +807,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
_addCarton() async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCargos = _selectedCartonType == carton_from_cargos;
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
|
||||
if (_fcsShipment == null && _isNew) {
|
||||
showMsgDialog(context, "Error", "Please select FCS shipment");
|
||||
@@ -824,12 +819,12 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (consignee == null && isFromCargos) {
|
||||
if (consignee == null && isFromCartons) {
|
||||
showMsgDialog(context, "Error", "Please select consignee's FCS ID");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender == null && isFromCargos) {
|
||||
if (sender == null && isFromCartons) {
|
||||
showMsgDialog(context, "Error", "Please select sender's FCS ID");
|
||||
return;
|
||||
}
|
||||
@@ -849,7 +844,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||
}
|
||||
|
||||
if (isFromCargos) {
|
||||
if (isFromCartons) {
|
||||
carton.receiverID = consignee?.id;
|
||||
carton.receiverFCSID = consignee?.fcsID;
|
||||
carton.receiverName = consignee?.name;
|
||||
@@ -881,7 +876,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_cartons.add(_carton);
|
||||
}
|
||||
|
||||
if (isFromCargos) {
|
||||
if (isFromCartons) {
|
||||
_cartonsForCargos.add(_carton);
|
||||
}
|
||||
|
||||
@@ -943,7 +938,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
_save() async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCargos = _selectedCartonType == carton_from_cargos;
|
||||
bool isFromCargos = _selectedCartonType == carton_from_cartons;
|
||||
if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCargos)) {
|
||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user