update carton
This commit is contained in:
@@ -11,9 +11,10 @@ class CartonDataProvider {
|
|||||||
static final CartonDataProvider instance = CartonDataProvider._();
|
static final CartonDataProvider instance = CartonDataProvider._();
|
||||||
CartonDataProvider._();
|
CartonDataProvider._();
|
||||||
|
|
||||||
Future<void> createCarton(Carton carton) async {
|
Future<Carton> createCarton(Carton carton) async {
|
||||||
return await requestAPI("/cartons", "POST",
|
var data = await requestAPI("/cartons", "POST",
|
||||||
payload: carton.toMap(), token: await getToken());
|
payload: carton.toMap(), token: await getToken());
|
||||||
|
return Carton.fromMap(data, data['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateCarton(Carton carton) async {
|
Future<void> updateCarton(Carton carton) async {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CartonServiceImp implements CartonService {
|
|||||||
final CartonDataProvider cartonDataProvider;
|
final CartonDataProvider cartonDataProvider;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> createCarton(Carton carton) {
|
Future<Carton> createCarton(Carton carton) {
|
||||||
return cartonDataProvider.createCarton(carton);
|
return cartonDataProvider.createCarton(carton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
|
||||||
abstract class CartonService {
|
abstract class CartonService {
|
||||||
Future<void> createCarton(Carton carton);
|
Future<Carton> createCarton(Carton carton);
|
||||||
Future<void> updateCarton(Carton carton);
|
Future<void> updateCarton(Carton carton);
|
||||||
Future<void> deleteCarton(Carton carton);
|
Future<void> deleteCarton(Carton carton);
|
||||||
Future<void> deliver(Carton carton);
|
Future<void> deliver(Carton carton);
|
||||||
|
|||||||
@@ -199,9 +199,9 @@ class Carton {
|
|||||||
shipmentNumber: map['shipment_number'],
|
shipmentNumber: map['shipment_number'],
|
||||||
receiverNumber: map['receiver_number'],
|
receiverNumber: map['receiver_number'],
|
||||||
boxNumber: map['box_number'],
|
boxNumber: map['box_number'],
|
||||||
length: map['length'],
|
length: double.tryParse(map['length']?.toString()),
|
||||||
width: map['width'],
|
width: double.tryParse(map['width']?.toString()),
|
||||||
height: map['height'],
|
height: double.tryParse(map['height']?.toString()),
|
||||||
userName: map['user_name'],
|
userName: map['user_name'],
|
||||||
fcsID: map['fcs_id'],
|
fcsID: map['fcs_id'],
|
||||||
cartonType: map['carton_type'],
|
cartonType: map['carton_type'],
|
||||||
|
|||||||
@@ -138,6 +138,14 @@ class Package {
|
|||||||
package.fcsID != this.fcsID;
|
package.fcsID != this.fcsID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEditProcessing(Package package) {
|
||||||
|
return package.trackingID != this.trackingID ||
|
||||||
|
package.fcsID != this.fcsID ||
|
||||||
|
package.market != this.market ||
|
||||||
|
package.desc != this.desc ||
|
||||||
|
package.remark != this.remark;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => other is Package && other.id == id;
|
bool operator ==(Object other) => other is Package && other.id == id;
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,17 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/carton/carton_package_table.dart';
|
import 'package:fcs/pages/carton/carton_package_table.dart';
|
||||||
import 'package:fcs/pages/carton_search/carton_search.dart';
|
import 'package:fcs/pages/carton_search/carton_search.dart';
|
||||||
import 'package:fcs/pages/carton_size/carton_size_list.dart';
|
import 'package:fcs/pages/carton_size/carton_size_list.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||||
|
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||||
|
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||||
import 'package:fcs/pages/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||||
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||||
import 'package:fcs/pages/widgets/local_button.dart';
|
import 'package:fcs/pages/widgets/local_button.dart';
|
||||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||||
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
||||||
@@ -27,6 +31,8 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'cargo_type_addtion.dart';
|
||||||
|
import 'carton_cargo_table.dart';
|
||||||
import 'carton_list_row.dart';
|
import 'carton_list_row.dart';
|
||||||
import 'carton_row.dart';
|
import 'carton_row.dart';
|
||||||
import 'mix_carton_editor.dart';
|
import 'mix_carton_editor.dart';
|
||||||
@@ -47,6 +53,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
TextEditingController _widthController = new TextEditingController();
|
TextEditingController _widthController = new TextEditingController();
|
||||||
TextEditingController _heightController = new TextEditingController();
|
TextEditingController _heightController = new TextEditingController();
|
||||||
TextEditingController _lengthController = new TextEditingController();
|
TextEditingController _lengthController = new TextEditingController();
|
||||||
|
List<DeliveryAddress> _deliveryAddresses = [];
|
||||||
|
|
||||||
Carton _carton;
|
Carton _carton;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
@@ -62,6 +69,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
Carton _mixCarton;
|
Carton _mixCarton;
|
||||||
List<Carton> _cartons = [];
|
List<Carton> _cartons = [];
|
||||||
List<Carton> _mixCartons = [];
|
List<Carton> _mixCartons = [];
|
||||||
|
CartonSize selectedCatonSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -85,6 +93,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_isNew = false;
|
_isNew = false;
|
||||||
_user = User(fcsID: _carton.fcsID, name: _carton.userName);
|
_user = User(fcsID: _carton.fcsID, name: _carton.userName);
|
||||||
_loadPackages();
|
_loadPackages();
|
||||||
|
_getDeliverAddresses();
|
||||||
|
getCartonSize();
|
||||||
} else {
|
} else {
|
||||||
_carton = Carton(
|
_carton = Carton(
|
||||||
cargoTypes: [],
|
cargoTypes: [],
|
||||||
@@ -97,12 +107,12 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_selectedCartonType = carton_from_packages;
|
_selectedCartonType = carton_from_packages;
|
||||||
_selectedMixType = mix_delivery;
|
_selectedMixType = mix_delivery;
|
||||||
_loadFcsShipments();
|
_loadFcsShipments();
|
||||||
_cartons = [Carton(cartonNumber: "A100B-1#3", userName: "Seven 7")];
|
// _cartons = [Carton(cartonNumber: "A100B-1#3", userName: "Seven 7")];
|
||||||
|
|
||||||
_mixCartons = [
|
// _mixCartons = [
|
||||||
Carton(cartonNumber: "A100B-1#1", userName: "Seven 7"),
|
// Carton(cartonNumber: "A100B-1#1", userName: "Seven 7"),
|
||||||
Carton(cartonNumber: "A100B-1#2", userName: "Seven 7"),
|
// Carton(cartonNumber: "A100B-1#2", userName: "Seven 7"),
|
||||||
];
|
// ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +162,19 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_carton.packages = packages;
|
_carton.packages = packages;
|
||||||
});
|
});
|
||||||
_populateDeliveryAddress();
|
// _populateDeliveryAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
_populateDeliveryAddress() {
|
// _populateDeliveryAddress() {
|
||||||
if (_carton.packages == null) return;
|
// if (_carton.packages == null) return;
|
||||||
var d = _carton.packages
|
// var d = _carton.packages
|
||||||
.firstWhere((p) => p.isChecked && p.deliveryAddress != null,
|
// .firstWhere((p) => p.isChecked && p.deliveryAddress != null,
|
||||||
orElse: () => null)
|
// orElse: () => null)
|
||||||
?.deliveryAddress;
|
// ?.deliveryAddress;
|
||||||
setState(() {
|
// setState(() {
|
||||||
_deliveryAddress = d;
|
// _deliveryAddress = d;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
_calShipmentWeight() {
|
_calShipmentWeight() {
|
||||||
double l = double.parse(_lengthController.text, (s) => 0);
|
double l = double.parse(_lengthController.text, (s) => 0);
|
||||||
@@ -175,6 +185,32 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getDeliverAddresses() async {
|
||||||
|
var addressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
this._deliveryAddresses =
|
||||||
|
await addressModel.getDeliveryAddresses(_carton.userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
getCartonSize() {
|
||||||
|
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||||
|
cartonSizeModel.cartonSizes.forEach((c) {
|
||||||
|
if (c.length == _carton.length &&
|
||||||
|
c.width == _carton.width &&
|
||||||
|
c.height == _carton.height) {
|
||||||
|
print(c.name);
|
||||||
|
// setState(() {
|
||||||
|
// // selectedCatonSize = CartonSize(
|
||||||
|
// // id: c.id,
|
||||||
|
// // name: c.name,
|
||||||
|
// // length: c.length,
|
||||||
|
// // width: c.width,
|
||||||
|
// // height: c.height);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -267,7 +303,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||||
if (_user == null && isFromPackages) {
|
if (_user == null && isFromPackages) {
|
||||||
showMsgDialog(context, "Error", "Please select customer");
|
showMsgDialog(context, "Error", "Please select FCS ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_fcsShipment == null && _isNew) {
|
if (_fcsShipment == null && _isNew) {
|
||||||
@@ -285,6 +321,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
carton.fcsShipmentID =
|
carton.fcsShipmentID =
|
||||||
_isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
_isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||||
carton.userID = _user?.id;
|
carton.userID = _user?.id;
|
||||||
|
carton.fcsID = _user?.fcsID;
|
||||||
|
carton.userName = _user?.name;
|
||||||
carton.packages =
|
carton.packages =
|
||||||
_carton.packages.where((e) => e.isChecked).toList();
|
_carton.packages.where((e) => e.isChecked).toList();
|
||||||
|
|
||||||
@@ -298,12 +336,18 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
Navigator.push(
|
Carton _c = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
PackageCartonEditor(carton: carton, isNew: _isNew)),
|
PackageCartonEditor(carton: carton, isNew: _isNew)),
|
||||||
);
|
);
|
||||||
|
if (_c == null) return;
|
||||||
|
var cartonModel =
|
||||||
|
Provider.of<CartonModel>(context, listen: false);
|
||||||
|
Carton _carton = await cartonModel.getCarton(_c.id);
|
||||||
|
_cartons.add(_carton);
|
||||||
|
setState(() {});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -369,7 +413,59 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
final cargoTableTitleBox = LocalTitle(
|
||||||
|
textKey: "box.cargo.type",
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.add_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||||
|
if (cargos == null) return;
|
||||||
|
setState(() {
|
||||||
|
_carton.cargoTypes.clear();
|
||||||
|
_carton.cargoTypes.addAll(cargos);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
final cargoTableBox = CargoTable(
|
||||||
|
isNew: _isNew,
|
||||||
|
cargoTypes: _carton.cargoTypes,
|
||||||
|
onAdd: (c) => _addCargo(c),
|
||||||
|
onRemove: (c) => _removeCargo(c),
|
||||||
|
);
|
||||||
|
|
||||||
|
final lengthBox = LengthPicker(
|
||||||
|
controller: _lengthController,
|
||||||
|
lableKey: "box.length",
|
||||||
|
isReadOnly: true,
|
||||||
|
);
|
||||||
|
final widthBox = LengthPicker(
|
||||||
|
controller: _widthController,
|
||||||
|
lableKey: "box.width",
|
||||||
|
isReadOnly: true,
|
||||||
|
);
|
||||||
|
final heightBox = LengthPicker(
|
||||||
|
controller: _heightController,
|
||||||
|
lableKey: "box.height",
|
||||||
|
isReadOnly: true,
|
||||||
|
);
|
||||||
|
final dimBox = Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
|
child: Icon(FontAwesome.arrow_circle_right, color: primaryColor),
|
||||||
|
),
|
||||||
|
SizedBox(child: lengthBox, width: 80),
|
||||||
|
SizedBox(child: widthBox, width: 80),
|
||||||
|
SizedBox(child: heightBox, width: 80),
|
||||||
|
],
|
||||||
|
);
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -432,20 +528,53 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
p.isChecked = checked;
|
p.isChecked = checked;
|
||||||
});
|
});
|
||||||
_populateDeliveryAddress();
|
// _populateDeliveryAddress();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cartonTitleBox,
|
_isNew ? cartonTitleBox : Container(),
|
||||||
Column(
|
_isNew
|
||||||
children: _getCartons(
|
? Column(
|
||||||
context,
|
children: _getCartons(
|
||||||
this._cartons,
|
context,
|
||||||
)),
|
this._cartons,
|
||||||
|
))
|
||||||
|
: Container(),
|
||||||
|
_isNew ? Container() : cargoTableTitleBox,
|
||||||
|
_isNew ? Container() : cargoTableBox,
|
||||||
|
_isNew
|
||||||
|
? Container()
|
||||||
|
: LocalTitle(textKey: "box.dimension"),
|
||||||
|
_isNew ? Container() : cartonSizeDropdown(),
|
||||||
|
_isNew ? Container() : dimBox,
|
||||||
|
_isNew
|
||||||
|
? Container()
|
||||||
|
: LocalTitle(textKey: "box.delivery_address"),
|
||||||
|
_isNew
|
||||||
|
? Container()
|
||||||
|
: DefaultDeliveryAddress(
|
||||||
|
deliveryAddress: _deliveryAddress,
|
||||||
|
labelKey: "box.delivery_address",
|
||||||
|
onTap: () async {
|
||||||
|
DeliveryAddress d =
|
||||||
|
await Navigator.push<DeliveryAddress>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
DeliveryAddressSelection(
|
||||||
|
deliveryAddress: _deliveryAddress,
|
||||||
|
deliveryAddresses:
|
||||||
|
_deliveryAddresses)),
|
||||||
|
);
|
||||||
|
if (d == null) return;
|
||||||
|
setState(() {
|
||||||
|
_deliveryAddress = d;
|
||||||
|
});
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
createBtn,
|
_isNew ? createBtn : saveBtn,
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
@@ -486,7 +615,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
CartonSize selectedCatonSize;
|
|
||||||
Widget cartonSizeDropdown() {
|
Widget cartonSizeDropdown() {
|
||||||
List<CartonSize> _cartonSizes =
|
List<CartonSize> _cartonSizes =
|
||||||
Provider.of<CartonSizeModel>(context).getCartonSizes;
|
Provider.of<CartonSizeModel>(context).getCartonSizes;
|
||||||
@@ -565,6 +693,20 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_addCargo(CargoType cargo) {
|
||||||
|
if (cargo == null) return;
|
||||||
|
setState(() {
|
||||||
|
_carton.cargoTypes.remove(cargo);
|
||||||
|
_carton.cargoTypes.add(cargo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeCargo(CargoType cargo) {
|
||||||
|
setState(() {
|
||||||
|
_carton.cargoTypes.remove(cargo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_save() async {
|
_save() async {
|
||||||
// bool isFromShipment = _selectedCartonType == carton_from_shipments;
|
// bool isFromShipment = _selectedCartonType == carton_from_shipments;
|
||||||
// bool isSmallBag = _selectedCartonType == carton_small_bag;
|
// bool isSmallBag = _selectedCartonType == carton_small_bag;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'package:fcs/domain/constants.dart';
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/entities/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/domain/entities/carton_size.dart';
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/carton_size/model/carton_size_model.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/package/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||||
@@ -88,6 +90,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
(isFromPackages || isSmallBag) &&
|
(isFromPackages || isSmallBag) &&
|
||||||
_box.status == carton_packed_status;
|
_box.status == carton_packed_status;
|
||||||
selectMixBoxType = _box.mixBoxType ?? "Mix Delivery";
|
selectMixBoxType = _box.mixBoxType ?? "Mix Delivery";
|
||||||
|
getCartonSize();
|
||||||
_cartons = [
|
_cartons = [
|
||||||
Carton(
|
Carton(
|
||||||
cartonNumber: "A100B-1#1",
|
cartonNumber: "A100B-1#1",
|
||||||
@@ -100,6 +103,20 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCartonSize() {
|
||||||
|
var cartonSizeModel = Provider.of<CartonSizeModel>(context, listen: false);
|
||||||
|
cartonSizeModel.cartonSizes.forEach((c) {
|
||||||
|
if (c.length == _box.length &&
|
||||||
|
c.width == _box.width &&
|
||||||
|
c.height == _box.height) {
|
||||||
|
print(c.name);
|
||||||
|
setState(() {
|
||||||
|
_cartonSizeController.text = c.name;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_loadPackages() async {
|
_loadPackages() async {
|
||||||
if (!isFromPackages && !isSmallBag) return;
|
if (!isFromPackages && !isSmallBag) return;
|
||||||
|
|
||||||
|
|||||||
@@ -207,11 +207,12 @@ class CartonModel extends BaseModel {
|
|||||||
return Carton.fromMap(snap.data, snap.documentID);
|
return Carton.fromMap(snap.data, snap.documentID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createCarton(Carton carton) {
|
Future<Carton> createCarton(Carton carton) {
|
||||||
return Services.instance.cartonService.createCarton(carton);
|
return Services.instance.cartonService.createCarton(carton);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateCarton(Carton carton) {
|
Future<void> updateCarton(Carton carton) {
|
||||||
|
print(carton.id);
|
||||||
return Services.instance.cartonService.updateCarton(carton);
|
return Services.instance.cartonService.updateCarton(carton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,19 +43,23 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
Carton _carton;
|
Carton _carton;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
|
List<DeliveryAddress> _deliveryAddresses = [];
|
||||||
List<CargoType> _cargoTypes = [];
|
List<CargoType> _cargoTypes = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
_load() {
|
||||||
|
_carton = widget.carton;
|
||||||
|
_getDeliverAddresses();
|
||||||
if (widget.isNew) {
|
if (widget.isNew) {
|
||||||
_carton = widget.carton;
|
|
||||||
_lengthCtl.text = "0";
|
_lengthCtl.text = "0";
|
||||||
_widthCtl.text = "0";
|
_widthCtl.text = "0";
|
||||||
_heightCtl.text = "0";
|
_heightCtl.text = "0";
|
||||||
} else {
|
} else {
|
||||||
_carton = widget.carton;
|
|
||||||
_cargoTypes = List.from(widget.carton.cargoTypes);
|
_cargoTypes = List.from(widget.carton.cargoTypes);
|
||||||
_lengthCtl.text = _carton.length.toString();
|
_lengthCtl.text = _carton.length.toString();
|
||||||
_widthCtl.text = _carton.width.toString();
|
_widthCtl.text = _carton.width.toString();
|
||||||
@@ -64,6 +68,13 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getDeliverAddresses() async {
|
||||||
|
var addressModel =
|
||||||
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
this._deliveryAddresses =
|
||||||
|
await addressModel.getDeliveryAddresses(_carton.userID);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final lengthBox = LengthPicker(
|
final lengthBox = LengthPicker(
|
||||||
@@ -163,8 +174,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _deliveryAddress,
|
deliveryAddress: _deliveryAddress,
|
||||||
)),
|
deliveryAddresses: this._deliveryAddresses)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -308,11 +319,12 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
CartonModel cartonModel =
|
CartonModel cartonModel =
|
||||||
Provider.of<CartonModel>(context, listen: false);
|
Provider.of<CartonModel>(context, listen: false);
|
||||||
if (widget.isNew) {
|
if (widget.isNew) {
|
||||||
await cartonModel.createCarton(carton);
|
Carton _c = await cartonModel.createCarton(carton);
|
||||||
|
Navigator.pop(context, _c);
|
||||||
} else {
|
} else {
|
||||||
await cartonModel.updateCarton(carton);
|
await cartonModel.updateCarton(carton);
|
||||||
|
Navigator.pop(context, carton);
|
||||||
}
|
}
|
||||||
Navigator.pop(context, true);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -84,4 +84,16 @@ class DeliveryAddressModel extends BaseModel {
|
|||||||
return Services.instance.deliveryAddressService
|
return Services.instance.deliveryAddressService
|
||||||
.selectDefalutDeliveryAddress(deliveryAddress);
|
.selectDefalutDeliveryAddress(deliveryAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<DeliveryAddress>> getDeliveryAddresses(String userID) async {
|
||||||
|
String path = "$delivery_address_collection/";
|
||||||
|
var querySnap = await Firestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.document("$userID")
|
||||||
|
.collection("$path")
|
||||||
|
.getDocuments();
|
||||||
|
return querySnap.documents
|
||||||
|
.map((e) => DeliveryAddress.fromMap(e.data, e.documentID))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,19 +70,20 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
bool canChangeDeliveryAddress =
|
bool canChangeDeliveryAddress =
|
||||||
_package?.status == package_received_status ||
|
_package?.status == package_received_status ||
|
||||||
_package?.status == package_processed_status;
|
_package?.status == package_processed_status;
|
||||||
|
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||||
|
|
||||||
final trackingIdBox = DisplayText(
|
final trackingIdBox = DisplayText(
|
||||||
text: _package?.trackingID??"",
|
text: _package?.trackingID ?? "",
|
||||||
labelTextKey: "package.tracking.id",
|
labelTextKey: "package.tracking.id",
|
||||||
iconData: MaterialCommunityIcons.barcode_scan,
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
);
|
);
|
||||||
var fcsIDBox = DisplayText(
|
var fcsIDBox = DisplayText(
|
||||||
text: _package?.fcsID??"",
|
text: _package?.fcsID ?? "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
);
|
);
|
||||||
final customerNameBox = DisplayText(
|
final customerNameBox = DisplayText(
|
||||||
text: _package?.userName??"",
|
text: _package?.userName ?? "",
|
||||||
labelTextKey: "package.create.name",
|
labelTextKey: "package.create.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
@@ -120,8 +121,8 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _package.deliveryAddress,
|
deliveryAddress: _package.deliveryAddress,
|
||||||
)),
|
deliveryAddresses: deliveryAddressModel.deliveryAddresses)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
_changeDeliverayAddress(d);
|
_changeDeliverayAddress(d);
|
||||||
@@ -158,7 +159,9 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
widget.isSearchResult ? Container() : fcsIDBox,
|
widget.isSearchResult ? Container() : fcsIDBox,
|
||||||
widget.isSearchResult ? Container() : customerNameBox,
|
widget.isSearchResult ? Container() : customerNameBox,
|
||||||
widget.isSearchResult ? Container() : marketBox,
|
widget.isSearchResult ? Container() : marketBox,
|
||||||
_package==null || _package.photoUrls.length == 0 ? Container() : img,
|
_package == null || _package.photoUrls.length == 0
|
||||||
|
? Container()
|
||||||
|
: img,
|
||||||
widget.isSearchResult ? Container() : descBox,
|
widget.isSearchResult ? Container() : descBox,
|
||||||
remarkBox,
|
remarkBox,
|
||||||
_package?.status == package_received_status &&
|
_package?.status == package_received_status &&
|
||||||
|
|||||||
@@ -114,7 +114,15 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
@@ -267,7 +275,8 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
PackageModel packageModel =
|
PackageModel packageModel =
|
||||||
Provider.of<PackageModel>(context, listen: false);
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
Package package=await packageModel.getPackageByTrackingID(_trackingIDCtl.text);
|
Package package =
|
||||||
|
await packageModel.getPackageByTrackingID(_trackingIDCtl.text);
|
||||||
package.trackingID = _trackingIDCtl.text;
|
package.trackingID = _trackingIDCtl.text;
|
||||||
package.market = selectedMarket;
|
package.market = selectedMarket;
|
||||||
package.desc = _descCtl.text;
|
package.desc = _descCtl.text;
|
||||||
@@ -275,8 +284,8 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
package.photoFiles = _isNew
|
package.photoFiles = _isNew
|
||||||
? multiImgController.getAddedFile
|
? multiImgController.getAddedFile
|
||||||
: multiImgController.getUpdatedFile;
|
: multiImgController.getUpdatedFile;
|
||||||
package.fcsID=widget.consignee.fcsID;
|
package.fcsID = widget.consignee.fcsID;
|
||||||
package.senderFCSID=widget.sender?.fcsID;
|
package.senderFCSID = widget.sender?.fcsID;
|
||||||
|
|
||||||
await packageModel.updateProcessing(package,
|
await packageModel.updateProcessing(package,
|
||||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
@@ -290,4 +299,12 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
return _trackingIDCtl.text != "" ||
|
||||||
|
selectedMarket != null ||
|
||||||
|
_descCtl.text != "" ||
|
||||||
|
_remarkCtl.text != "" ||
|
||||||
|
multiImgController.getAddedFile.isNotEmpty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,10 +267,23 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isDataChanged() {
|
isDataChanged() {
|
||||||
return _user.fcsID != "" ||
|
if (isNew) {
|
||||||
selectedMarket != "" ||
|
return _user.fcsID != "" ||
|
||||||
_descCtl.text != "" ||
|
selectedMarket != null ||
|
||||||
_remarkCtl.text != "" ||
|
_descCtl.text != "" ||
|
||||||
multiImgController.getAddedFile.isNotEmpty;
|
_remarkCtl.text != "" ||
|
||||||
|
multiImgController.getAddedFile.isNotEmpty;
|
||||||
|
} else {
|
||||||
|
var _package = Package(
|
||||||
|
trackingID: widget.package.trackingID,
|
||||||
|
fcsID: _user.fcsID,
|
||||||
|
market: selectedMarket,
|
||||||
|
desc: _descCtl.text,
|
||||||
|
remark: _remarkCtl.text,
|
||||||
|
photoUrls: widget.package.photoUrls);
|
||||||
|
return widget.package.isChangedForEditProcessing(_package) ||
|
||||||
|
multiImgController.getAddedFile.isNotEmpty ||
|
||||||
|
multiImgController.getDeletedUrl.isNotEmpty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||||
final shipmentWeightBox = DisplayText(
|
final shipmentWeightBox = DisplayText(
|
||||||
labelTextKey: "shipment.box.shipment.weight",
|
labelTextKey: "shipment.box.shipment.weight",
|
||||||
text: shipmentWeight == null ? "" : shipmentWeight.toStringAsFixed(0),
|
text: shipmentWeight == null ? "" : shipmentWeight.toStringAsFixed(0),
|
||||||
@@ -190,8 +191,9 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
|||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _box.deliveryAddress,
|
deliveryAddress: _box.deliveryAddress,
|
||||||
)),
|
deliveryAddresses:
|
||||||
|
deliveryAddressModel.deliveryAddresses)),
|
||||||
);
|
);
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
|
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
|
||||||
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
|
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
|
||||||
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
|
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
|
||||||
|
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||||
final fromTimeBox = InputTime(
|
final fromTimeBox = InputTime(
|
||||||
labelTextKey: 'shipment.from',
|
labelTextKey: 'shipment.from',
|
||||||
iconData: Icons.timer,
|
iconData: Icons.timer,
|
||||||
@@ -129,6 +130,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => DeliveryAddressSelection(
|
builder: (context) => DeliveryAddressSelection(
|
||||||
deliveryAddress: _shipment.pickupAddress,
|
deliveryAddress: _shipment.pickupAddress,
|
||||||
|
deliveryAddresses: deliveryAddressModel.deliveryAddresses,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
if (address == null) return;
|
if (address == null) return;
|
||||||
|
|||||||
@@ -2,23 +2,20 @@ import 'package:fcs/domain/vo/delivery_address.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_editor.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
||||||
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class DeliveryAddressSelection extends StatelessWidget {
|
class DeliveryAddressSelection extends StatelessWidget {
|
||||||
final DeliveryAddress deliveryAddress;
|
final DeliveryAddress deliveryAddress;
|
||||||
|
final List<DeliveryAddress> deliveryAddresses;
|
||||||
|
|
||||||
const DeliveryAddressSelection({Key key, this.deliveryAddress})
|
const DeliveryAddressSelection(
|
||||||
|
{Key key, this.deliveryAddress, this.deliveryAddresses})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var shipmentModel = Provider.of<DeliveryAddressModel>(context);
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
@@ -47,9 +44,9 @@ class DeliveryAddressSelection extends StatelessWidget {
|
|||||||
separatorBuilder: (c, i) => Divider(
|
separatorBuilder: (c, i) => Divider(
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
itemCount: shipmentModel.deliveryAddresses.length,
|
itemCount: deliveryAddresses.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return _row(context, shipmentModel.deliveryAddresses[index]);
|
return _row(context, deliveryAddresses[index]);
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user