fix carton

This commit is contained in:
2021-01-10 15:56:27 +06:30
parent 83cea10328
commit 4839109280
21 changed files with 201 additions and 162 deletions

View File

@@ -51,7 +51,6 @@ class _CartonInfoState extends State<CartonInfo> {
double volumetricRatio = 0;
double shipmentWeight = 0;
String selectMixBoxType;
List<Carton> _mixCartons = [];
bool isMixBox;
bool isFromShipments;
@@ -76,6 +75,7 @@ class _CartonInfoState extends State<CartonInfo> {
_updateBoxData();
_loadPackages();
_loadMixCartons();
}
_updateBoxData() {
@@ -93,7 +93,6 @@ class _CartonInfoState extends State<CartonInfo> {
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
_box.status == carton_packed_status;
selectMixBoxType = _box.mixBoxType ?? "";
_mixCartons = _box.mixCartons == null ? [] : _box.mixCartons;
getCartonSize();
}
@@ -132,6 +131,20 @@ class _CartonInfoState extends State<CartonInfo> {
});
}
_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.parse(_lengthController.text, (s) => 0);
double w = double.parse(_widthController.text, (s) => 0);
@@ -356,7 +369,7 @@ class _CartonInfoState extends State<CartonInfo> {
isMixBox ? mixTypeBox : Container(),
isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
isMixBox
? Column(children: _getCartons(context, this._mixCartons))
? Column(children: _getCartons(context, _box.mixCartons))
: Container(),
isFromPackages || isSmallBag
? CartonPackageTable(
@@ -397,6 +410,7 @@ class _CartonInfoState extends State<CartonInfo> {
}
_gotoEditor() async {
widget.box.mixCartons=_box.mixCartons;
bool updated = await Navigator.push<bool>(
context,
CupertinoPageRoute(builder: (context) => CartonEditor(box: widget.box)),
@@ -406,9 +420,10 @@ class _CartonInfoState extends State<CartonInfo> {
var c = await cartonModel.getCarton(widget.box.id);
setState(() {
_box = c;
_loadPackages();
_loadMixCartons();
_updateBoxData();
});
_loadPackages();
}
}