update cargo type form from rate, update carton info and form
This commit is contained in:
@@ -12,6 +12,7 @@ import '../../../domain/entities/carton_size.dart';
|
||||
import '../../../domain/entities/fcs_shipment.dart';
|
||||
import '../../../domain/vo/local_step.dart';
|
||||
import '../../../helpers/theme.dart';
|
||||
import '../../carton_size/model/carton_size_model.dart';
|
||||
import '../../main/util.dart';
|
||||
import '../../widgets/local_text.dart';
|
||||
import '../../widgets/progress.dart';
|
||||
@@ -58,10 +59,30 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
|
||||
_init() async {
|
||||
context.read<CartonSelectionModel>().clearSelection();
|
||||
_cartonSizeType = customCarton;
|
||||
_length = widget.carton.length;
|
||||
_width = widget.carton.width;
|
||||
_height = widget.carton.height;
|
||||
|
||||
// check carton size type
|
||||
List<CartonSize> cartonSizes = context.read<CartonSizeModel>().cartonSizes;
|
||||
|
||||
var sameLength =
|
||||
cartonSizes.any((size) => size.length == widget.carton.length);
|
||||
var sameWidth =
|
||||
cartonSizes.any((size) => size.width == widget.carton.width);
|
||||
var sameHeight =
|
||||
cartonSizes.any((size) => size.height == widget.carton.height);
|
||||
bool isStandartSize = sameLength && sameWidth && sameHeight;
|
||||
if (isStandartSize) {
|
||||
_cartonSizeType = standardCarton;
|
||||
_standardSize = cartonSizes.firstWhere((size) =>
|
||||
size.length == widget.carton.length &&
|
||||
size.width == widget.carton.width &&
|
||||
size.height == widget.carton.height);
|
||||
} else if (widget.carton.length == 0 &&
|
||||
widget.carton.width == 0 &&
|
||||
widget.carton.height == 0) {
|
||||
_cartonSizeType = packageCarton;
|
||||
} else {
|
||||
_cartonSizeType = customCarton;
|
||||
}
|
||||
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
@@ -70,7 +91,7 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
|
||||
_cartons = await context
|
||||
.read<CartonModel>()
|
||||
.getCartonsByIds(widget.carton.mixCartonIDs);
|
||||
.getCartonsByIds(widget.carton.cartonIDs);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
@@ -113,8 +134,16 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
},
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(context, 'box.update_title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
title: Column(
|
||||
children: [
|
||||
LocalText(context, 'box.update_title',
|
||||
color: primaryColor, fontSize: 20),
|
||||
Text(
|
||||
widget.carton.cartonNumber ?? '',
|
||||
style: TextStyle(color: primaryColor, fontSize: 14),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
@@ -212,6 +241,35 @@ class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
double length = 0;
|
||||
double width = 0;
|
||||
double height = 0;
|
||||
|
||||
if (_cartonSizeType == standardCarton) {
|
||||
if (_standardSize != null) {
|
||||
length = _standardSize!.length;
|
||||
width = _standardSize!.width;
|
||||
height = _standardSize!.height;
|
||||
}
|
||||
} else if (_cartonSizeType == customCarton) {
|
||||
length = _length;
|
||||
width = _width;
|
||||
height = _height;
|
||||
} else {
|
||||
length = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
var carton = Carton(
|
||||
id: widget.carton.id,
|
||||
cartonType: mix_carton,
|
||||
fcsShipmentID: _shipment?.id,
|
||||
length: length,
|
||||
width: width,
|
||||
height: height,
|
||||
cartons: _cartons);
|
||||
await context.read<CartonModel>().updateCarton(carton);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
Reference in New Issue
Block a user