Merge branch 'master' of tzw/fcs into master
This commit is contained in:
@@ -11,9 +11,10 @@ class CartonDataProvider {
|
||||
static final CartonDataProvider instance = CartonDataProvider._();
|
||||
CartonDataProvider._();
|
||||
|
||||
Future<void> createCarton(Carton carton) async {
|
||||
return await requestAPI("/cartons", "POST",
|
||||
Future<Carton> createCarton(Carton carton) async {
|
||||
var data = await requestAPI("/cartons", "POST",
|
||||
payload: carton.toMap(), token: await getToken());
|
||||
return Carton.fromMap(data, data['id']);
|
||||
}
|
||||
|
||||
Future<void> updateCarton(Carton carton) async {
|
||||
|
||||
@@ -15,7 +15,7 @@ class CartonServiceImp implements CartonService {
|
||||
final CartonDataProvider cartonDataProvider;
|
||||
|
||||
@override
|
||||
Future<void> createCarton(Carton carton) {
|
||||
Future<Carton> createCarton(Carton carton) {
|
||||
return cartonDataProvider.createCarton(carton);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
|
||||
abstract class CartonService {
|
||||
Future<void> createCarton(Carton carton);
|
||||
Future<Carton> createCarton(Carton carton);
|
||||
Future<void> updateCarton(Carton carton);
|
||||
Future<void> deleteCarton(Carton carton);
|
||||
Future<void> deliver(Carton carton);
|
||||
|
||||
@@ -199,9 +199,9 @@ class Carton {
|
||||
shipmentNumber: map['shipment_number'],
|
||||
receiverNumber: map['receiver_number'],
|
||||
boxNumber: map['box_number'],
|
||||
length: map['length'],
|
||||
width: map['width'],
|
||||
height: map['height'],
|
||||
length: double.tryParse(map['length']?.toString()),
|
||||
width: double.tryParse(map['width']?.toString()),
|
||||
height: double.tryParse(map['height']?.toString()),
|
||||
userName: map['user_name'],
|
||||
fcsID: map['fcs_id'],
|
||||
cartonType: map['carton_type'],
|
||||
|
||||
@@ -138,6 +138,14 @@ class Package {
|
||||
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
|
||||
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_search/carton_search.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/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_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/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/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_dropdown.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_icons/flutter_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'cargo_type_addtion.dart';
|
||||
import 'carton_cargo_table.dart';
|
||||
import 'carton_list_row.dart';
|
||||
import 'carton_row.dart';
|
||||
import 'mix_carton_editor.dart';
|
||||
@@ -47,6 +53,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
TextEditingController _widthController = new TextEditingController();
|
||||
TextEditingController _heightController = new TextEditingController();
|
||||
TextEditingController _lengthController = new TextEditingController();
|
||||
List<DeliveryAddress> _deliveryAddresses = [];
|
||||
|
||||
Carton _carton;
|
||||
bool _isLoading = false;
|
||||
@@ -62,6 +69,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
Carton _mixCarton;
|
||||
List<Carton> _cartons = [];
|
||||
List<Carton> _mixCartons = [];
|
||||
CartonSize selectedCatonSize;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -85,6 +93,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_isNew = false;
|
||||
_user = User(fcsID: _carton.fcsID, name: _carton.userName);
|
||||
_loadPackages();
|
||||
_getDeliverAddresses();
|
||||
getCartonSize();
|
||||
} else {
|
||||
_carton = Carton(
|
||||
cargoTypes: [],
|
||||
@@ -97,12 +107,12 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_selectedCartonType = carton_from_packages;
|
||||
_selectedMixType = mix_delivery;
|
||||
_loadFcsShipments();
|
||||
_cartons = [Carton(cartonNumber: "A100B-1#3", userName: "Seven 7")];
|
||||
// _cartons = [Carton(cartonNumber: "A100B-1#3", userName: "Seven 7")];
|
||||
|
||||
_mixCartons = [
|
||||
Carton(cartonNumber: "A100B-1#1", userName: "Seven 7"),
|
||||
Carton(cartonNumber: "A100B-1#2", userName: "Seven 7"),
|
||||
];
|
||||
// _mixCartons = [
|
||||
// Carton(cartonNumber: "A100B-1#1", userName: "Seven 7"),
|
||||
// Carton(cartonNumber: "A100B-1#2", userName: "Seven 7"),
|
||||
// ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,19 +162,19 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
setState(() {
|
||||
_carton.packages = packages;
|
||||
});
|
||||
_populateDeliveryAddress();
|
||||
// _populateDeliveryAddress();
|
||||
}
|
||||
|
||||
_populateDeliveryAddress() {
|
||||
if (_carton.packages == null) return;
|
||||
var d = _carton.packages
|
||||
.firstWhere((p) => p.isChecked && p.deliveryAddress != null,
|
||||
orElse: () => null)
|
||||
?.deliveryAddress;
|
||||
setState(() {
|
||||
_deliveryAddress = d;
|
||||
});
|
||||
}
|
||||
// _populateDeliveryAddress() {
|
||||
// if (_carton.packages == null) return;
|
||||
// var d = _carton.packages
|
||||
// .firstWhere((p) => p.isChecked && p.deliveryAddress != null,
|
||||
// orElse: () => null)
|
||||
// ?.deliveryAddress;
|
||||
// setState(() {
|
||||
// _deliveryAddress = d;
|
||||
// });
|
||||
// }
|
||||
|
||||
_calShipmentWeight() {
|
||||
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
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
@@ -267,7 +303,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
onPressed: () async {
|
||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||
if (_user == null && isFromPackages) {
|
||||
showMsgDialog(context, "Error", "Please select customer");
|
||||
showMsgDialog(context, "Error", "Please select FCS ID");
|
||||
return;
|
||||
}
|
||||
if (_fcsShipment == null && _isNew) {
|
||||
@@ -285,6 +321,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
carton.fcsShipmentID =
|
||||
_isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||
carton.userID = _user?.id;
|
||||
carton.fcsID = _user?.fcsID;
|
||||
carton.userName = _user?.name;
|
||||
carton.packages =
|
||||
_carton.packages.where((e) => e.isChecked).toList();
|
||||
|
||||
@@ -298,12 +336,18 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
Navigator.push(
|
||||
Carton _c = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
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) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} 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(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -432,20 +528,53 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
setState(() {
|
||||
p.isChecked = checked;
|
||||
});
|
||||
_populateDeliveryAddress();
|
||||
// _populateDeliveryAddress();
|
||||
},
|
||||
),
|
||||
cartonTitleBox,
|
||||
Column(
|
||||
children: _getCartons(
|
||||
context,
|
||||
this._cartons,
|
||||
)),
|
||||
_isNew ? cartonTitleBox : Container(),
|
||||
_isNew
|
||||
? Column(
|
||||
children: _getCartons(
|
||||
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(
|
||||
height: 20,
|
||||
),
|
||||
createBtn,
|
||||
_isNew ? createBtn : saveBtn,
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
@@ -486,7 +615,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
CartonSize selectedCatonSize;
|
||||
Widget cartonSizeDropdown() {
|
||||
List<CartonSize> _cartonSizes =
|
||||
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 {
|
||||
// bool isFromShipment = _selectedCartonType == carton_from_shipments;
|
||||
// bool isSmallBag = _selectedCartonType == carton_small_bag;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.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/vo/delivery_address.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/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
@@ -88,6 +90,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
(isFromPackages || isSmallBag) &&
|
||||
_box.status == carton_packed_status;
|
||||
selectMixBoxType = _box.mixBoxType ?? "Mix Delivery";
|
||||
getCartonSize();
|
||||
_cartons = [
|
||||
Carton(
|
||||
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 {
|
||||
if (!isFromPackages && !isSmallBag) return;
|
||||
|
||||
|
||||
@@ -207,11 +207,12 @@ class CartonModel extends BaseModel {
|
||||
return Carton.fromMap(snap.data, snap.documentID);
|
||||
}
|
||||
|
||||
Future<void> createCarton(Carton carton) {
|
||||
Future<Carton> createCarton(Carton carton) {
|
||||
return Services.instance.cartonService.createCarton(carton);
|
||||
}
|
||||
|
||||
Future<void> updateCarton(Carton carton) {
|
||||
print(carton.id);
|
||||
return Services.instance.cartonService.updateCarton(carton);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,19 +43,23 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
Carton _carton;
|
||||
bool _isLoading = false;
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
|
||||
List<DeliveryAddress> _deliveryAddresses = [];
|
||||
List<CargoType> _cargoTypes = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_load();
|
||||
}
|
||||
|
||||
_load() {
|
||||
_carton = widget.carton;
|
||||
_getDeliverAddresses();
|
||||
if (widget.isNew) {
|
||||
_carton = widget.carton;
|
||||
_lengthCtl.text = "0";
|
||||
_widthCtl.text = "0";
|
||||
_heightCtl.text = "0";
|
||||
} else {
|
||||
_carton = widget.carton;
|
||||
_cargoTypes = List.from(widget.carton.cargoTypes);
|
||||
_lengthCtl.text = _carton.length.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
|
||||
Widget build(BuildContext context) {
|
||||
final lengthBox = LengthPicker(
|
||||
@@ -163,8 +174,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
)),
|
||||
deliveryAddress: _deliveryAddress,
|
||||
deliveryAddresses: this._deliveryAddresses)),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
@@ -308,11 +319,12 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
CartonModel cartonModel =
|
||||
Provider.of<CartonModel>(context, listen: false);
|
||||
if (widget.isNew) {
|
||||
await cartonModel.createCarton(carton);
|
||||
Carton _c = await cartonModel.createCarton(carton);
|
||||
Navigator.pop(context, _c);
|
||||
} else {
|
||||
await cartonModel.updateCarton(carton);
|
||||
Navigator.pop(context, carton);
|
||||
}
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
|
||||
@@ -84,4 +84,16 @@ class DeliveryAddressModel extends BaseModel {
|
||||
return Services.instance.deliveryAddressService
|
||||
.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 =
|
||||
_package?.status == package_received_status ||
|
||||
_package?.status == package_processed_status;
|
||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||
|
||||
final trackingIdBox = DisplayText(
|
||||
text: _package?.trackingID??"",
|
||||
text: _package?.trackingID ?? "",
|
||||
labelTextKey: "package.tracking.id",
|
||||
iconData: MaterialCommunityIcons.barcode_scan,
|
||||
);
|
||||
var fcsIDBox = DisplayText(
|
||||
text: _package?.fcsID??"",
|
||||
text: _package?.fcsID ?? "",
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
final customerNameBox = DisplayText(
|
||||
text: _package?.userName??"",
|
||||
text: _package?.userName ?? "",
|
||||
labelTextKey: "package.create.name",
|
||||
iconData: Icons.perm_identity,
|
||||
);
|
||||
@@ -120,8 +121,8 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _package.deliveryAddress,
|
||||
)),
|
||||
deliveryAddress: _package.deliveryAddress,
|
||||
deliveryAddresses: deliveryAddressModel.deliveryAddresses)),
|
||||
);
|
||||
if (d == null) return;
|
||||
_changeDeliverayAddress(d);
|
||||
@@ -158,7 +159,9 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
widget.isSearchResult ? Container() : fcsIDBox,
|
||||
widget.isSearchResult ? Container() : customerNameBox,
|
||||
widget.isSearchResult ? Container() : marketBox,
|
||||
_package==null || _package.photoUrls.length == 0 ? Container() : img,
|
||||
_package == null || _package.photoUrls.length == 0
|
||||
? Container()
|
||||
: img,
|
||||
widget.isSearchResult ? Container() : descBox,
|
||||
remarkBox,
|
||||
_package?.status == package_received_status &&
|
||||
|
||||
@@ -114,7 +114,15 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
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,
|
||||
backgroundColor: Colors.white,
|
||||
@@ -267,7 +275,8 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
try {
|
||||
Package package=await packageModel.getPackageByTrackingID(_trackingIDCtl.text);
|
||||
Package package =
|
||||
await packageModel.getPackageByTrackingID(_trackingIDCtl.text);
|
||||
package.trackingID = _trackingIDCtl.text;
|
||||
package.market = selectedMarket;
|
||||
package.desc = _descCtl.text;
|
||||
@@ -275,8 +284,8 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
package.photoFiles = _isNew
|
||||
? multiImgController.getAddedFile
|
||||
: multiImgController.getUpdatedFile;
|
||||
package.fcsID=widget.consignee.fcsID;
|
||||
package.senderFCSID=widget.sender?.fcsID;
|
||||
package.fcsID = widget.consignee.fcsID;
|
||||
package.senderFCSID = widget.sender?.fcsID;
|
||||
|
||||
await packageModel.updateProcessing(package,
|
||||
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() {
|
||||
return _user.fcsID != "" ||
|
||||
selectedMarket != "" ||
|
||||
_descCtl.text != "" ||
|
||||
_remarkCtl.text != "" ||
|
||||
multiImgController.getAddedFile.isNotEmpty;
|
||||
if (isNew) {
|
||||
return _user.fcsID != "" ||
|
||||
selectedMarket != null ||
|
||||
_descCtl.text != "" ||
|
||||
_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
|
||||
Widget build(BuildContext context) {
|
||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||
final shipmentWeightBox = DisplayText(
|
||||
labelTextKey: "shipment.box.shipment.weight",
|
||||
text: shipmentWeight == null ? "" : shipmentWeight.toStringAsFixed(0),
|
||||
@@ -190,8 +191,9 @@ class _ShipmentBoxEditorState extends State<ShipmentBoxEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _box.deliveryAddress,
|
||||
)),
|
||||
deliveryAddress: _box.deliveryAddress,
|
||||
deliveryAddresses:
|
||||
deliveryAddressModel.deliveryAddresses)),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
|
||||
@@ -91,6 +91,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
bool isCourierPickup = _selectedShipmentType == shipment_courier_pickup;
|
||||
bool isLocalDropoff = _selectedShipmentType == shipment_local_dropoff;
|
||||
bool isCourierDropoff = _selectedShipmentType == shipment_courier_dropoff;
|
||||
var deliveryAddressModel = Provider.of<DeliveryAddressModel>(context);
|
||||
final fromTimeBox = InputTime(
|
||||
labelTextKey: 'shipment.from',
|
||||
iconData: Icons.timer,
|
||||
@@ -129,6 +130,7 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _shipment.pickupAddress,
|
||||
deliveryAddresses: deliveryAddressModel.deliveryAddresses,
|
||||
)),
|
||||
);
|
||||
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/pages/delivery_address/delivery_address_editor.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:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class DeliveryAddressSelection extends StatelessWidget {
|
||||
final DeliveryAddress deliveryAddress;
|
||||
final List<DeliveryAddress> deliveryAddresses;
|
||||
|
||||
const DeliveryAddressSelection({Key key, this.deliveryAddress})
|
||||
const DeliveryAddressSelection(
|
||||
{Key key, this.deliveryAddress, this.deliveryAddresses})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var shipmentModel = Provider.of<DeliveryAddressModel>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
@@ -47,9 +44,9 @@ class DeliveryAddressSelection extends StatelessWidget {
|
||||
separatorBuilder: (c, i) => Divider(
|
||||
color: primaryColor,
|
||||
),
|
||||
itemCount: shipmentModel.deliveryAddresses.length,
|
||||
itemCount: deliveryAddresses.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _row(context, shipmentModel.deliveryAddresses[index]);
|
||||
return _row(context, deliveryAddresses[index]);
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user