update cartion editor
This commit is contained in:
@@ -36,10 +36,11 @@ class Carton {
|
||||
String? mixCartonNumber;
|
||||
String? cartonSizeID;
|
||||
String? cartonSizeName;
|
||||
String? deliveryType;
|
||||
String? cartonSizeType;
|
||||
String? cartonStandardSize;
|
||||
|
||||
double cartonWeight;
|
||||
String? billTo;
|
||||
String? billTo;
|
||||
bool isSelected;
|
||||
|
||||
int rate;
|
||||
@@ -51,7 +52,6 @@ class Carton {
|
||||
String? remark;
|
||||
DateTime? arrivedDate;
|
||||
String? cartonNumber;
|
||||
String? deliveryCarton;
|
||||
|
||||
List<String> packageIDs;
|
||||
List<Package> packages;
|
||||
@@ -163,12 +163,11 @@ class Carton {
|
||||
this.cartonSizeID,
|
||||
this.cartonSizeName,
|
||||
this.cartonSizeType,
|
||||
this.cartonStandardSize,
|
||||
this.deliveryCarton,
|
||||
this.deliveryType,
|
||||
this.mixBoxType,
|
||||
this.mixCartons = const [],
|
||||
this.mixCartonIDs = const [],
|
||||
this.cartonWeight =0,
|
||||
this.cartonWeight = 0,
|
||||
this.photoUrls = const [],
|
||||
this.isSelected = false});
|
||||
|
||||
@@ -209,7 +208,7 @@ class Carton {
|
||||
List<Map<String, dynamic>>.from(map['mix_cartons'] ?? []);
|
||||
var _mixCartons =
|
||||
mixCartonsMaps.map((e) => Carton.fromMap(e, e["id"])).toList();
|
||||
List<String> _photoUrls =
|
||||
List<String> _photoUrls =
|
||||
map['photo_urls'] == null ? [] : List.from(map['photo_urls']);
|
||||
|
||||
return Carton(
|
||||
@@ -243,7 +242,7 @@ class Carton {
|
||||
senderName: map['sender_name'],
|
||||
mixCartonIDs: List<String>.from(map['mix_carton_ids'] ?? []),
|
||||
cartonWeight: (map['carton_weight'] ?? 0).toDouble(),
|
||||
photoUrls: _photoUrls,
|
||||
photoUrls: _photoUrls,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../domain/entities/carton_size.dart';
|
||||
import '../widgets/local_button.dart';
|
||||
import 'carton_package_editor.dart';
|
||||
import 'mix_carton/mix_carton_editor.dart';
|
||||
@@ -40,8 +41,9 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
List<CargoType> _surchareItems = [];
|
||||
List<Carton> _mixCartons = [];
|
||||
List<Package> _packages = [];
|
||||
double totalWeight=0.0;
|
||||
double totalSurchargeCount=0.0;
|
||||
double totalWeight = 0.0;
|
||||
double totalSurchargeCount = 0.0;
|
||||
CartonSize? standardSize;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -51,13 +53,14 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
}
|
||||
|
||||
_init() async {
|
||||
_carton.billTo = billToSender;
|
||||
_carton.cartonSizeType=standardCarton;
|
||||
_carton.billTo = billToConsignee;
|
||||
_carton.cartonSizeType = customCarton;
|
||||
_carton.cartonType = carton_from_packages;
|
||||
multiImgController.setImageUrls = _carton.photos;
|
||||
_cargoTypes = _carton.cargoTypes.where((e) => !e.isCutomDuty).toList();
|
||||
_surchareItems = _carton.cargoTypes.where((e) => e.isCutomDuty).toList();
|
||||
if (_carton.cartonType == carton_from_packages) {
|
||||
_carton.deliveryType = delivery_caton;
|
||||
_packages = await context
|
||||
.read<PackageModel>()
|
||||
.getPackagesByIds(_carton.packageIDs);
|
||||
@@ -72,16 +75,20 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
_carton.cartonType="Carton for packages";
|
||||
totalWeight =
|
||||
_carton.cartonType = "Carton for packages";
|
||||
totalWeight =
|
||||
_carton.cargoTypes.fold(0, (sum, value) => sum + value.weight);
|
||||
totalSurchargeCount =
|
||||
totalSurchargeCount =
|
||||
_surchareItems.fold(0, (sum, value) => sum + value.qty);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
String? boxDimension = _carton.cartonSizeType == standardCarton
|
||||
? "${standardSize?.name} - ${standardSize?.length.toInt()}”x${standardSize?.width.toInt()}”x${standardSize?.height.toInt()}”"
|
||||
: _carton.cartonSizeType == customCarton
|
||||
? "${_carton.length.toInt()}”x${_carton.width.toInt()}”x${_carton.height.toInt()}”"
|
||||
: null;
|
||||
|
||||
final cartonTypeBox = DisplayText(
|
||||
text: _carton.cartonNumber,
|
||||
@@ -90,8 +97,10 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
|
||||
final cartonQrBox = DisplayText(iconData: AntDesign.qrcode);
|
||||
final cartonSubTypeBox = DisplayText(
|
||||
text: _carton.cartonType==carton_from_packages ? "Carton for packages":"Mix carton",
|
||||
subText:Text( "${_carton.cartonStandardSize}"),
|
||||
text: _carton.cartonType == carton_from_packages
|
||||
? "Carton for packages"
|
||||
: "Mix carton",
|
||||
subText: boxDimension == null ? null : Text("$boxDimension"),
|
||||
labelTextKey: "box.carton.type",
|
||||
);
|
||||
|
||||
@@ -101,19 +110,19 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
);
|
||||
|
||||
final deliveryBox = DisplayText(
|
||||
text: _carton.deliveryCarton,
|
||||
text: _carton.deliveryType,
|
||||
labelTextKey: "box.delivery_type",
|
||||
);
|
||||
|
||||
final senderBox = DisplayText(
|
||||
text: _carton.senderName== null ? "" : _carton.senderName,
|
||||
subText: Text(_carton.senderFCSID?? "", style: textStyle),
|
||||
text: _carton.senderName == null ? "" : _carton.senderName,
|
||||
subText: Text(_carton.senderFCSID ?? "", style: textStyle),
|
||||
labelTextKey: "box.name",
|
||||
);
|
||||
|
||||
final consigneeNameBox = DisplayText(
|
||||
text: _carton.userName != null ? _carton.userName : "",
|
||||
subText: Text(_carton.fcsID?? "", style: textStyle),
|
||||
subText: Text(_carton.fcsID ?? "", style: textStyle),
|
||||
labelTextKey: "processing.consignee.name",
|
||||
);
|
||||
|
||||
@@ -183,7 +192,6 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
style: TextStyle(color: Colors.black54, fontSize: 15)))
|
||||
],
|
||||
),
|
||||
//),
|
||||
Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 100),
|
||||
@@ -346,20 +354,21 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
child: cartonQrBox,
|
||||
),
|
||||
]),
|
||||
Row(children: [Flexible(child: cartonSubTypeBox),],),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(child: cartonSubTypeBox),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(child: shipmentBox),
|
||||
_mixCartons.isEmpty
|
||||
?
|
||||
Flexible(child: deliveryBox):const SizedBox(),
|
||||
? Flexible(child: deliveryBox)
|
||||
: const SizedBox(),
|
||||
],
|
||||
),
|
||||
_mixCartons.isEmpty
|
||||
?
|
||||
userRowBox:
|
||||
const SizedBox(),
|
||||
_mixCartons.isEmpty ? userRowBox : const SizedBox(),
|
||||
_packages.isEmpty
|
||||
? const SizedBox()
|
||||
: Padding(
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../../domain/entities/package.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../fcs_shipment/model/fcs_shipment_model.dart';
|
||||
import '../main/util.dart';
|
||||
import '../package/model/package_model.dart';
|
||||
import '../widgets/local_text.dart';
|
||||
import '../widgets/progress.dart';
|
||||
import '../widgets/step_widget.dart';
|
||||
@@ -70,6 +71,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
}
|
||||
|
||||
_init() async {
|
||||
context.read<PackageSelectionModel>().clearSelection();
|
||||
_sender = User(
|
||||
name: widget.carton.senderName,
|
||||
fcsID: widget.carton.senderFCSID,
|
||||
@@ -81,18 +83,23 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
|
||||
fcsID: widget.carton.fcsID);
|
||||
|
||||
_billToValue = widget.carton.billTo ?? billToSender;
|
||||
_selectedDeliveryType = delivery_caton;
|
||||
_cartonSizeType = customCarton;
|
||||
_selectedDeliveryType = widget.carton.deliveryType ?? delivery_caton;
|
||||
_cartonSizeType = widget.carton.cartonSizeType ?? customCarton;
|
||||
_length = widget.carton.length;
|
||||
_width = widget.carton.width;
|
||||
_height = widget.carton.height;
|
||||
_cargoTypes = widget.carton.cargoTypes.where((e) => !e.isCutomDuty).toList();
|
||||
_surchareItems = widget.carton.cargoTypes.where((e) => e.isCutomDuty).toList();
|
||||
|
||||
var s = await context
|
||||
.read<FcsShipmentModel>()
|
||||
.getFcsShipment(widget.carton.fcsShipmentID ?? "");
|
||||
_shipment = s;
|
||||
|
||||
context.read<PackageSelectionModel>().clearSelection();
|
||||
_packages = await context
|
||||
.read<PackageModel>()
|
||||
.getPackagesByIds(widget.carton.packageIDs);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -144,4 +144,5 @@ class CartonSelectionModel extends BaseModel {
|
||||
cartons.clear();
|
||||
query = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ class PackageSelectionModel extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
addSelectedPackage(List<Package> list){
|
||||
selectedPackageList = list;
|
||||
}
|
||||
|
||||
Future<void> _refresh(
|
||||
{required String shipmentId,
|
||||
required String senderId,
|
||||
|
||||
@@ -60,6 +60,8 @@ class _PackageSelectionWidgetState extends State<PackageSelectionWidget> {
|
||||
consigneeId: widget.consignee.id!,
|
||||
senderId: widget.sender.id!);
|
||||
|
||||
searchModel.addSelectedPackage(widget.packages);
|
||||
|
||||
_controller.text = searchModel.query;
|
||||
_query = searchModel.query;
|
||||
if (mounted) {
|
||||
|
||||
Reference in New Issue
Block a user