add mix carton
This commit is contained in:
@@ -55,7 +55,8 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
|
||||
bool isMixBox;
|
||||
bool isFromShipments;
|
||||
bool isFromPackage;
|
||||
bool isFromPackages;
|
||||
bool isSmallBag;
|
||||
bool isEdiable;
|
||||
|
||||
@override
|
||||
@@ -72,35 +73,39 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
_widthController.addListener(_calShipmentWeight);
|
||||
_heightController.addListener(_calShipmentWeight);
|
||||
|
||||
_updateBoxData();
|
||||
_loadPackages();
|
||||
}
|
||||
|
||||
_updateBoxData() {
|
||||
_widthController.text = _box.width.toString();
|
||||
_heightController.text = _box.height.toString();
|
||||
_lengthController.text = _box.length.toString();
|
||||
|
||||
_cargoTypes = _box.cargoTypes;
|
||||
_deliveryAddress = _box.deliveryAddress;
|
||||
|
||||
isMixBox = _box.cartonType == carton_mix_box;
|
||||
isFromShipments = _box.cartonType == carton_from_shipments;
|
||||
isFromPackage = _box.cartonType == carton_from_packages;
|
||||
isEdiable =
|
||||
(isMixBox || isFromPackage) && _box.status == carton_packed_status;
|
||||
|
||||
if (isFromPackage) {
|
||||
_loadPackages();
|
||||
}
|
||||
isFromPackages = _box.cartonType == carton_from_packages;
|
||||
isSmallBag = _box.cartonType == carton_small_bag;
|
||||
isEdiable = !isMixBox &&
|
||||
(isFromPackages || isSmallBag) &&
|
||||
_box.status == carton_packed_status;
|
||||
}
|
||||
|
||||
_loadPackages() async {
|
||||
if (!isFromPackages && !isSmallBag) return;
|
||||
|
||||
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);
|
||||
List<Package> packages = await packageModel.getPackages(_box.userID, [
|
||||
package_processed_status,
|
||||
package_packed_status,
|
||||
package_shipped_status
|
||||
]);
|
||||
packages = packages.where((p) => _box.packageIDs.contains(p.id)).toList();
|
||||
packages.forEach((p) {
|
||||
if (_box.packageIDs.contains(p.id)) {
|
||||
p.isChecked = true;
|
||||
} else {
|
||||
p.isChecked = false;
|
||||
}
|
||||
p.isChecked = true;
|
||||
});
|
||||
|
||||
setState(() {
|
||||
@@ -219,6 +224,11 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
final cargoTableBox = CargoTable(
|
||||
cargoTypes: _box.cargoTypes,
|
||||
);
|
||||
final mixCartonNumberBox = DisplayText(
|
||||
text: _box.mixCartonNumber,
|
||||
labelTextKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
@@ -250,65 +260,68 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
]
|
||||
: [],
|
||||
),
|
||||
body: Card(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
fcsIDBox,
|
||||
customerNameBox,
|
||||
isFromPackage
|
||||
? CartonPackageTable(
|
||||
packages: _box.packages,
|
||||
)
|
||||
: Container(),
|
||||
isFromPackage
|
||||
? Container()
|
||||
: isFromShipments
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: _selectedCartonType == "Mix carton"
|
||||
? CartonMixTable(
|
||||
cartons: _box.cartons,
|
||||
onSelect: (c, check) {
|
||||
setState(() {
|
||||
c.isChecked = check;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
LocalTitle(textKey: "box.cargo.type"),
|
||||
cargoTableBox,
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
LocalTitle(textKey: "box.delivery_address"),
|
||||
DefaultDeliveryAddress(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
Center(child: getCartonNumberStatus(context, _box)),
|
||||
LocalTitle(textKey: "box.type.title"),
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
shipmentBox,
|
||||
isSmallBag ? mixCartonNumberBox : Container(),
|
||||
isMixBox ? Container() : fcsIDBox,
|
||||
isMixBox ? Container() : customerNameBox,
|
||||
isFromPackages || isSmallBag
|
||||
? CartonPackageTable(
|
||||
packages: _box.packages,
|
||||
)
|
||||
: Container(),
|
||||
isFromPackages
|
||||
? Container()
|
||||
: isFromShipments
|
||||
? Column(
|
||||
children: [
|
||||
LocalTitle(textKey: "box.shipment.boxes"),
|
||||
shipmentBoxTitle,
|
||||
Divider(
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
shipmentBoxRow
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
// : _selectedCartonType == "Mix carton"
|
||||
// ? CartonMixTable(
|
||||
// cartons: _box.cartons,
|
||||
// onSelect: (c, check) {
|
||||
// setState(() {
|
||||
// c.isChecked = check;
|
||||
// });
|
||||
// },
|
||||
// )
|
||||
// : Container(),
|
||||
isMixBox ? Container() : LocalTitle(textKey: "box.cargo.type"),
|
||||
isMixBox ? Container() : cargoTableBox,
|
||||
...(isFromPackages
|
||||
? [
|
||||
LocalTitle(textKey: "box.dimension"),
|
||||
dimBox,
|
||||
shipmentWeightBox,
|
||||
]
|
||||
: []),
|
||||
isMixBox
|
||||
? Container()
|
||||
: LocalTitle(textKey: "box.delivery_address"),
|
||||
isMixBox
|
||||
? Container()
|
||||
: DefaultDeliveryAddress(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
labelKey: "box.delivery_address",
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
]),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -324,6 +337,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
var c = await cartonModel.getCarton(widget.box.id);
|
||||
setState(() {
|
||||
_box = c;
|
||||
_updateBoxData();
|
||||
});
|
||||
_loadPackages();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user