update carton
This commit is contained in:
@@ -74,7 +74,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
//for carton from cargos
|
||||
User consignee;
|
||||
User sender;
|
||||
List<Carton> _cartonsForCargos = [];
|
||||
List<Carton> _cartonsFromCartons = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -95,17 +95,17 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_heightController.text = _carton.height.toString();
|
||||
_lengthController.text = _carton.length.toString();
|
||||
_selectedCartonType = _carton.cartonType;
|
||||
_cargoTypes = List.from(_carton.cargoTypes);
|
||||
|
||||
_cargoTypes = _carton.cargoTypes.map((e) => e.clone()).toList();
|
||||
|
||||
_isNew = false;
|
||||
_user = User(
|
||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
||||
consignee = User(
|
||||
id: _carton.receiverID,
|
||||
fcsID: _carton.receiverFCSID,
|
||||
name: _carton.receiverName);
|
||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
||||
sender = User(
|
||||
id: _carton.senderID,
|
||||
fcsID: _carton.senderID,
|
||||
fcsID: _carton.senderFCSID,
|
||||
name: _carton.senderName);
|
||||
_selectedMixBoxType = _carton.mixBoxType ?? "";
|
||||
this._mixCartons =
|
||||
@@ -251,7 +251,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
));
|
||||
|
||||
final fcsIDBox = Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
@@ -389,6 +389,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
boxModel.selectedIndexFilter = 1;
|
||||
searchCarton(context, callbackCartonSelect: (c) {
|
||||
_addMixCarton(c);
|
||||
});
|
||||
@@ -451,7 +452,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
);
|
||||
|
||||
final createMixCarton = LocalButton(
|
||||
textKey: _isNew ? "box.mix_carton_btn" : "btn.save",
|
||||
textKey: _isNew ? "box.mix_carton_btn" : "box.mix_carton.update.btn",
|
||||
callBack: _creatMixCarton,
|
||||
);
|
||||
|
||||
@@ -529,17 +530,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () {
|
||||
if (isDataChanged()) {
|
||||
showConfirmDialog(context, "back.button_confirm", () {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
icon:
|
||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||
onPressed: () => Navigator.of(context).pop()),
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
title: LocalText(
|
||||
@@ -610,7 +603,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
context,
|
||||
isFromPackages
|
||||
? this._cartons
|
||||
: this._cartonsForCargos))
|
||||
: this._cartonsFromCartons))
|
||||
: Container(),
|
||||
_isNew ? Container() : cargoTableTitleBox,
|
||||
_isNew ? Container() : cargoTableBox,
|
||||
@@ -635,14 +628,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
builder: (context) =>
|
||||
DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
user: isFromPackages
|
||||
? User(
|
||||
id: _carton.userID,
|
||||
name: _carton.userName)
|
||||
: User(
|
||||
id: _carton.receiverID,
|
||||
name: _carton
|
||||
.receiverName))),
|
||||
user: User(
|
||||
id: _carton.userID,
|
||||
name: _carton.userName))),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
@@ -845,9 +833,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}
|
||||
|
||||
if (isFromCartons) {
|
||||
carton.receiverID = consignee?.id;
|
||||
carton.receiverFCSID = consignee?.fcsID;
|
||||
carton.receiverName = consignee?.name;
|
||||
carton.userID = consignee?.id;
|
||||
carton.fcsID = consignee?.fcsID;
|
||||
carton.userName = consignee?.name;
|
||||
carton.senderID = sender?.id;
|
||||
carton.senderFCSID = sender?.fcsID;
|
||||
carton.senderName = sender?.name;
|
||||
@@ -877,7 +865,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}
|
||||
|
||||
if (isFromCartons) {
|
||||
_cartonsForCargos.add(_carton);
|
||||
_cartonsFromCartons.add(_carton);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
@@ -938,19 +926,19 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
_save() async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
bool isFromCargos = _selectedCartonType == carton_from_cartons;
|
||||
if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCargos)) {
|
||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||
if ((_cargoTypes?.length ?? 0) == 0 && (isFromPackages || isFromCartons)) {
|
||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||
return;
|
||||
}
|
||||
double l = double.parse(_lengthController.text, (s) => 0);
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
double h = double.parse(_heightController.text, (s) => 0);
|
||||
if ((l <= 0 || w <= 0 || h <= 0) && (isFromPackages || isFromCargos)) {
|
||||
if ((l <= 0 || w <= 0 || h <= 0) && (isFromPackages || isFromCartons)) {
|
||||
showMsgDialog(context, "Error", "Invalid dimension");
|
||||
return;
|
||||
}
|
||||
if (_deliveryAddress == null && (isFromPackages || isFromCargos)) {
|
||||
if (_deliveryAddress == null && (isFromPackages || isFromCartons)) {
|
||||
showMsgDialog(context, "Error", "Invalid delivery address");
|
||||
return;
|
||||
}
|
||||
@@ -963,8 +951,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
carton.userID = _user?.id;
|
||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||
}
|
||||
if (isFromCargos) {
|
||||
carton.receiverID = consignee?.id;
|
||||
if (isFromCartons) {
|
||||
carton.userID = consignee?.id;
|
||||
carton.senderID = sender?.id;
|
||||
}
|
||||
|
||||
@@ -990,13 +978,4 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isDataChanged() {
|
||||
if (_isNew) {
|
||||
return false;
|
||||
// return _fcsShipment != null || _user != null;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user