Merge branch 'master' of https://git.mokkon.com/sainw/fcs
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
"btn.ok": "Ok",
|
"btn.ok": "Ok",
|
||||||
"feet":"Feet",
|
"feet":"Feet",
|
||||||
"inch":"Inch",
|
"inch":"Inch",
|
||||||
|
"back.button_confirm":"Are you sure you want to continue without submitting changes?",
|
||||||
"Buttons End ================================================================":"",
|
"Buttons End ================================================================":"",
|
||||||
|
|
||||||
"Offline Start ================================================================":"",
|
"Offline Start ================================================================":"",
|
||||||
@@ -292,6 +293,13 @@
|
|||||||
"box.carton_size_remove.confirm":"Remove this carton size?",
|
"box.carton_size_remove.confirm":"Remove this carton size?",
|
||||||
"box.carton_size.name":"Name",
|
"box.carton_size.name":"Name",
|
||||||
"box.cargo_total_title":"Edit Total Weight",
|
"box.cargo_total_title":"Edit Total Weight",
|
||||||
|
"box.new_carton_btn":"Create new carton",
|
||||||
|
"box.select.cargo.title":"Select cargos",
|
||||||
|
"box.complete.packaging":"Complete Packaging",
|
||||||
|
"box.mix_caton_title":"Mix cartons",
|
||||||
|
"box.min_caton.form.title":"Mix Carton",
|
||||||
|
"box.mix_carton_btn":"Create mix carton",
|
||||||
|
"box.mix_type":"Mix Box Types",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
@@ -398,9 +406,12 @@
|
|||||||
"rate.delivery_fee":"Delivery fees",
|
"rate.delivery_fee":"Delivery fees",
|
||||||
"rate.total_estimated_amount":"Total estimated amount",
|
"rate.total_estimated_amount":"Total estimated amount",
|
||||||
"rate.volumetric_ratio":"Volumetric ratio",
|
"rate.volumetric_ratio":"Volumetric ratio",
|
||||||
|
"rate.diff_discount_weight":"Weight difference discount (lb)",
|
||||||
|
"rate.diff_weight_rate":"Weight difference rate",
|
||||||
"rate.custom.form.title":"Custom",
|
"rate.custom.form.title":"Custom",
|
||||||
"rate.cutom.product_type":"Product type",
|
"rate.cutom.product_type":"Product type",
|
||||||
"rate.custom.fee":"Fee",
|
"rate.custom.fee":"Fee",
|
||||||
|
"rate.custom.shipment_rate":"Shipment rate",
|
||||||
"rate.discount.weight":"Weight",
|
"rate.discount.weight":"Weight",
|
||||||
"rate.discount.rate":"Discount rate",
|
"rate.discount.rate":"Discount rate",
|
||||||
"rate.custom_duty.title":"Custom Fee",
|
"rate.custom_duty.title":"Custom Fee",
|
||||||
@@ -416,6 +427,7 @@
|
|||||||
"cargo.type":"Cargo type",
|
"cargo.type":"Cargo type",
|
||||||
"cargo.weight":"Weight",
|
"cargo.weight":"Weight",
|
||||||
"cargo.rate":"Rate",
|
"cargo.rate":"Rate",
|
||||||
|
"cargo.qty":"Quantity",
|
||||||
"cargo.amount":"Amount",
|
"cargo.amount":"Amount",
|
||||||
"cargo.edit.delete.confirm":"Delete this cargo type?",
|
"cargo.edit.delete.confirm":"Delete this cargo type?",
|
||||||
"Cargo End ================================================================":"",
|
"Cargo End ================================================================":"",
|
||||||
@@ -548,7 +560,7 @@
|
|||||||
"processing.create":"New Processing",
|
"processing.create":"New Processing",
|
||||||
"processing.update":"Update Processing",
|
"processing.update":"Update Processing",
|
||||||
"processing.consignee.name":"Consignee name",
|
"processing.consignee.name":"Consignee name",
|
||||||
"processing.shipper.name":"Shipper name",
|
"processing.shipper.name":"Sender name",
|
||||||
"processing.package.select.btn":"Select",
|
"processing.package.select.btn":"Select",
|
||||||
"processing.package.create":"New Package",
|
"processing.package.create":"New Package",
|
||||||
"processing.package.update":"Update Package",
|
"processing.package.update":"Update Package",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"btn.ok": "အိုကေ",
|
"btn.ok": "အိုကေ",
|
||||||
"feet":"ပေ",
|
"feet":"ပေ",
|
||||||
"inch":"လက်မ",
|
"inch":"လက်မ",
|
||||||
|
"back.button_confirm":"Are you sure you want to continue without submitting changes?",
|
||||||
"Buttons End ================================================================":"",
|
"Buttons End ================================================================":"",
|
||||||
|
|
||||||
"Offline Start ================================================================":"",
|
"Offline Start ================================================================":"",
|
||||||
@@ -292,6 +293,13 @@
|
|||||||
"box.carton_size_remove.confirm":"Remove this carton size?",
|
"box.carton_size_remove.confirm":"Remove this carton size?",
|
||||||
"box.carton_size.name":"နာမည်",
|
"box.carton_size.name":"နာမည်",
|
||||||
"box.cargo_total_title":"စုစုပေါင်းအလေးချိန် ပြုပြင်မည်",
|
"box.cargo_total_title":"စုစုပေါင်းအလေးချိန် ပြုပြင်မည်",
|
||||||
|
"box.new_carton_btn":"သေတ္တာ အသစ်ပြုလုပ်မည်",
|
||||||
|
"box.select.cargo.title":"Sကုန်ပစ္စည်းများ ရွေးခြင်း",
|
||||||
|
"box.complete.packaging":"ထုပ်ပိုးခြင်း ပြီးဆုံးမည်",
|
||||||
|
"box.mix_caton_title":"Mix cartons",
|
||||||
|
"box.min_caton.form.title":"Mix Carton",
|
||||||
|
"box.mix_carton_btn":"Create mix carton",
|
||||||
|
"box.mix_type":"Mix Box Types",
|
||||||
"Boxes End ================================================================":"",
|
"Boxes End ================================================================":"",
|
||||||
|
|
||||||
"Delivery Start ================================================================":"",
|
"Delivery Start ================================================================":"",
|
||||||
@@ -398,9 +406,12 @@
|
|||||||
"rate.delivery_fee":"ပို့ဆောင်ခ",
|
"rate.delivery_fee":"ပို့ဆောင်ခ",
|
||||||
"rate.total_estimated_amount":"စုစုပေါင်းခန့်မှန်းပမာဏ",
|
"rate.total_estimated_amount":"စုစုပေါင်းခန့်မှန်းပမာဏ",
|
||||||
"rate.volumetric_ratio":"Volumetric Ratio",
|
"rate.volumetric_ratio":"Volumetric Ratio",
|
||||||
|
"rate.diff_discount_weight":"Weight difference discount (lb)",
|
||||||
|
"rate.diff_weight_rate":"Weight difference rate",
|
||||||
"rate.custom.form.title":"အကောက်ခွန်",
|
"rate.custom.form.title":"အကောက်ခွန်",
|
||||||
"rate.cutom.product_type":"ကုန်ပစ္စည်းအမျိုးအစား",
|
"rate.cutom.product_type":"ကုန်ပစ္စည်းအမျိုးအစား",
|
||||||
"rate.custom.fee":"အခကြေးငွေ",
|
"rate.custom.fee":"အခကြေးငွေ",
|
||||||
|
"rate.custom.shipment_rate":"တင်ပို့နှုန်း",
|
||||||
"rate.discount.weight":"အလေးချိန်",
|
"rate.discount.weight":"အလေးချိန်",
|
||||||
"rate.discount.rate":"လျှော့စျေးနှုန်း",
|
"rate.discount.rate":"လျှော့စျေးနှုန်း",
|
||||||
"rate.custom_duty.title":"အကောက်ခွန်များ",
|
"rate.custom_duty.title":"အကောက်ခွန်များ",
|
||||||
@@ -416,6 +427,7 @@
|
|||||||
"cargo.type":"ကုန်ပစ္စည်းအမျိုးအစား",
|
"cargo.type":"ကုန်ပစ္စည်းအမျိုးအစား",
|
||||||
"cargo.weight":"အလေးချိန်",
|
"cargo.weight":"အလေးချိန်",
|
||||||
"cargo.rate":"စျေးနှုန်း",
|
"cargo.rate":"စျေးနှုန်း",
|
||||||
|
"cargo.qty":"အရေအတွက်",
|
||||||
"cargo.amount":"ပမာဏ",
|
"cargo.amount":"ပမာဏ",
|
||||||
"cargo.edit.delete.confirm":"ကုန်ပစ္စည်းကို ဖျက်မလား?",
|
"cargo.edit.delete.confirm":"ကုန်ပစ္စည်းကို ဖျက်မလား?",
|
||||||
"Cargo End ================================================================":"",
|
"Cargo End ================================================================":"",
|
||||||
|
|||||||
@@ -14,16 +14,18 @@ class Config {
|
|||||||
final String reportURL;
|
final String reportURL;
|
||||||
final Level level;
|
final Level level;
|
||||||
final String reportProjectID;
|
final String reportProjectID;
|
||||||
|
final String bucketName;
|
||||||
|
|
||||||
factory Config(
|
factory Config(
|
||||||
{@required Flavor flavor,
|
{@required Flavor flavor,
|
||||||
@required String apiURL,
|
@required String apiURL,
|
||||||
@required String reportURL,
|
@required String reportURL,
|
||||||
@required String reportProjectID,
|
@required String reportProjectID,
|
||||||
|
@required String bucketName,
|
||||||
Color color: Colors.blue,
|
Color color: Colors.blue,
|
||||||
Level level: Level.SEVERE}) {
|
Level level: Level.SEVERE}) {
|
||||||
_instance ??= Config._internal(flavor, FlavorNames[flavor.index], color,
|
_instance ??= Config._internal(flavor, FlavorNames[flavor.index], color,
|
||||||
apiURL, reportURL, level, reportProjectID);
|
apiURL, reportURL, level, reportProjectID, bucketName);
|
||||||
|
|
||||||
Logger.root.level = level;
|
Logger.root.level = level;
|
||||||
Logger.root.onRecord.listen((record) {
|
Logger.root.onRecord.listen((record) {
|
||||||
@@ -35,7 +37,7 @@ class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Config._internal(this.flavor, this.name, this.color, this.apiURL,
|
Config._internal(this.flavor, this.name, this.color, this.apiURL,
|
||||||
this.reportURL, this.level, this.reportProjectID);
|
this.reportURL, this.level, this.reportProjectID, this.bucketName);
|
||||||
|
|
||||||
static Config get instance {
|
static Config get instance {
|
||||||
return _instance;
|
return _instance;
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ class RateDataProvider {
|
|||||||
_rate.deliveryFee = rate.deliveryFee;
|
_rate.deliveryFee = rate.deliveryFee;
|
||||||
_rate.freeDeliveryWeight = rate.freeDeliveryWeight;
|
_rate.freeDeliveryWeight = rate.freeDeliveryWeight;
|
||||||
_rate.volumetricRatio = rate.volumetricRatio;
|
_rate.volumetricRatio = rate.volumetricRatio;
|
||||||
|
_rate.diffDiscountWeight = rate.diffDiscountWeight;
|
||||||
|
_rate.diffWeightRate = rate.diffWeightRate;
|
||||||
controller.add(_rate);
|
controller.add(_rate);
|
||||||
});
|
});
|
||||||
cargoListener = _cargoTypeStream().listen((cargoTypes) {
|
cargoListener = _cargoTypeStream().listen((cargoTypes) {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ const user_collection = "users";
|
|||||||
const invitations_collection = "invitations";
|
const invitations_collection = "invitations";
|
||||||
const privilege_collection = "privileges";
|
const privilege_collection = "privileges";
|
||||||
const markets_collection = "markets";
|
const markets_collection = "markets";
|
||||||
|
const carton_sizes_collection = "carton_sizes";
|
||||||
|
|
||||||
const packages_collection = "packages";
|
const packages_collection = "packages";
|
||||||
const messages_collection = "messages";
|
const messages_collection = "messages";
|
||||||
const fcs_shipment_collection = "fcs_shipments";
|
const fcs_shipment_collection = "fcs_shipments";
|
||||||
@@ -77,8 +79,13 @@ const shipment_courier_dropoff = "Courier drop off";
|
|||||||
//Carton types
|
//Carton types
|
||||||
const carton_from_packages = "From packages";
|
const carton_from_packages = "From packages";
|
||||||
const carton_from_shipments = "From shipments";
|
const carton_from_shipments = "From shipments";
|
||||||
const carton_mix_box = "Mix carton";
|
const carton_mix_carton = "Mix carton";
|
||||||
const carton_small_bag = "Small bag";
|
const carton_small_bag = "Small bag";
|
||||||
|
const carton_mix_box = "Mix box";
|
||||||
|
|
||||||
|
//Mix types
|
||||||
|
const mix_delivery = "Mix Delivery";
|
||||||
|
const mix_pickup = "Mix Pickup";
|
||||||
|
|
||||||
//Carton status
|
//Carton status
|
||||||
const carton_packed_status = "packed";
|
const carton_packed_status = "packed";
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ class CargoType {
|
|||||||
double rate;
|
double rate;
|
||||||
double weight;
|
double weight;
|
||||||
bool isChecked;
|
bool isChecked;
|
||||||
|
int qty;
|
||||||
|
bool isCutomDuty = false;
|
||||||
|
|
||||||
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
|
double get calAmount => (calRate ?? 0) * (calWeight ?? 0);
|
||||||
|
|
||||||
@@ -20,15 +22,16 @@ class CargoType {
|
|||||||
calRate: map['cal_rate']?.toDouble() ?? 0,
|
calRate: map['cal_rate']?.toDouble() ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
CargoType({
|
CargoType(
|
||||||
this.id,
|
{this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.rate,
|
this.rate,
|
||||||
this.weight,
|
this.weight,
|
||||||
this.calWeight,
|
this.calWeight,
|
||||||
this.calRate,
|
this.calRate,
|
||||||
this.isChecked = false,
|
this.isChecked = false,
|
||||||
});
|
this.qty = 0,
|
||||||
|
this.isCutomDuty = false});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
@@ -55,4 +58,8 @@ class CargoType {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(CargoType cargoType) {
|
||||||
|
return cargoType.name != this.name || cargoType.rate != this.rate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ class Carton {
|
|||||||
String fcsShipmentNumber;
|
String fcsShipmentNumber;
|
||||||
String mixCartonID;
|
String mixCartonID;
|
||||||
String mixCartonNumber;
|
String mixCartonNumber;
|
||||||
|
String cartonSizeID;
|
||||||
|
String cartonSizeName;
|
||||||
|
String mixBoxType;
|
||||||
|
|
||||||
int rate;
|
int rate;
|
||||||
int weight;
|
int weight;
|
||||||
@@ -62,7 +65,7 @@ class Carton {
|
|||||||
double get actualWeight =>
|
double get actualWeight =>
|
||||||
cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
|
cargoTypes == null ? 0 : cargoTypes.fold(0, (p, e) => e.weight + p);
|
||||||
|
|
||||||
double getShipmentWeight(double volumetricRatio) {
|
int getShipmentWeight(double volumetricRatio) {
|
||||||
if (length == null ||
|
if (length == null ||
|
||||||
length <= 0 ||
|
length <= 0 ||
|
||||||
width == null ||
|
width == null ||
|
||||||
@@ -72,7 +75,7 @@ class Carton {
|
|||||||
volumetricRatio == null ||
|
volumetricRatio == null ||
|
||||||
volumetricRatio <= 0) return 0;
|
volumetricRatio <= 0) return 0;
|
||||||
|
|
||||||
return (length * width * height) / volumetricRatio;
|
return ((length * width * height) / volumetricRatio).round();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getCargoTypeForCalWeight returns carton with shipment weight
|
/// getCargoTypeForCalWeight returns carton with shipment weight
|
||||||
@@ -95,25 +98,26 @@ class Carton {
|
|||||||
/// calAmount returns total amount
|
/// calAmount returns total amount
|
||||||
double calAmount(Rate rate) {
|
double calAmount(Rate rate) {
|
||||||
// get shipment weight
|
// get shipment weight
|
||||||
double volume = (length ?? 0) * (width ?? 0) * (height ?? 0);
|
int sw = getShipmentWeight(rate.volumetricRatio);
|
||||||
double sw = volume / rate.volumetricRatio ?? 0;
|
|
||||||
|
|
||||||
// get actual weight
|
// get actual weight
|
||||||
double aw = cargoTypes.fold(0.0, (p, c) => p + c.weight);
|
double aw = cargoTypes.fold(0.0, (p, c) => p + c.weight);
|
||||||
if (aw == 0 || sw == 0) return 0;
|
if (aw == 0 || sw == 0) return 0;
|
||||||
|
|
||||||
DiscountByWeight discountByWeight =
|
double wd = sw - aw;
|
||||||
rate.getDiscountByWeight(sw > aw ? sw : aw);
|
wd = wd - rate.diffDiscountWeight;
|
||||||
|
double wdAmount = wd > 0 ? wd * rate.diffWeightRate : 0;
|
||||||
|
|
||||||
|
DiscountByWeight discountByWeight = rate.getDiscountByWeight(aw);
|
||||||
|
|
||||||
double total = 0;
|
double total = 0;
|
||||||
cargoTypes.forEach((e) {
|
cargoTypes.forEach((e) {
|
||||||
double cargoWeight = aw > sw ? e.weight : e.weight / aw * sw;
|
|
||||||
double r =
|
double r =
|
||||||
e.rate - (discountByWeight != null ? discountByWeight.discount : 0);
|
e.rate - (discountByWeight != null ? discountByWeight.discount : 0);
|
||||||
double amount = cargoWeight * r;
|
double amount = e.weight * r;
|
||||||
total += amount;
|
total += amount;
|
||||||
});
|
});
|
||||||
return total;
|
return total + wdAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ShipmentStatus> shipmentHistory;
|
List<ShipmentStatus> shipmentHistory;
|
||||||
@@ -157,7 +161,10 @@ class Carton {
|
|||||||
this.mixCartonID,
|
this.mixCartonID,
|
||||||
this.mixCartonNumber,
|
this.mixCartonNumber,
|
||||||
this.isShipmentCarton = false,
|
this.isShipmentCarton = false,
|
||||||
this.deliveryAddress});
|
this.deliveryAddress,
|
||||||
|
this.cartonSizeID,
|
||||||
|
this.cartonSizeName,
|
||||||
|
this.mixBoxType});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
||||||
|
|||||||
@@ -5,4 +5,31 @@ class CartonSize {
|
|||||||
double width;
|
double width;
|
||||||
double height;
|
double height;
|
||||||
CartonSize({this.id, this.name, this.length, this.width, this.height});
|
CartonSize({this.id, this.name, this.length, this.width, this.height});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'length': length,
|
||||||
|
'width': width,
|
||||||
|
'height': height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory CartonSize.fromMap(Map<String, dynamic> map, String id) {
|
||||||
|
return CartonSize(
|
||||||
|
id: id,
|
||||||
|
name: map['name'],
|
||||||
|
length: map['length'],
|
||||||
|
width: map['width'],
|
||||||
|
height: map['height'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(CartonSize cartonSize) {
|
||||||
|
return cartonSize.name != this.name ||
|
||||||
|
cartonSize.length != this.length ||
|
||||||
|
cartonSize.width != this.width ||
|
||||||
|
cartonSize.height != this.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ class CustomDuty {
|
|||||||
String productType;
|
String productType;
|
||||||
String desc;
|
String desc;
|
||||||
double fee;
|
double fee;
|
||||||
CustomDuty({this.id, this.productType, this.desc, this.fee});
|
double shipmentRate;
|
||||||
|
CustomDuty(
|
||||||
|
{this.id, this.productType, this.desc, this.fee, this.shipmentRate});
|
||||||
|
|
||||||
factory CustomDuty.fromMap(Map<String, dynamic> map, String id) {
|
factory CustomDuty.fromMap(Map<String, dynamic> map, String id) {
|
||||||
return CustomDuty(
|
return CustomDuty(
|
||||||
@@ -28,4 +30,11 @@ class CustomDuty {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => id.hashCode;
|
int get hashCode => id.hashCode;
|
||||||
|
|
||||||
|
bool isChangedForEdit(CustomDuty customDuty) {
|
||||||
|
return customDuty.productType != this.productType ||
|
||||||
|
customDuty.fee != this.fee
|
||||||
|
// ||customDuty.shipmentRate != this.shipmentRate
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,10 @@ class Discount {
|
|||||||
status: map['status'],
|
status: map['status'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(Discount discount) {
|
||||||
|
return discount.code != this.code ||
|
||||||
|
discount.amount != this.amount ||
|
||||||
|
discount.customerId != this.customerId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,9 @@ class DiscountByWeight {
|
|||||||
'discount': discount,
|
'discount': discount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(DiscountByWeight discountByWeight) {
|
||||||
|
return discountByWeight.weight != this.weight ||
|
||||||
|
discountByWeight.discount != this.discount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,14 @@ class FcsShipment {
|
|||||||
bool isConfirmed() {
|
bool isConfirmed() {
|
||||||
return status == fcs_shipment_confirmed_status;
|
return status == fcs_shipment_confirmed_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(FcsShipment fcsShipment) {
|
||||||
|
return fcsShipment.shipmentNumber != this.shipmentNumber ||
|
||||||
|
fcsShipment.cutoffDate != this.cutoffDate ||
|
||||||
|
fcsShipment.arrivalDate != this.arrivalDate ||
|
||||||
|
fcsShipment.shipType != this.shipType ||
|
||||||
|
fcsShipment.consignee != this.consignee ||
|
||||||
|
fcsShipment.port != this.port ||
|
||||||
|
fcsShipment.destination != this.destination;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class Package {
|
|||||||
'tracking_id': trackingID,
|
'tracking_id': trackingID,
|
||||||
'market': market,
|
'market': market,
|
||||||
'fcs_id': fcsID,
|
'fcs_id': fcsID,
|
||||||
|
'sender_fcs_id': senderFCSID,
|
||||||
"desc": desc,
|
"desc": desc,
|
||||||
"remark": remark,
|
"remark": remark,
|
||||||
"photo_urls": photoUrls
|
"photo_urls": photoUrls
|
||||||
@@ -131,6 +132,12 @@ class Package {
|
|||||||
currentStatusDate: DateTime.parse(json['status_date']));
|
currentStatusDate: DateTime.parse(json['status_date']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(Package package) {
|
||||||
|
return package.trackingID != this.trackingID ||
|
||||||
|
package.remark != this.remark ||
|
||||||
|
package.fcsID != this.fcsID;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => other is Package && other.id == id;
|
bool operator ==(Object other) => other is Package && other.id == id;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ class Processing {
|
|||||||
@override
|
@override
|
||||||
int get hashCode => id.hashCode;
|
int get hashCode => id.hashCode;
|
||||||
|
|
||||||
|
bool isChangedForEdit(Processing processing) {
|
||||||
|
return processing.userID != this.userID ||
|
||||||
|
processing.fcsID != this.fcsID ||
|
||||||
|
processing.packages != this.packages;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Processing{id: $id}';
|
return 'Processing{id: $id}';
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ class Rate {
|
|||||||
double freeDeliveryWeight;
|
double freeDeliveryWeight;
|
||||||
double volumetricRatio;
|
double volumetricRatio;
|
||||||
|
|
||||||
|
double diffDiscountWeight;
|
||||||
|
double diffWeightRate;
|
||||||
|
|
||||||
List<CargoType> cargoTypes;
|
List<CargoType> cargoTypes;
|
||||||
List<CustomDuty> customDuties;
|
List<CustomDuty> customDuties;
|
||||||
List<DiscountByWeight> discountByWeights;
|
List<DiscountByWeight> discountByWeights;
|
||||||
@@ -22,17 +25,20 @@ class Rate {
|
|||||||
? null
|
? null
|
||||||
: cargoTypes.firstWhere((e) => e.name == "General");
|
: cargoTypes.firstWhere((e) => e.name == "General");
|
||||||
|
|
||||||
Rate({
|
Rate(
|
||||||
this.deliveryFee,
|
{this.deliveryFee,
|
||||||
this.freeDeliveryWeight,
|
this.freeDeliveryWeight,
|
||||||
this.volumetricRatio,
|
this.volumetricRatio,
|
||||||
});
|
this.diffDiscountWeight,
|
||||||
|
this.diffWeightRate});
|
||||||
|
|
||||||
factory Rate.fromMap(Map<String, dynamic> map) {
|
factory Rate.fromMap(Map<String, dynamic> map) {
|
||||||
return Rate(
|
return Rate(
|
||||||
deliveryFee: (map['delivery_fee'] ?? 0).toDouble(),
|
deliveryFee: (map['delivery_fee'] ?? 0).toDouble(),
|
||||||
freeDeliveryWeight: (map['free_delivery_weight'] ?? 0).toDouble(),
|
freeDeliveryWeight: (map['free_delivery_weight'] ?? 0).toDouble(),
|
||||||
volumetricRatio: (map['volumetric_ratio'] ?? 0).toDouble(),
|
volumetricRatio: (map['volumetric_ratio'] ?? 0).toDouble(),
|
||||||
|
diffDiscountWeight: (map['diff_discount_weight'] ?? 0).toDouble(),
|
||||||
|
diffWeightRate: (map['diff_weight_rate'] ?? 0).toDouble(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,11 +47,21 @@ class Rate {
|
|||||||
"delivery_fee": deliveryFee,
|
"delivery_fee": deliveryFee,
|
||||||
'free_delivery_weight': freeDeliveryWeight,
|
'free_delivery_weight': freeDeliveryWeight,
|
||||||
'volumetric_ratio': volumetricRatio,
|
'volumetric_ratio': volumetricRatio,
|
||||||
|
'diff_discount_weight': diffDiscountWeight,
|
||||||
|
'diff_weight_rate': diffWeightRate,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(Rate rate) {
|
||||||
|
return rate.freeDeliveryWeight != this.freeDeliveryWeight ||
|
||||||
|
rate.deliveryFee != this.deliveryFee ||
|
||||||
|
rate.volumetricRatio != this.volumetricRatio ||
|
||||||
|
rate.diffDiscountWeight != this.diffDiscountWeight ||
|
||||||
|
rate.diffWeightRate != this.diffWeightRate;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Rate{deliveryFee:$deliveryFee,freeDeliveryWeight:$freeDeliveryWeight,volumetricRatio:$volumetricRatio}';
|
return 'Rate{deliveryFee:$deliveryFee,freeDeliveryWeight:$freeDeliveryWeight,volumetricRatio:$volumetricRatio,diffDiscountWeight:$diffDiscountWeight,diffWeightRate:$diffWeightRate}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,4 +41,13 @@ class DeliveryAddress {
|
|||||||
'phone_number': phoneNumber,
|
'phone_number': phoneNumber,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChangedForEdit(DeliveryAddress deliveryAddress) {
|
||||||
|
return deliveryAddress.fullName != this.fullName ||
|
||||||
|
deliveryAddress.phoneNumber != this.phoneNumber ||
|
||||||
|
deliveryAddress.addressLine1 != this.addressLine1 ||
|
||||||
|
deliveryAddress.addressLine2 != this.addressLine2 ||
|
||||||
|
deliveryAddress.state != this.state ||
|
||||||
|
deliveryAddress.city != this.city;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ class ShipmentStatus {
|
|||||||
String status;
|
String status;
|
||||||
DateTime date;
|
DateTime date;
|
||||||
bool done;
|
bool done;
|
||||||
ShipmentStatus({this.status, this.date, this.done});
|
String staffId;
|
||||||
|
String staffName;
|
||||||
|
ShipmentStatus(
|
||||||
|
{this.status, this.date, this.done, this.staffId, this.staffName});
|
||||||
|
|
||||||
factory ShipmentStatus.fromMap(Map<String, dynamic> map) {
|
factory ShipmentStatus.fromMap(Map<String, dynamic> map) {
|
||||||
var _date = (map['date'] as Timestamp);
|
var _date = (map['date'] as Timestamp);
|
||||||
@@ -12,6 +15,7 @@ class ShipmentStatus {
|
|||||||
status: map['status'],
|
status: map['status'],
|
||||||
date: _date == null ? null : _date.toDate(),
|
date: _date == null ? null : _date.toDate(),
|
||||||
done: map['done'],
|
done: map['done'],
|
||||||
);
|
staffId: map['staff_id'],
|
||||||
|
staffName: map['staff_name']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fcs/config.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:firebase_storage/firebase_storage.dart';
|
import 'package:firebase_storage/firebase_storage.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
@@ -39,7 +40,9 @@ Future<String> uploadStorage(String path, File file, {String fileName}) async {
|
|||||||
fileName = Uuid().v4();
|
fileName = Uuid().v4();
|
||||||
}
|
}
|
||||||
StorageReference storageReference =
|
StorageReference storageReference =
|
||||||
FirebaseStorage.instance.ref().child('$path/$fileName');
|
FirebaseStorage(storageBucket: Config.instance.bucketName)
|
||||||
|
.ref()
|
||||||
|
.child('$path/$fileName');
|
||||||
StorageUploadTask uploadTask = storageReference.putFile(file);
|
StorageUploadTask uploadTask = storageReference.putFile(file);
|
||||||
await uploadTask.onComplete;
|
await uploadTask.onComplete;
|
||||||
String downloadUrl = await storageReference.getDownloadURL();
|
String downloadUrl = await storageReference.getDownloadURL();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ void main() {
|
|||||||
apiURL: "https://asia-northeast1-fcs-dev1.cloudfunctions.net/API",
|
apiURL: "https://asia-northeast1-fcs-dev1.cloudfunctions.net/API",
|
||||||
reportURL: "http://petrok.mokkon.com:8091",
|
reportURL: "http://petrok.mokkon.com:8091",
|
||||||
reportProjectID: "fcs-dev",
|
reportProjectID: "fcs-dev",
|
||||||
|
bucketName: "gs://fcs-dev1-us",
|
||||||
level: Level.ALL);
|
level: Level.ALL);
|
||||||
runApp(App());
|
runApp(App());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ void main() {
|
|||||||
Config(
|
Config(
|
||||||
flavor: Flavor.DEV,
|
flavor: Flavor.DEV,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
reportURL: "http://192.168.100.11:8080",
|
reportURL: "http://petrok.mokkon.com:8091",
|
||||||
reportProjectID: "fcs-dev",
|
reportProjectID: "fcs-dev",
|
||||||
apiURL: "http://192.168.100.11:7777",
|
apiURL: "http://192.168.1.155:7777",
|
||||||
|
bucketName: "gs://fcs-dev1-us",
|
||||||
level: Level.ALL);
|
level: Level.ALL);
|
||||||
runApp(App());
|
runApp(App());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ void main() {
|
|||||||
apiURL: "https://asia-northeast1-fcs-prod1.cloudfunctions.net/API",
|
apiURL: "https://asia-northeast1-fcs-prod1.cloudfunctions.net/API",
|
||||||
reportURL: "http://petrok.mokkon.com:8092",
|
reportURL: "http://petrok.mokkon.com:8092",
|
||||||
reportProjectID: "fcs-prod",
|
reportProjectID: "fcs-prod",
|
||||||
|
bucketName: "gs://fcs-prod1",
|
||||||
level: Level.ALL);
|
level: Level.ALL);
|
||||||
runApp(App());
|
runApp(App());
|
||||||
}
|
}
|
||||||
|
|||||||
118
lib/pages/carton/cargo_table.dart
Normal file
118
lib/pages/carton/cargo_table.dart
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CargoTable extends StatefulWidget {
|
||||||
|
final List<CargoType> cargoTypes;
|
||||||
|
|
||||||
|
const CargoTable({
|
||||||
|
Key key,
|
||||||
|
this.cargoTypes,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CargoTableState createState() => _CargoTableState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CargoTableState extends State<CargoTable> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: MyDataTable(
|
||||||
|
headingRowHeight: 40,
|
||||||
|
columnSpacing: 50,
|
||||||
|
columns: [
|
||||||
|
MyDataColumn(
|
||||||
|
label: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.type",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MyDataColumn(
|
||||||
|
label: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.qty",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MyDataColumn(
|
||||||
|
label: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.weight",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
rows: getCargoRows(context),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MyDataRow> getCargoRows(BuildContext context) {
|
||||||
|
if (widget.cargoTypes == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
double total = 0;
|
||||||
|
var rows = widget.cargoTypes.map((c) {
|
||||||
|
total += c.weight;
|
||||||
|
return MyDataRow(
|
||||||
|
onSelectChanged: (bool selected) async {},
|
||||||
|
cells: [
|
||||||
|
MyDataCell(new Text(
|
||||||
|
c.name == null ? "" : c.name,
|
||||||
|
style: textStyle,
|
||||||
|
)),
|
||||||
|
MyDataCell(c.qty == null || c.qty == 0
|
||||||
|
? Center(
|
||||||
|
child: Text(
|
||||||
|
"-",
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: Text(
|
||||||
|
c.qty.toString(),
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
MyDataCell(
|
||||||
|
Text(c.weight == null ? "0" : c.weight.toStringAsFixed(2),
|
||||||
|
style: textStyle),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
var totalRow = MyDataRow(
|
||||||
|
onSelectChanged: (bool selected) {},
|
||||||
|
cells: [
|
||||||
|
MyDataCell(Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"shipment.cargo.total",
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
MyDataCell(Text("")),
|
||||||
|
MyDataCell(
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 48.0),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Text(total.toStringAsFixed(2),
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
rows.add(totalRow);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/rates/custom_list.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/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -21,9 +24,15 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
cargos =
|
var shipmentRateModel =
|
||||||
Provider.of<ShipmentRateModel>(context, listen: false).rate.cargoTypes;
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
cargos.forEach((p) => p.isChecked = false);
|
cargos = List.from(shipmentRateModel.rate.cargoTypes);
|
||||||
|
cargos.forEach((p) {
|
||||||
|
p.isChecked = false;
|
||||||
|
p.isCutomDuty = false;
|
||||||
|
p.weight = 0;
|
||||||
|
p.qty = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -31,48 +40,58 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> showcargoTypeList(BuildContext context) {
|
@override
|
||||||
return this.cargos.map((c) {
|
Widget build(BuildContext context) {
|
||||||
return new ListTile(
|
List<Widget> getCargoRowList() {
|
||||||
contentPadding: EdgeInsets.all(0),
|
return cargos.map((c) {
|
||||||
title: InkWell(
|
return Container(
|
||||||
onTap: () {
|
child: Container(
|
||||||
setState(() {
|
padding:
|
||||||
c.isChecked = c.isChecked == null ? true : !c.isChecked;
|
EdgeInsets.only(left: 10.0, right: 5.0, top: 3.0, bottom: 3.0),
|
||||||
});
|
child: Row(
|
||||||
},
|
|
||||||
child: new Row(
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Checkbox(
|
Checkbox(
|
||||||
value: c.isChecked == null ? false : c.isChecked,
|
value: c.isChecked,
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool check) {
|
||||||
setState(() {
|
setState(() {
|
||||||
c.isChecked = value;
|
c.isChecked = check;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
new Text(
|
new Text(c.name, style: textStyle),
|
||||||
c.name,
|
c.isCutomDuty
|
||||||
style: TextStyle(fontSize: 15.0, color: primaryColor),
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 15),
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
cargos.removeWhere((t) => t.name == c.name);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.remove_circle,
|
||||||
|
color: Colors.black45,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final saveBtn = fcsButton(
|
final saveBtn = fcsButton(
|
||||||
context,
|
context,
|
||||||
getLocalString(context, 'box.cargo.save.btn'),
|
getLocalString(context, 'box.cargo.save.btn'),
|
||||||
callack: () {
|
callack: () {
|
||||||
this.cargos.forEach((p) => p.weight = 0.00);
|
|
||||||
List<CargoType> _cargos =
|
List<CargoType> _cargos =
|
||||||
this.cargos.where((c) => c.isChecked).toList();
|
this.cargos.where((c) => c.isChecked).toList();
|
||||||
Navigator.pop(context, _cargos);
|
Navigator.pop(context, _cargos);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -92,12 +111,27 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
)),
|
)),
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(18),
|
padding: EdgeInsets.all(8),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
LocalTitle(
|
||||||
|
textKey: "box.select.cargo.title",
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.add_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
CustomDuty customDuty = await Navigator.of(context).push(
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
CustomList(selected: true)));
|
||||||
|
_addCustom(customDuty);
|
||||||
|
}),
|
||||||
|
),
|
||||||
Column(
|
Column(
|
||||||
children: showcargoTypeList(context),
|
children: getCargoRowList(),
|
||||||
),
|
),
|
||||||
SizedBox(height: 30),
|
SizedBox(height: 30),
|
||||||
saveBtn,
|
saveBtn,
|
||||||
@@ -109,8 +143,14 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List<CargoType> cargoTypeList() {
|
_addCustom(CustomDuty customDuty) {
|
||||||
// return this.privileges.where((p) => p.isChecked).map((p) => p.id).toList();
|
if (customDuty == null) return;
|
||||||
// }
|
|
||||||
|
|
||||||
|
if (cargos.any((c) => c.name == customDuty.productType)) return;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
cargos.add(CargoType(
|
||||||
|
name: customDuty.productType, isCutomDuty: true, qty: 1, weight: 0));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/widgets/dialog_input.dart';
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/my_data_table.dart';
|
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'cargo_type_editor.dart';
|
import 'cargo_type_editor.dart';
|
||||||
import 'total_weight_edit.dart';
|
|
||||||
|
|
||||||
typedef OnAdd(CargoType cargoType);
|
typedef OnAdd(CargoType cargoType);
|
||||||
typedef OnRemove(CargoType cargoType);
|
typedef OnRemove(CargoType cargoType);
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
class CargoTable extends StatefulWidget {
|
||||||
final List<CargoType> cargoTypes;
|
final List<CargoType> cargoTypes;
|
||||||
|
final bool isNew;
|
||||||
final OnAdd onAdd;
|
final OnAdd onAdd;
|
||||||
final OnRemove onRemove;
|
final OnRemove onRemove;
|
||||||
|
|
||||||
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
const CargoTable(
|
||||||
|
{Key key, this.cargoTypes, this.isNew, this.onAdd, this.onRemove})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -25,10 +28,31 @@ class CargoTable extends StatefulWidget {
|
|||||||
|
|
||||||
class _CargoTableState extends State<CargoTable> {
|
class _CargoTableState extends State<CargoTable> {
|
||||||
double totalWeight = 0;
|
double totalWeight = 0;
|
||||||
|
List<CargoType> _cargos = [];
|
||||||
|
double remainingWeight = 0;
|
||||||
|
List<String> _list = [];
|
||||||
|
List<String> _types = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
if (!widget.isNew) {
|
||||||
|
totalWeight = widget.cargoTypes
|
||||||
|
.fold(0, (previous, current) => previous + current.weight);
|
||||||
|
}
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MyDataTable(
|
remainingWeight =
|
||||||
|
widget.cargoTypes.length == 0 ? this.totalWeight : remainingWeight;
|
||||||
|
this._cargos = widget.cargoTypes.length == 0 ? [] : this._cargos;
|
||||||
|
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: MyDataTable(
|
||||||
headingRowHeight: 40,
|
headingRowHeight: 40,
|
||||||
|
columnSpacing: 40,
|
||||||
columns: [
|
columns: [
|
||||||
MyDataColumn(
|
MyDataColumn(
|
||||||
label: LocalText(
|
label: LocalText(
|
||||||
@@ -37,6 +61,13 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MyDataColumn(
|
||||||
|
label: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.qty",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
MyDataColumn(
|
MyDataColumn(
|
||||||
label: LocalText(
|
label: LocalText(
|
||||||
context,
|
context,
|
||||||
@@ -46,6 +77,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
rows: getCargoRows(context),
|
rows: getCargoRows(context),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,30 +86,118 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
double _total = 0;
|
CargoType cargo;
|
||||||
var rows = widget.cargoTypes.map((c) {
|
|
||||||
_total += c.weight;
|
|
||||||
|
|
||||||
|
var rows = widget.cargoTypes.map((c) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {
|
onSelectChanged: (bool selected) async {},
|
||||||
CargoType cargo = await Navigator.push<CargoType>(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => CargoTypeEditor(
|
|
||||||
cargo: c,
|
|
||||||
)));
|
|
||||||
if (widget.onAdd != null) widget.onAdd(cargo);
|
|
||||||
},
|
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(new Text(
|
MyDataCell(
|
||||||
|
new Text(
|
||||||
c.name == null ? "" : c.name,
|
c.name == null ? "" : c.name,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
|
MyDataCell(
|
||||||
|
c.isCutomDuty
|
||||||
|
? GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
String _t = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => DialogInput(
|
||||||
|
label: "cargo.qty", value: c.qty.toString()));
|
||||||
|
|
||||||
|
if (_t == null) return;
|
||||||
|
setState(() {
|
||||||
|
c.qty = int.parse(_t);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
width: 40,
|
||||||
|
padding: const EdgeInsets.all(7.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: primaryColor),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||||
|
),
|
||||||
|
child: new Text(
|
||||||
|
c.qty == null ? "" : c.qty.toString(),
|
||||||
|
style: textStyle,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: new Text(
|
||||||
|
"-",
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
if (this.totalWeight <= 0) {
|
||||||
|
showMsgDialog(
|
||||||
|
context, "Error", "Please insert total weight");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String _t = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => DialogInput(
|
||||||
|
label: "cargo.weight",
|
||||||
|
value: c.weight.toStringAsFixed(2)));
|
||||||
|
|
||||||
|
if (_t == null) return;
|
||||||
|
setState(() {
|
||||||
|
c.weight = double.parse(_t);
|
||||||
|
});
|
||||||
|
|
||||||
|
cargo = c;
|
||||||
|
this._cargos.add(cargo);
|
||||||
|
if (this.remainingWeight <= 0) return;
|
||||||
|
this.remainingWeight -= cargo.weight;
|
||||||
|
|
||||||
|
this._cargos.forEach((c) {
|
||||||
|
_list.add(c.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.cargoTypes.forEach((c) {
|
||||||
|
_types.add(c.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this._cargos.length == widget.cargoTypes.length - 1) {
|
||||||
|
_types.forEach((t) {
|
||||||
|
if (!_list.contains(t)) {
|
||||||
|
widget.cargoTypes.forEach((c) {
|
||||||
|
if (c.name == t) {
|
||||||
|
c.weight = this.remainingWeight;
|
||||||
|
setState(() {
|
||||||
|
this._cargos = [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.remainingWeight = this.totalWeight;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(7.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: primaryColor),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
c.weight == null ? "0.00" : c.weight.toStringAsFixed(2),
|
||||||
|
style: textStyle),
|
||||||
|
),
|
||||||
|
),
|
||||||
widget.onRemove == null
|
widget.onRemove == null
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: 50,
|
width: 50,
|
||||||
@@ -98,14 +218,7 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
var totalRow = MyDataRow(
|
var totalRow = MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {
|
onSelectChanged: (bool selected) {},
|
||||||
double _t = await Navigator.of(context).push<double>(CupertinoPageRoute(
|
|
||||||
builder: (context) => TotalWeightEdit(totalWeight: totalWeight)));
|
|
||||||
if (_t == null) return;
|
|
||||||
setState(() {
|
|
||||||
totalWeight = _t;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
cells: [
|
cells: [
|
||||||
MyDataCell(Align(
|
MyDataCell(Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
@@ -116,13 +229,36 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
MyDataCell(Text("")),
|
||||||
MyDataCell(
|
MyDataCell(
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 48.0),
|
padding: const EdgeInsets.only(right: 48.0),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
String _t = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => DialogInput(
|
||||||
|
label: "shipment.cargo.total",
|
||||||
|
value: totalWeight.toStringAsFixed(2)));
|
||||||
|
|
||||||
|
if (_t == null) return;
|
||||||
|
setState(() {
|
||||||
|
totalWeight = double.parse(_t);
|
||||||
|
remainingWeight = totalWeight;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(7.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: primaryColor),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||||
|
),
|
||||||
child: Text(totalWeight.toStringAsFixed(2),
|
child: Text(totalWeight.toStringAsFixed(2),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold))),
|
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
),
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -131,11 +267,6 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getRemainBalance(double total) {
|
|
||||||
double _r = this.totalWeight < total ? 0 : this.totalWeight - total;
|
|
||||||
return _r;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<MyDataRow> _getCargoRows(BuildContext context) {
|
List<MyDataRow> _getCargoRows(BuildContext context) {
|
||||||
if (widget.cargoTypes == null) {
|
if (widget.cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
184
lib/pages/carton/carton_cargo_table_old.dart
Normal file
184
lib/pages/carton/carton_cargo_table_old.dart
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/my_data_table.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'cargo_type_editor.dart';
|
||||||
|
import 'total_weight_edit.dart';
|
||||||
|
|
||||||
|
typedef OnAdd(CargoType cargoType);
|
||||||
|
typedef OnRemove(CargoType cargoType);
|
||||||
|
|
||||||
|
class CargoTable extends StatefulWidget {
|
||||||
|
final List<CargoType> cargoTypes;
|
||||||
|
final OnAdd onAdd;
|
||||||
|
final OnRemove onRemove;
|
||||||
|
|
||||||
|
const CargoTable({Key key, this.cargoTypes, this.onAdd, this.onRemove})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CargoTableState createState() => _CargoTableState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CargoTableState extends State<CargoTable> {
|
||||||
|
double totalWeight = 0;
|
||||||
|
List<CargoType> _cargos = [];
|
||||||
|
double remainingWeight = 0;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MyDataTable(
|
||||||
|
headingRowHeight: 40,
|
||||||
|
columns: [
|
||||||
|
MyDataColumn(
|
||||||
|
label: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.type",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MyDataColumn(
|
||||||
|
label: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 50),
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"cargo.weight",
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
rows: getCargoRows(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MyDataRow> getCargoRows(BuildContext context) {
|
||||||
|
if (widget.cargoTypes == null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
List<String> _list = [];
|
||||||
|
List<String> _types = [];
|
||||||
|
double _total = 0;
|
||||||
|
|
||||||
|
var rows = widget.cargoTypes.map((c) {
|
||||||
|
_total += c.weight;
|
||||||
|
return MyDataRow(
|
||||||
|
onSelectChanged: (bool selected) async {},
|
||||||
|
cells: [
|
||||||
|
MyDataCell(Row(
|
||||||
|
children: [
|
||||||
|
new Text(
|
||||||
|
c.name == null ? "" : c.name,
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
|
new Text(
|
||||||
|
c.qty == null || c.qty == 0 ? "" : " x ${c.qty.toString()}",
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
MyDataCell(
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(c.weight.toStringAsFixed(2), style: textStyle),
|
||||||
|
widget.onRemove == null
|
||||||
|
? SizedBox(
|
||||||
|
width: 50,
|
||||||
|
)
|
||||||
|
: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.remove_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (widget.onRemove != null) widget.onRemove(c);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
var totalRow = MyDataRow(
|
||||||
|
onSelectChanged: (bool selected) {},
|
||||||
|
cells: [
|
||||||
|
MyDataCell(Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"shipment.cargo.total",
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
MyDataCell(
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 40.0),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
double _t = await Navigator.of(context).push<double>(
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
TotalWeightEdit(totalWeight: totalWeight)));
|
||||||
|
if (_t == null) return;
|
||||||
|
setState(() {
|
||||||
|
totalWeight = _t;
|
||||||
|
this.remainingWeight = this.totalWeight - _total;
|
||||||
|
widget.cargoTypes.forEach((c) {
|
||||||
|
if (c.qty == null) {
|
||||||
|
this._cargos.add(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this._cargos.forEach((c) {
|
||||||
|
_list.add(c.name);
|
||||||
|
});
|
||||||
|
widget.cargoTypes.forEach((c) {
|
||||||
|
_types.add(c.name);
|
||||||
|
});
|
||||||
|
if (this._cargos.length == widget.cargoTypes.length - 1) {
|
||||||
|
_types.forEach((t) {
|
||||||
|
if (!_list.contains(t)) {
|
||||||
|
widget.cargoTypes.forEach((c) {
|
||||||
|
if (c.name == t) {
|
||||||
|
c.weight = this.remainingWeight;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(7.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: Colors.grey),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(5.0)),
|
||||||
|
),
|
||||||
|
child: Text(totalWeight.toStringAsFixed(2),
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
rows.add(totalRow);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
double getRemainBalance(double total) {
|
||||||
|
double _r = this.totalWeight < total ? 0 : this.totalWeight - total;
|
||||||
|
return _r;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,20 +7,16 @@ import 'package:fcs/domain/entities/package.dart';
|
|||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.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/carton_cargo_table.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_size/carton_size_list.dart';
|
import 'package:fcs/pages/carton_size/carton_size_list.dart';
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_list.dart';
|
|
||||||
import 'package:fcs/pages/delivery_address/delivery_address_row.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/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';
|
||||||
@@ -31,10 +27,12 @@ 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_list_row.dart';
|
||||||
import 'cargo_type_editor.dart';
|
import 'carton_row.dart';
|
||||||
|
import 'mix_carton_editor.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
import '../carton_size/model/carton_size_model.dart';
|
import '../carton_size/model/carton_size_model.dart';
|
||||||
|
import 'package_carton_editor.dart';
|
||||||
import 'widgets.dart';
|
import 'widgets.dart';
|
||||||
|
|
||||||
class CartonEditor extends StatefulWidget {
|
class CartonEditor extends StatefulWidget {
|
||||||
@@ -56,12 +54,14 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
User _user;
|
User _user;
|
||||||
String _selectedCartonType;
|
String _selectedCartonType;
|
||||||
|
String _selectedMixType;
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
FcsShipment _fcsShipment;
|
FcsShipment _fcsShipment;
|
||||||
List<FcsShipment> _fcsShipments;
|
List<FcsShipment> _fcsShipments;
|
||||||
Carton _mixCarton;
|
Carton _mixCarton;
|
||||||
List<Carton> _mixCartons;
|
List<Carton> _cartons = [];
|
||||||
|
List<Carton> _mixCartons = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -90,12 +90,19 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
cargoTypes: [],
|
cargoTypes: [],
|
||||||
packages: [],
|
packages: [],
|
||||||
);
|
);
|
||||||
_lengthController.text = "";
|
_lengthController.text = "0";
|
||||||
_widthController.text = "";
|
_widthController.text = "0";
|
||||||
_heightController.text = "";
|
_heightController.text = "0";
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
_selectedCartonType = carton_from_packages;
|
_selectedCartonType = carton_from_packages;
|
||||||
|
_selectedMixType = mix_delivery;
|
||||||
_loadFcsShipments();
|
_loadFcsShipments();
|
||||||
|
_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"),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,18 +166,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadMixCartons() async {
|
|
||||||
if (_fcsShipment == null || _fcsShipment.id == null) return;
|
|
||||||
if (_selectedCartonType != carton_small_bag) return;
|
|
||||||
|
|
||||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
|
||||||
List<Carton> cartons =
|
|
||||||
await cartonModel.getMixCartonsByFcsShipment(_fcsShipment.id);
|
|
||||||
setState(() {
|
|
||||||
_mixCartons = cartons;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_calShipmentWeight() {
|
_calShipmentWeight() {
|
||||||
double l = double.parse(_lengthController.text, (s) => 0);
|
double l = double.parse(_lengthController.text, (s) => 0);
|
||||||
double w = double.parse(_widthController.text, (s) => 0);
|
double w = double.parse(_widthController.text, (s) => 0);
|
||||||
@@ -189,17 +184,13 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var boxModel = Provider.of<CartonModel>(context);
|
var boxModel = Provider.of<CartonModel>(context);
|
||||||
bool isMixBox = _selectedCartonType == carton_mix_box;
|
bool isMixBox = _selectedCartonType == carton_mix_box;
|
||||||
bool isSmallBag = _selectedCartonType == carton_small_bag;
|
|
||||||
final shipmentBox = DisplayText(
|
final shipmentBox = DisplayText(
|
||||||
text: _carton.fcsShipmentNumber,
|
text: _carton.fcsShipmentNumber,
|
||||||
labelTextKey: "box.fcs_shipment_num",
|
labelTextKey: "box.fcs_shipment_num",
|
||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
);
|
);
|
||||||
final mixCartonNumberBox = DisplayText(
|
|
||||||
text: _carton.mixCartonNumber,
|
|
||||||
labelTextKey: "box.mix.carton",
|
|
||||||
iconData: MaterialCommunityIcons.package,
|
|
||||||
);
|
|
||||||
var fcsShipmentsBox = Container(
|
var fcsShipmentsBox = Container(
|
||||||
padding: EdgeInsets.only(top: 10),
|
padding: EdgeInsets.only(top: 10),
|
||||||
child: LocalDropdown<FcsShipment>(
|
child: LocalDropdown<FcsShipment>(
|
||||||
@@ -207,7 +198,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_fcsShipment = v;
|
_fcsShipment = v;
|
||||||
});
|
});
|
||||||
_loadMixCartons();
|
|
||||||
},
|
},
|
||||||
labelKey: "shipment.pack.fcs.shipment",
|
labelKey: "shipment.pack.fcs.shipment",
|
||||||
iconData: Ionicons.ios_airplane,
|
iconData: Ionicons.ios_airplane,
|
||||||
@@ -216,21 +206,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
values: _fcsShipments,
|
values: _fcsShipments,
|
||||||
));
|
));
|
||||||
|
|
||||||
var mixCartonsBox = Container(
|
|
||||||
padding: EdgeInsets.only(top: 10),
|
|
||||||
child: LocalDropdown<Carton>(
|
|
||||||
callback: (v) {
|
|
||||||
setState(() {
|
|
||||||
_mixCarton = v;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
labelKey: "box.mix.carton",
|
|
||||||
iconData: MaterialCommunityIcons.package,
|
|
||||||
display: (u) => u.cartonNumber,
|
|
||||||
selectedValue: _mixCarton,
|
|
||||||
values: _mixCartons,
|
|
||||||
));
|
|
||||||
|
|
||||||
final fcsIDBox = Container(
|
final fcsIDBox = Container(
|
||||||
padding: EdgeInsets.only(top: 10),
|
padding: EdgeInsets.only(top: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -261,43 +236,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
|
|
||||||
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),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
final shipmentWeightBox = DisplayText(
|
|
||||||
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(2) : "",
|
|
||||||
labelTextKey: "box.shipment_weight",
|
|
||||||
iconData: MaterialCommunityIcons.weight,
|
|
||||||
);
|
|
||||||
|
|
||||||
final createBtn = LocalButton(
|
final createBtn = LocalButton(
|
||||||
textKey: "box.create.btn",
|
textKey: "box.complete.packaging",
|
||||||
callBack: _save,
|
callBack: _save,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -316,32 +256,118 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
final cargoTableTitleBox = LocalTitle(
|
final cartonTitleBox = Container(
|
||||||
textKey: "box.cargo.type",
|
child: LocalTitle(
|
||||||
|
textKey: "boxes.title",
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.add_circle,
|
Icons.add_circle,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// CargoType cargo = await Navigator.push<CargoType>(context,
|
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||||
// CupertinoPageRoute(builder: (context) => CargoTypeEditor()));
|
if (_user == null && isFromPackages) {
|
||||||
// _addCargo(cargo);
|
showMsgDialog(context, "Error", "Please select customer");
|
||||||
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
return;
|
||||||
context,
|
}
|
||||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
if (_fcsShipment == null && _isNew) {
|
||||||
if (cargos == null) return;
|
showMsgDialog(context, "Error", "Please select FCS shipment");
|
||||||
|
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);
|
||||||
|
|
||||||
|
Carton carton = Carton();
|
||||||
|
carton.id = _carton.id;
|
||||||
|
carton.cartonType = _selectedCartonType;
|
||||||
|
carton.fcsShipmentID =
|
||||||
|
_isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||||
|
carton.userID = _user?.id;
|
||||||
|
carton.packages =
|
||||||
|
_carton.packages.where((e) => e.isChecked).toList();
|
||||||
|
|
||||||
|
carton.cargoTypes = _carton.cargoTypes;
|
||||||
|
carton.length = l;
|
||||||
|
carton.width = w;
|
||||||
|
carton.height = h;
|
||||||
|
|
||||||
|
carton.deliveryAddress = _carton.deliveryAddress;
|
||||||
setState(() {
|
setState(() {
|
||||||
_carton.cargoTypes.clear();
|
_isLoading = true;
|
||||||
_carton.cargoTypes.addAll(cargos);
|
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
PackageCartonEditor(carton: carton, isNew: _isNew)),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final cargoTableBox = CargoTable(
|
final mixTypeBox = Container(
|
||||||
cargoTypes: _carton.cargoTypes,
|
padding: EdgeInsets.only(top: 20),
|
||||||
onAdd: (c) => _addCargo(c),
|
child: Column(
|
||||||
onRemove: (c) => _removeCargo(c),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 5),
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"box.mix_type",
|
||||||
|
color: primaryColor,
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
)),
|
||||||
|
Row(
|
||||||
|
children: boxModel.mixTypes.map((e) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Radio(
|
||||||
|
value: e,
|
||||||
|
groupValue: _selectedMixType,
|
||||||
|
activeColor: primaryColor,
|
||||||
|
onChanged: (v) {
|
||||||
|
setState(() {
|
||||||
|
_selectedMixType = v;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text(e),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final mixcartonTitleBox = Container(
|
||||||
|
child: LocalTitle(
|
||||||
|
textKey: "box.mix_caton_title",
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.add_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(builder: (context) => MixCartonEditor()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
@@ -351,20 +377,21 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
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,
|
||||||
title: _isNew
|
title: LocalText(
|
||||||
? LocalText(
|
|
||||||
context,
|
context,
|
||||||
"boxes.create.title",
|
"box.info.title",
|
||||||
fontSize: 20,
|
|
||||||
color: primaryColor,
|
|
||||||
)
|
|
||||||
: LocalText(
|
|
||||||
context,
|
|
||||||
"box.edit.title",
|
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
@@ -381,21 +408,15 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
cartonTypeBox,
|
cartonTypeBox,
|
||||||
LocalTitle(textKey: "box.shipment_info"),
|
LocalTitle(textKey: "box.shipment_info"),
|
||||||
_isNew ? fcsShipmentsBox : shipmentBox,
|
_isNew ? fcsShipmentsBox : shipmentBox,
|
||||||
isSmallBag
|
isMixBox ? mixTypeBox : Container(),
|
||||||
? _isNew
|
|
||||||
? mixCartonsBox
|
|
||||||
: mixCartonNumberBox
|
|
||||||
: Container(),
|
|
||||||
...(isMixBox
|
...(isMixBox
|
||||||
? [
|
? [
|
||||||
// CartonMixTable(
|
mixcartonTitleBox,
|
||||||
// cartons: _carton.cartons,
|
Column(
|
||||||
// onSelect: (c, check) {
|
children: _getMixCartons(
|
||||||
// setState(() {
|
context,
|
||||||
// c.isChecked = check;
|
this._mixCartons,
|
||||||
// });
|
)),
|
||||||
// },
|
|
||||||
// )
|
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
fcsIDBox,
|
fcsIDBox,
|
||||||
@@ -414,33 +435,17 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
_populateDeliveryAddress();
|
_populateDeliveryAddress();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
cargoTableTitleBox,
|
cartonTitleBox,
|
||||||
cargoTableBox,
|
Column(
|
||||||
isSmallBag
|
children: _getCartons(
|
||||||
? Container()
|
|
||||||
: LocalTitle(textKey: "box.dimension"),
|
|
||||||
isSmallBag ? Container() : cartonSizeDropdown(),
|
|
||||||
isSmallBag ? Container() : dimBox,
|
|
||||||
isSmallBag ? Container() : shipmentWeightBox,
|
|
||||||
LocalTitle(textKey: "box.delivery_address"),
|
|
||||||
DefaultDeliveryAddress(
|
|
||||||
deliveryAddress: _deliveryAddress,
|
|
||||||
labelKey: "box.delivery_address",
|
|
||||||
onTap: () async {
|
|
||||||
DeliveryAddress _address = await Navigator.push(
|
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
this._cartons,
|
||||||
builder: (context) => DeliveryAddressList(
|
)),
|
||||||
isAdminCreation: true,
|
|
||||||
deliveryAddress: _deliveryAddress)));
|
|
||||||
if (_address == null) return;
|
|
||||||
setState(() {
|
|
||||||
_deliveryAddress = _address;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
_isNew ? createBtn : saveBtn,
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
createBtn,
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
@@ -451,6 +456,36 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_addCarton(Carton carton) {
|
||||||
|
if (carton == null) return;
|
||||||
|
this._cartons.add(carton);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _getCartons(BuildContext context, List<Carton> cartons) {
|
||||||
|
return cartons.map((c) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
child: CartonRow(
|
||||||
|
key: ValueKey(c.id),
|
||||||
|
box: c,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _getMixCartons(BuildContext context, List<Carton> cartons) {
|
||||||
|
return cartons.map((c) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
child: CartonRow(
|
||||||
|
key: ValueKey(c.id),
|
||||||
|
box: c,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
CartonSize selectedCatonSize;
|
CartonSize selectedCatonSize;
|
||||||
Widget cartonSizeDropdown() {
|
Widget cartonSizeDropdown() {
|
||||||
List<CartonSize> _cartonSizes =
|
List<CartonSize> _cartonSizes =
|
||||||
@@ -530,92 +565,78 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getAddressList(
|
|
||||||
BuildContext context, List<DeliveryAddress> addresses) {
|
|
||||||
return addresses.asMap().entries.map((s) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: () {},
|
|
||||||
child: DeliveryAddressRow(deliveryAddress: s.value),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
_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;
|
||||||
if (_user == null && (isFromShipment || isSmallBag)) {
|
// if (_user == null && (isFromShipment || isSmallBag)) {
|
||||||
showMsgDialog(context, "Error", "Please select customer");
|
// showMsgDialog(context, "Error", "Please select customer");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (_fcsShipment == null && _isNew) {
|
// if (_fcsShipment == null && _isNew) {
|
||||||
showMsgDialog(context, "Error", "Please select FCS shipment");
|
// showMsgDialog(context, "Error", "Please select FCS shipment");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if ((_carton.cargoTypes?.length ?? 0) == 0 &&
|
// if ((_carton.cargoTypes?.length ?? 0) == 0 &&
|
||||||
(isFromShipment || isSmallBag)) {
|
// (isFromShipment || isSmallBag)) {
|
||||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
// showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
double l = double.parse(_lengthController.text, (s) => 0);
|
// double l = double.parse(_lengthController.text, (s) => 0);
|
||||||
double w = double.parse(_widthController.text, (s) => 0);
|
// double w = double.parse(_widthController.text, (s) => 0);
|
||||||
double h = double.parse(_heightController.text, (s) => 0);
|
// double h = double.parse(_heightController.text, (s) => 0);
|
||||||
if ((l <= 0 || w <= 0 || h <= 0) && isFromShipment) {
|
// if ((l <= 0 || w <= 0 || h <= 0) && isFromShipment) {
|
||||||
showMsgDialog(context, "Error", "Invalid dimension");
|
// showMsgDialog(context, "Error", "Invalid dimension");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (_deliveryAddress == null && (isFromShipment || isSmallBag)) {
|
// if (_deliveryAddress == null && (isFromShipment || isSmallBag)) {
|
||||||
showMsgDialog(context, "Error", "Invalid delivery address");
|
// showMsgDialog(context, "Error", "Invalid delivery address");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (isSmallBag && _mixCarton == null && _isNew) {
|
// if (isSmallBag && _mixCarton == null && _isNew) {
|
||||||
showMsgDialog(context, "Error", "Invalid mix carton");
|
// showMsgDialog(context, "Error", "Invalid mix carton");
|
||||||
return;
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Carton carton = Carton();
|
||||||
|
// carton.id = _carton.id;
|
||||||
|
// carton.cartonType = _selectedCartonType;
|
||||||
|
// carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
||||||
|
// carton.userID = _user?.id;
|
||||||
|
// carton.cargoTypes = _carton.cargoTypes;
|
||||||
|
// carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||||
|
// carton.mixCartonID = _mixCarton?.id;
|
||||||
|
// carton.length = l;
|
||||||
|
// carton.width = w;
|
||||||
|
// carton.height = h;
|
||||||
|
// carton.deliveryAddress = _deliveryAddress;
|
||||||
|
// setState(() {
|
||||||
|
// _isLoading = true;
|
||||||
|
// });
|
||||||
|
// try {
|
||||||
|
// CartonModel cartonModel =
|
||||||
|
// Provider.of<CartonModel>(context, listen: false);
|
||||||
|
// if (_isNew) {
|
||||||
|
// await cartonModel.createCarton(carton);
|
||||||
|
// } else {
|
||||||
|
// await cartonModel.updateCarton(carton);
|
||||||
|
// }
|
||||||
|
// Navigator.pop(context, true);
|
||||||
|
// } catch (e) {
|
||||||
|
// showMsgDialog(context, "Error", e.toString());
|
||||||
|
// } finally {
|
||||||
|
// setState(() {
|
||||||
|
// _isLoading = false;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
Navigator.pop(context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Carton carton = Carton();
|
isDataChanged() {
|
||||||
carton.id = _carton.id;
|
|
||||||
carton.cartonType = _selectedCartonType;
|
|
||||||
carton.fcsShipmentID = _isNew ? _fcsShipment.id : _carton.fcsShipmentID;
|
|
||||||
carton.userID = _user?.id;
|
|
||||||
carton.cargoTypes = _carton.cargoTypes;
|
|
||||||
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
|
||||||
carton.mixCartonID = _mixCarton?.id;
|
|
||||||
carton.length = l;
|
|
||||||
carton.width = w;
|
|
||||||
carton.height = h;
|
|
||||||
carton.deliveryAddress = _deliveryAddress;
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
CartonModel cartonModel =
|
|
||||||
Provider.of<CartonModel>(context, listen: false);
|
|
||||||
if (_isNew) {
|
if (_isNew) {
|
||||||
await cartonModel.createCarton(carton);
|
return false;
|
||||||
|
// return _fcsShipment != null || _user != null;
|
||||||
} else {
|
} else {
|
||||||
await cartonModel.updateCarton(carton);
|
return false;
|
||||||
}
|
|
||||||
Navigator.pop(context, true);
|
|
||||||
} catch (e) {
|
|
||||||
showMsgDialog(context, "Error", e.toString());
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
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/carton.dart';
|
import 'package:fcs/domain/entities/carton.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';
|
||||||
@@ -20,9 +21,10 @@ import 'package:flutter_icons/flutter_icons.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'carton_cargo_table.dart';
|
import 'cargo_table.dart';
|
||||||
import 'carton_editor.dart';
|
import 'carton_editor.dart';
|
||||||
import 'carton_package_table.dart';
|
import 'carton_package_table.dart';
|
||||||
|
import 'carton_row.dart';
|
||||||
import 'model/carton_model.dart';
|
import 'model/carton_model.dart';
|
||||||
import 'widgets.dart';
|
import 'widgets.dart';
|
||||||
|
|
||||||
@@ -43,8 +45,11 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
TextEditingController _widthController = new TextEditingController();
|
TextEditingController _widthController = new TextEditingController();
|
||||||
TextEditingController _heightController = new TextEditingController();
|
TextEditingController _heightController = new TextEditingController();
|
||||||
TextEditingController _lengthController = new TextEditingController();
|
TextEditingController _lengthController = new TextEditingController();
|
||||||
|
TextEditingController _cartonSizeController = new TextEditingController();
|
||||||
double volumetricRatio = 0;
|
double volumetricRatio = 0;
|
||||||
double shipmentWeight = 0;
|
double shipmentWeight = 0;
|
||||||
|
String selectMixBoxType;
|
||||||
|
List<Carton> _cartons = [];
|
||||||
|
|
||||||
bool isMixBox;
|
bool isMixBox;
|
||||||
bool isFromShipments;
|
bool isFromShipments;
|
||||||
@@ -73,6 +78,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
_widthController.text = _box.width.toString();
|
_widthController.text = _box.width.toString();
|
||||||
_heightController.text = _box.height.toString();
|
_heightController.text = _box.height.toString();
|
||||||
_lengthController.text = _box.length.toString();
|
_lengthController.text = _box.length.toString();
|
||||||
|
_cartonSizeController.text = _box.cartonSizeName ?? "";
|
||||||
_deliveryAddress = _box.deliveryAddress;
|
_deliveryAddress = _box.deliveryAddress;
|
||||||
isMixBox = _box.cartonType == carton_mix_box;
|
isMixBox = _box.cartonType == carton_mix_box;
|
||||||
isFromShipments = _box.cartonType == carton_from_shipments;
|
isFromShipments = _box.cartonType == carton_from_shipments;
|
||||||
@@ -81,6 +87,17 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
isEdiable = !isMixBox &&
|
isEdiable = !isMixBox &&
|
||||||
(isFromPackages || isSmallBag) &&
|
(isFromPackages || isSmallBag) &&
|
||||||
_box.status == carton_packed_status;
|
_box.status == carton_packed_status;
|
||||||
|
selectMixBoxType = _box.mixBoxType ?? "Mix Delivery";
|
||||||
|
_cartons = [
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#1",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#2",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadPackages() async {
|
_loadPackages() async {
|
||||||
@@ -176,10 +193,10 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final shipmentWeightBox = DisplayText(
|
final cartonSizeBox = DisplayText(
|
||||||
text: shipmentWeight != null ? shipmentWeight.toStringAsFixed(2) : "",
|
text: _cartonSizeController.text,
|
||||||
labelTextKey: "box.shipment_weight",
|
labelTextKey: "box.carton_size",
|
||||||
iconData: MaterialCommunityIcons.weight,
|
iconData: AntDesign.CodeSandbox,
|
||||||
);
|
);
|
||||||
final cargoTableBox = CargoTable(
|
final cargoTableBox = CargoTable(
|
||||||
cargoTypes: _box.cargoTypes,
|
cargoTypes: _box.cargoTypes,
|
||||||
@@ -190,6 +207,36 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
iconData: MaterialCommunityIcons.package,
|
iconData: MaterialCommunityIcons.package,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final mixTypeBox = Container(
|
||||||
|
padding: EdgeInsets.only(top: 20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 5),
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"box.mix_type",
|
||||||
|
color: primaryColor,
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
)),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(selectMixBoxType)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -222,7 +269,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: ListView(children: <Widget>[
|
child: ListView(shrinkWrap: true, children: <Widget>[
|
||||||
Center(child: getCartonNumberStatus(context, _box)),
|
Center(child: getCartonNumberStatus(context, _box)),
|
||||||
LocalTitle(textKey: "box.type.title"),
|
LocalTitle(textKey: "box.type.title"),
|
||||||
cartonTypeBox,
|
cartonTypeBox,
|
||||||
@@ -231,6 +278,15 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
isSmallBag ? mixCartonNumberBox : Container(),
|
isSmallBag ? mixCartonNumberBox : Container(),
|
||||||
isMixBox ? Container() : fcsIDBox,
|
isMixBox ? Container() : fcsIDBox,
|
||||||
isMixBox ? Container() : customerNameBox,
|
isMixBox ? Container() : customerNameBox,
|
||||||
|
isMixBox ? mixTypeBox : Container(),
|
||||||
|
isMixBox ? LocalTitle(textKey: "boxes.title") : Container(),
|
||||||
|
isMixBox
|
||||||
|
? Column(
|
||||||
|
children: _getCartons(
|
||||||
|
context,
|
||||||
|
this._cartons,
|
||||||
|
))
|
||||||
|
: Container(),
|
||||||
isFromPackages || isSmallBag
|
isFromPackages || isSmallBag
|
||||||
? CartonPackageTable(
|
? CartonPackageTable(
|
||||||
packages: _box.packages,
|
packages: _box.packages,
|
||||||
@@ -241,8 +297,8 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
...(isFromPackages
|
...(isFromPackages
|
||||||
? [
|
? [
|
||||||
LocalTitle(textKey: "box.dimension"),
|
LocalTitle(textKey: "box.dimension"),
|
||||||
|
cartonSizeBox,
|
||||||
dimBox,
|
dimBox,
|
||||||
shipmentWeightBox,
|
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
isMixBox
|
isMixBox
|
||||||
@@ -263,6 +319,12 @@ class _CartonInfoState extends State<CartonInfo> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Widget> _getCartons(BuildContext context, List<Carton> cartons) {
|
||||||
|
return cartons.map((c) {
|
||||||
|
return CartonRow(box: c);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
_gotoEditor() async {
|
_gotoEditor() async {
|
||||||
bool updated = await Navigator.push<bool>(
|
bool updated = await Navigator.push<bool>(
|
||||||
context,
|
context,
|
||||||
|
|||||||
100
lib/pages/carton/carton_row.dart
Normal file
100
lib/pages/carton/carton_row.dart
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
typedef OnRemove(Carton carton);
|
||||||
|
|
||||||
|
class CartonRow extends StatelessWidget {
|
||||||
|
final Carton box;
|
||||||
|
final OnRemove onRemove;
|
||||||
|
CartonRow({Key key, this.box, this.onRemove}) : super(key: key);
|
||||||
|
|
||||||
|
final double dotSize = 15.0;
|
||||||
|
final DateFormat dateFormat = new DateFormat("dd MMM yyyy");
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: Colors.grey[300]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: new Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 13.0),
|
||||||
|
child: new Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 5, right: 10),
|
||||||
|
child: Icon(
|
||||||
|
MaterialCommunityIcons.package,
|
||||||
|
color: primaryColor,
|
||||||
|
size: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
new Expanded(
|
||||||
|
child: new Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
box.cartonNumber ?? "",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0, color: Colors.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||||
|
child: new Text(
|
||||||
|
box.userName ?? "",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
onRemove == null
|
||||||
|
? Container()
|
||||||
|
: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.remove_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (onRemove != null) onRemove(box);
|
||||||
|
}),
|
||||||
|
box.actualWeight == 0
|
||||||
|
? Container()
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0, bottom: 5),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
new Text(
|
||||||
|
"${box.actualWeight?.toStringAsFixed(2) ?? ''} lb",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
lib/pages/carton/input_text_border.dart
Normal file
30
lib/pages/carton/input_text_border.dart
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
typedef OnAdd(String value);
|
||||||
|
|
||||||
|
class InputTextBorder extends StatelessWidget {
|
||||||
|
final OnAdd onAdd;
|
||||||
|
final TextEditingController controller;
|
||||||
|
|
||||||
|
const InputTextBorder({Key key, this.onAdd, this.controller})
|
||||||
|
: super(key: key);
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TextFormField(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
controller: controller,
|
||||||
|
onChanged: (v) {
|
||||||
|
if (onAdd != null) onAdd(v);
|
||||||
|
},
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: new InputDecoration(
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.grey),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
128
lib/pages/carton/mix_carton_editor.dart
Normal file
128
lib/pages/carton/mix_carton_editor.dart
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/carton_search/carton_search.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_button.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'carton_row.dart';
|
||||||
|
|
||||||
|
class MixCartonEditor extends StatefulWidget {
|
||||||
|
final Carton box;
|
||||||
|
MixCartonEditor({this.box});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_MixCartonEditorState createState() => _MixCartonEditorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MixCartonEditorState extends State<MixCartonEditor> {
|
||||||
|
Carton _box;
|
||||||
|
bool _isLoading = false;
|
||||||
|
bool _isNew;
|
||||||
|
List<Carton> _cartons = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
if (widget.box != null) {
|
||||||
|
_box = widget.box;
|
||||||
|
_isNew = false;
|
||||||
|
} else {
|
||||||
|
_isNew = true;
|
||||||
|
_box = Carton(cargoTypes: []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final createBtn = LocalButton(
|
||||||
|
textKey: "box.mix_carton_btn",
|
||||||
|
callBack: _creatCarton,
|
||||||
|
);
|
||||||
|
|
||||||
|
final cargoTableTitleBox = LocalTitle(
|
||||||
|
textKey: "boxes.title",
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.add_circle,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () => searchCarton(context, callbackCartonSelect: (c) {
|
||||||
|
_addMixCarton(c);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
leading: new IconButton(
|
||||||
|
icon: new Icon(
|
||||||
|
CupertinoIcons.back,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
"box.min_caton.form.title",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
cargoTableTitleBox,
|
||||||
|
Column(
|
||||||
|
children: _getCartons(
|
||||||
|
context,
|
||||||
|
this._cartons,
|
||||||
|
)),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
createBtn
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _getCartons(BuildContext context, List<Carton> cartons) {
|
||||||
|
return cartons.map((c) {
|
||||||
|
return CartonRow(
|
||||||
|
key: ValueKey(c.id),
|
||||||
|
box: c,
|
||||||
|
onRemove: (carton) {
|
||||||
|
_removeMixCarton(carton);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
_addMixCarton(Carton carton) {
|
||||||
|
if (carton == null) return;
|
||||||
|
if (this._cartons.any((c) => c.cartonNumber == carton.cartonNumber)) return;
|
||||||
|
setState(() {
|
||||||
|
this._cartons.add(carton);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeMixCarton(Carton carton) {
|
||||||
|
setState(() {
|
||||||
|
this._cartons.remove(carton);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_creatCarton() {}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:fcs/data/services/services.dart';
|
import 'package:fcs/data/services/services.dart';
|
||||||
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/carton.dart';
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
import 'package:fcs/domain/vo/message.dart';
|
import 'package:fcs/domain/vo/message.dart';
|
||||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||||
@@ -55,11 +56,8 @@ class CartonModel extends BaseModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> cartonTypes = [
|
List<String> cartonTypes = [carton_from_packages, carton_mix_box];
|
||||||
carton_from_packages,
|
List<String> mixTypes = [mix_delivery, mix_pickup];
|
||||||
carton_mix_box,
|
|
||||||
carton_small_bag
|
|
||||||
];
|
|
||||||
List<String> cartonTypesInfo = [
|
List<String> cartonTypesInfo = [
|
||||||
carton_from_packages,
|
carton_from_packages,
|
||||||
carton_mix_box,
|
carton_mix_box,
|
||||||
@@ -220,4 +218,40 @@ class CartonModel extends BaseModel {
|
|||||||
Future<void> deleteCarton(Carton carton) {
|
Future<void> deleteCarton(Carton carton) {
|
||||||
return Services.instance.cartonService.deleteCarton(carton);
|
return Services.instance.cartonService.deleteCarton(carton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Carton>> searchCarton(String term) async {
|
||||||
|
if (term == null || term == '') return List();
|
||||||
|
|
||||||
|
List<Carton> _cartons = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
_cartons = [
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#1",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#2",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#3",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#4",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
Carton(
|
||||||
|
cartonNumber: "A100B-1#5",
|
||||||
|
cargoTypes: [CargoType(name: "General", weight: 12)],
|
||||||
|
userName: "Seven 7"),
|
||||||
|
];
|
||||||
|
} catch (e) {
|
||||||
|
// permission error
|
||||||
|
log.warning("user error:" + e.toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _cartons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
324
lib/pages/carton/package_carton_editor.dart
Normal file
324
lib/pages/carton/package_carton_editor.dart
Normal file
@@ -0,0 +1,324 @@
|
|||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/domain/entities/cargo_type.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/carton_size_list.dart';
|
||||||
|
import 'package:fcs/pages/carton_size/model/carton_size_model.dart';
|
||||||
|
import 'package:fcs/pages/delivery_address/model/delivery_address_model.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/rates/model/shipment_rate_model.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/length_picker.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_button.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
|
import 'package:fcs/pages/widgets/local_title.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
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 'model/carton_model.dart';
|
||||||
|
|
||||||
|
class PackageCartonEditor extends StatefulWidget {
|
||||||
|
final Carton carton;
|
||||||
|
final bool isNew;
|
||||||
|
PackageCartonEditor({this.carton, this.isNew});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PackageCartonEditorState createState() => _PackageCartonEditorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||||
|
TextEditingController _lengthCtl = new TextEditingController();
|
||||||
|
TextEditingController _widthCtl = new TextEditingController();
|
||||||
|
TextEditingController _heightCtl = new TextEditingController();
|
||||||
|
|
||||||
|
Carton _carton;
|
||||||
|
bool _isLoading = false;
|
||||||
|
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||||
|
|
||||||
|
List<CargoType> _cargoTypes = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
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();
|
||||||
|
_heightCtl.text = _carton.height.toString();
|
||||||
|
_deliveryAddress = _carton.deliveryAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final lengthBox = LengthPicker(
|
||||||
|
controller: _lengthCtl,
|
||||||
|
lableKey: "box.length",
|
||||||
|
isReadOnly: true,
|
||||||
|
);
|
||||||
|
final widthBox = LengthPicker(
|
||||||
|
controller: _widthCtl,
|
||||||
|
lableKey: "box.width",
|
||||||
|
isReadOnly: true,
|
||||||
|
);
|
||||||
|
final heightBox = LengthPicker(
|
||||||
|
controller: _heightCtl,
|
||||||
|
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),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final createBtn = LocalButton(
|
||||||
|
textKey: "box.new_carton_btn",
|
||||||
|
callBack: _creatCarton,
|
||||||
|
);
|
||||||
|
|
||||||
|
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(() {
|
||||||
|
_cargoTypes.clear();
|
||||||
|
_cargoTypes.addAll(cargos);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
final cargoTableBox = CargoTable(
|
||||||
|
isNew: widget.isNew,
|
||||||
|
cargoTypes: _cargoTypes,
|
||||||
|
onAdd: (c) => _addCargo(c),
|
||||||
|
onRemove: (c) => _removeCargo(c),
|
||||||
|
);
|
||||||
|
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
leading: new IconButton(
|
||||||
|
icon: new Icon(
|
||||||
|
CupertinoIcons.back,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
widget.isNew ? "boxes.create.title" : "box.edit.title",
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
cargoTableTitleBox,
|
||||||
|
cargoTableBox,
|
||||||
|
LocalTitle(textKey: "box.dimension"),
|
||||||
|
cartonSizeDropdown(),
|
||||||
|
dimBox,
|
||||||
|
LocalTitle(textKey: "box.delivery_address"),
|
||||||
|
DefaultDeliveryAddress(
|
||||||
|
deliveryAddress: _deliveryAddress,
|
||||||
|
labelKey: "box.delivery_address",
|
||||||
|
onTap: () async {
|
||||||
|
DeliveryAddress d = await Navigator.push<DeliveryAddress>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => DeliveryAddressSelection(
|
||||||
|
deliveryAddress: _deliveryAddress,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
if (d == null) return;
|
||||||
|
setState(() {
|
||||||
|
_deliveryAddress = d;
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
createBtn
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
CartonSize selectedCatonSize;
|
||||||
|
Widget cartonSizeDropdown() {
|
||||||
|
List<CartonSize> _cartonSizes =
|
||||||
|
Provider.of<CartonSizeModel>(context).getCartonSizes;
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 0, right: 10),
|
||||||
|
child: Icon(AntDesign.CodeSandbox, color: primaryColor),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 18.0),
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
"box.carton_size",
|
||||||
|
color: Colors.black54,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DropdownButton<CartonSize>(
|
||||||
|
isDense: true,
|
||||||
|
value: selectedCatonSize,
|
||||||
|
style: TextStyle(color: Colors.black, fontSize: 14),
|
||||||
|
underline: Container(
|
||||||
|
height: 1,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
onChanged: (CartonSize newValue) {
|
||||||
|
setState(() {
|
||||||
|
if (newValue.name == MANAGE_CARTONSIZE) {
|
||||||
|
selectedCatonSize = null;
|
||||||
|
_manageCartonSize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectedCatonSize = newValue;
|
||||||
|
_widthCtl.text = selectedCatonSize.width.toString();
|
||||||
|
_heightCtl.text = selectedCatonSize.height.toString();
|
||||||
|
_lengthCtl.text = selectedCatonSize.length.toString();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isExpanded: true,
|
||||||
|
items: _cartonSizes
|
||||||
|
.map<DropdownMenuItem<CartonSize>>((CartonSize value) {
|
||||||
|
return DropdownMenuItem<CartonSize>(
|
||||||
|
value: value,
|
||||||
|
child: Text(value.name ?? "",
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: value.name == MANAGE_CARTONSIZE
|
||||||
|
? secondaryColor
|
||||||
|
: primaryColor)),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_manageCartonSize() {
|
||||||
|
Navigator.push<Package>(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(builder: (context) => CartonSizeList()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_addCargo(CargoType cargo) {
|
||||||
|
if (cargo == null) return;
|
||||||
|
setState(() {
|
||||||
|
_cargoTypes.remove(cargo);
|
||||||
|
_cargoTypes.add(cargo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeCargo(CargoType cargo) {
|
||||||
|
setState(() {
|
||||||
|
_cargoTypes.remove(cargo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_creatCarton() async {
|
||||||
|
if ((_cargoTypes?.length ?? 0) == 0) {
|
||||||
|
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double l = double.parse(_lengthCtl.text, (s) => 0);
|
||||||
|
double w = double.parse(_widthCtl.text, (s) => 0);
|
||||||
|
double h = double.parse(_heightCtl.text, (s) => 0);
|
||||||
|
if ((l <= 0 || w <= 0 || h <= 0)) {
|
||||||
|
showMsgDialog(context, "Error", "Invalid dimension");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_deliveryAddress == null) {
|
||||||
|
showMsgDialog(context, "Error", "Invalid delivery address");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Carton carton = Carton();
|
||||||
|
carton.id = _carton.id;
|
||||||
|
carton.cartonType = _carton.cartonType;
|
||||||
|
carton.fcsShipmentID = _carton.fcsShipmentID;
|
||||||
|
carton.userID = _carton.userID;
|
||||||
|
carton.cargoTypes = _cargoTypes;
|
||||||
|
carton.packages = _carton.packages.where((e) => e.isChecked).toList();
|
||||||
|
// carton.cartonSizeID = selectedCatonSize?.id;
|
||||||
|
carton.length = l;
|
||||||
|
carton.width = w;
|
||||||
|
carton.height = h;
|
||||||
|
carton.deliveryAddress = _deliveryAddress;
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
CartonModel cartonModel =
|
||||||
|
Provider.of<CartonModel>(context, listen: false);
|
||||||
|
if (widget.isNew) {
|
||||||
|
await cartonModel.createCarton(carton);
|
||||||
|
} else {
|
||||||
|
await cartonModel.updateCarton(carton);
|
||||||
|
}
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
101
lib/pages/carton_search/carton_list_row.dart
Normal file
101
lib/pages/carton_search/carton_list_row.dart
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
|
||||||
|
import 'carton_search.dart';
|
||||||
|
|
||||||
|
class CartonListRow extends StatefulWidget {
|
||||||
|
final CallbackCartonSelect callbackCartonSelect;
|
||||||
|
final Carton carton;
|
||||||
|
const CartonListRow({this.carton, this.callbackCartonSelect});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CartonListRowState createState() => _CartonListRowState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CartonListRowState extends State<CartonListRow> {
|
||||||
|
final double dotSize = 15.0;
|
||||||
|
Carton _carton;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
this._carton = widget.carton;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: Colors.grey[300]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
if (widget.callbackCartonSelect != null)
|
||||||
|
widget.callbackCartonSelect(widget.carton);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: new Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 13.0),
|
||||||
|
child: new Row(
|
||||||
|
children: <Widget>[
|
||||||
|
new Padding(
|
||||||
|
padding: new EdgeInsets.symmetric(
|
||||||
|
horizontal: 25.0 - dotSize / 2),
|
||||||
|
child: Icon(
|
||||||
|
MaterialCommunityIcons.package,
|
||||||
|
color: primaryColor,
|
||||||
|
size: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
new Expanded(
|
||||||
|
child: new Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: new Text(
|
||||||
|
_carton.cartonNumber ?? "",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0, color: Colors.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||||
|
child: new Text(
|
||||||
|
_carton.userName ?? "",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0, bottom: 5, right: 10),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
new Text(
|
||||||
|
"${_carton.actualWeight?.toStringAsFixed(2) ?? ''} lb",
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 15.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
122
lib/pages/carton_search/carton_search.dart
Normal file
122
lib/pages/carton_search/carton_search.dart
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/carton/model/carton_model.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'carton_list_row.dart';
|
||||||
|
|
||||||
|
typedef CallbackCartonSelect(Carton carton);
|
||||||
|
|
||||||
|
Future<Carton> searchCarton(BuildContext context,
|
||||||
|
{CallbackCartonSelect callbackCartonSelect}) async =>
|
||||||
|
await showSearch<Carton>(
|
||||||
|
context: context,
|
||||||
|
delegate: PartSearchDelegate(callbackCartonSelect: callbackCartonSelect),
|
||||||
|
);
|
||||||
|
|
||||||
|
class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||||
|
final CallbackCartonSelect callbackCartonSelect;
|
||||||
|
PartSearchDelegate({this.callbackCartonSelect});
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get searchFieldLabel => 'Search by Carton Number/Customer Name';
|
||||||
|
|
||||||
|
@override
|
||||||
|
ThemeData appBarTheme(BuildContext context) {
|
||||||
|
final ThemeData theme = Theme.of(context);
|
||||||
|
return theme.copyWith(
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
||||||
|
textTheme: theme.textTheme.copyWith(
|
||||||
|
title: theme.textTheme.title.copyWith(
|
||||||
|
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
||||||
|
primaryColor: primaryColor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Widget> buildActions(BuildContext context) {
|
||||||
|
return [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.clear),
|
||||||
|
onPressed: () => query = '',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget buildLeading(BuildContext context) {
|
||||||
|
return IconButton(
|
||||||
|
icon: Icon(Icons.arrow_back),
|
||||||
|
onPressed: () => close(context, null),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget buildResults(BuildContext context) {
|
||||||
|
final cartonModel = Provider.of<CartonModel>(context);
|
||||||
|
return FutureBuilder(
|
||||||
|
future: cartonModel.searchCarton(query),
|
||||||
|
builder: (context, AsyncSnapshot<List<Carton>> snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
if (snapshot.data.length == 0) {
|
||||||
|
return Container(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"No result found",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(top: 15),
|
||||||
|
child: ListView(
|
||||||
|
children: snapshot.data
|
||||||
|
.map((u) => CartonListRow(
|
||||||
|
carton: u,
|
||||||
|
callbackCartonSelect: callbackCartonSelect,
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
return Container(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'${snapshot.error}',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
valueColor:
|
||||||
|
new AlwaysStoppedAnimation<Color>(primaryColor)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget buildSuggestions(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
child: Center(
|
||||||
|
child: Opacity(
|
||||||
|
opacity: 0.2,
|
||||||
|
child: Icon(
|
||||||
|
MaterialCommunityIcons.package,
|
||||||
|
color: primaryColor,
|
||||||
|
size: 200,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
|
||||||
import 'package:fcs/domain/entities/carton_size.dart';
|
import 'package:fcs/domain/entities/carton_size.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
|
||||||
import 'package:fcs/pages/widgets/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
import 'package:fcs/pages/widgets/progress.dart';
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -139,7 +136,15 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon:
|
icon:
|
||||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
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,
|
||||||
@@ -165,4 +170,21 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _nameController.text != "" ||
|
||||||
|
_lengthController.text != "12" ||
|
||||||
|
_widthController.text != "12" ||
|
||||||
|
_heightController.text != "12";
|
||||||
|
} else {
|
||||||
|
double l = double.parse(_lengthController.text, (s) => 0);
|
||||||
|
double w = double.parse(_widthController.text, (s) => 0);
|
||||||
|
double h = double.parse(_heightController.text, (s) => 0);
|
||||||
|
CartonSize _cartonSize = CartonSize(
|
||||||
|
name: _nameController.text, length: l, width: w, height: h);
|
||||||
|
|
||||||
|
return widget.cartonSize.isChangedForEdit(_cartonSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class _CartonSizeListState extends State<CartonSizeList> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Spacer(),
|
//Spacer(),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.remove, color: primaryColor),
|
icon: Icon(Icons.remove, color: primaryColor),
|
||||||
onPressed: () => _remove(p),
|
onPressed: () => _remove(p),
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:fcs/domain/constants.dart';
|
||||||
import 'package:fcs/domain/entities/carton_size.dart';
|
import 'package:fcs/domain/entities/carton_size.dart';
|
||||||
|
import 'package:fcs/helpers/firebase_helper.dart';
|
||||||
import 'package:fcs/pages/main/model/base_model.dart';
|
import 'package:fcs/pages/main/model/base_model.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
@@ -20,26 +22,49 @@ class CartonSizeModel extends BaseModel {
|
|||||||
|
|
||||||
void initUser(user) {
|
void initUser(user) {
|
||||||
super.initUser(user);
|
super.initUser(user);
|
||||||
cartonSizes = [
|
_loadCartonSizes();
|
||||||
CartonSize(
|
}
|
||||||
id: "1", name: "FCS Small Box", length: 16, width: 12, height: 12),
|
|
||||||
CartonSize(
|
Future<void> _loadCartonSizes() async {
|
||||||
id: "2", name: "FCS Medium Box", length: 22, width: 16, height: 15),
|
try {
|
||||||
CartonSize(
|
if (listener != null) listener.cancel();
|
||||||
id: "3", name: "FCS Large Box", length: 28, width: 15, height: 16)
|
|
||||||
];
|
listener = Firestore.instance
|
||||||
|
.collection(
|
||||||
|
"/$config_collection/$setting_doc_id/$carton_sizes_collection")
|
||||||
|
.snapshots()
|
||||||
|
.listen((QuerySnapshot snapshot) {
|
||||||
|
cartonSizes.clear();
|
||||||
|
cartonSizes = snapshot.documents.map((documentSnapshot) {
|
||||||
|
var c = CartonSize.fromMap(
|
||||||
|
documentSnapshot.data, documentSnapshot.documentID);
|
||||||
|
return c;
|
||||||
|
}).toList();
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
log.warning("Error!! $e");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
logout() async {
|
logout() async {
|
||||||
if (listener != null) await listener.cancel();
|
if (listener != null) await listener.cancel();
|
||||||
|
|
||||||
cartonSizes = [];
|
cartonSizes = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addCartonSize(CartonSize cartonSize) async {}
|
Future<void> addCartonSize(CartonSize cartonSize) async {
|
||||||
|
await request("/carton_sizes", "POST",
|
||||||
Future<void> updateCartonSize(CartonSize cartonSize) async {}
|
payload: cartonSize.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
Future<void> deleteCartonSize(String id) async {}
|
|
||||||
|
Future<void> updateCartonSize(CartonSize cartonSize) async {
|
||||||
|
await request("/carton_sizes", "PUT",
|
||||||
|
payload: cartonSize.toMap(), token: await getToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteCartonSize(String id) async {
|
||||||
|
await request("/carton_sizes", "DELETE",
|
||||||
|
payload: {"id": id}, token: await getToken());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,17 +29,21 @@ class _ContactEditorState extends State<ContactEditor> {
|
|||||||
TextEditingController _facebook = new TextEditingController();
|
TextEditingController _facebook = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
bool isNew;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.contact != null) {
|
if (widget.contact != null) {
|
||||||
|
isNew = false;
|
||||||
_usaPhone.text = widget.contact.usaContactNumber;
|
_usaPhone.text = widget.contact.usaContactNumber;
|
||||||
_mmPhone.text = widget.contact.mmContactNumber;
|
_mmPhone.text = widget.contact.mmContactNumber;
|
||||||
_usaAddress.text = widget.contact.usaAddress;
|
_usaAddress.text = widget.contact.usaAddress;
|
||||||
_mmAddress.text = widget.contact.mmAddress;
|
_mmAddress.text = widget.contact.mmAddress;
|
||||||
_email.text = widget.contact.emailAddress;
|
_email.text = widget.contact.emailAddress;
|
||||||
_facebook.text = widget.contact.facebookLink;
|
_facebook.text = widget.contact.facebookLink;
|
||||||
|
} else {
|
||||||
|
isNew = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +86,9 @@ class _ContactEditorState extends State<ContactEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
),
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
|
|||||||
@@ -51,7 +51,15 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
CupertinoIcons.back,
|
CupertinoIcons.back,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
context,
|
context,
|
||||||
@@ -162,4 +170,10 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
String userName = _nameController.text;
|
||||||
|
String phoneNumber = _phoneController.text;
|
||||||
|
return userName != "" || phoneNumber != "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,9 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
|
|||||||
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: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
|||||||
@@ -106,7 +106,15 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
@@ -248,4 +256,18 @@ class _DeliveryAddressEditorState extends State<DeliveryAddressEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _nameController.text != "" ||
|
||||||
|
_phoneController.text != "" ||
|
||||||
|
_address1Controller.text != "" ||
|
||||||
|
_address2Controller.text != "" ||
|
||||||
|
_cityController.text != "Yangon" ||
|
||||||
|
_stateController.text != "Yangon";
|
||||||
|
} else {
|
||||||
|
DeliveryAddress deliveryAddress = _getPayload();
|
||||||
|
return widget.deliveryAddress.isChangedForEdit(deliveryAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
|||||||
if (widget.discount != null) {
|
if (widget.discount != null) {
|
||||||
_discount = widget.discount;
|
_discount = widget.discount;
|
||||||
_codeController.text = _discount.code;
|
_codeController.text = _discount.code;
|
||||||
_amountController.text = _discount.amount.toString();
|
_amountController.text = _discount.amount.toStringAsFixed(2);
|
||||||
_statusController.text = _discount.status;
|
_statusController.text = _discount.status;
|
||||||
customerName = widget.discount.customerName;
|
customerName = widget.discount.customerName;
|
||||||
customerId = widget.discount.customerId;
|
customerId = widget.discount.customerId;
|
||||||
@@ -97,7 +97,15 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
|||||||
),
|
),
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -188,4 +196,19 @@ class _DiscountEditorState extends State<DiscountEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _codeController.text != "" ||
|
||||||
|
_amountController.text != "" ||
|
||||||
|
customerName != "";
|
||||||
|
} else {
|
||||||
|
Discount _discount = Discount(
|
||||||
|
code: _codeController.text,
|
||||||
|
customerName: customerName,
|
||||||
|
customerId: customerId,
|
||||||
|
amount: double.parse(_amountController.text));
|
||||||
|
return widget.discount.isChangedForEdit(_discount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class DiscountListRow extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Text(
|
new Text(
|
||||||
"${discount.amount ?? ''}",
|
"${discount.amount.toStringAsFixed(2) ?? ''}",
|
||||||
style:
|
style:
|
||||||
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
new TextStyle(fontSize: 15.0, color: Colors.grey),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -126,7 +126,15 @@ class _FAQEditorState extends State<FAQEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
@@ -236,4 +244,15 @@ class _FAQEditorState extends State<FAQEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
return _sn.text != "" ||
|
||||||
|
_engQ.text != "" ||
|
||||||
|
_engA.text != "" ||
|
||||||
|
_mmQ.text != "" ||
|
||||||
|
_mmA.text != "" ||
|
||||||
|
_pageLabelEng.text != "" ||
|
||||||
|
_pageLabelMm.text != "" ||
|
||||||
|
_pageLink != info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,15 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
@@ -267,4 +275,20 @@ class _FcsShipmentEditorState extends State<FcsShipmentEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
var mainModel = Provider.of<MainModel>(context, listen: false);
|
||||||
|
return _shipmentNumberController.text != "" ||
|
||||||
|
_cutoffDateController.text != "" ||
|
||||||
|
_arrivalDateController.text != "" ||
|
||||||
|
_consigneeController.text != "" ||
|
||||||
|
_portController.text != "" ||
|
||||||
|
_destinationController.text != "" ||
|
||||||
|
_currentShipmentType != mainModel.setting.shipmentTypes[0];
|
||||||
|
} else {
|
||||||
|
FcsShipment fcsShipment = _getPayload();
|
||||||
|
return widget.shipment.isChangedForEdit(fcsShipment);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,7 +315,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
|
|||||||
@@ -91,7 +91,11 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
|||||||
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: () {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
|||||||
@@ -48,7 +48,10 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
initPackage(widget.package);
|
initPackage(widget.package);
|
||||||
}
|
}
|
||||||
|
|
||||||
initPackage(Package package) {
|
initPackage(Package pkg) async {
|
||||||
|
PackageModel packageModel =
|
||||||
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
|
Package package = await packageModel.getPackageByTrackingID(pkg.trackingID);
|
||||||
setState(() {
|
setState(() {
|
||||||
_package = package;
|
_package = package;
|
||||||
multiImgController.setImageUrls = package.photoUrls;
|
multiImgController.setImageUrls = package.photoUrls;
|
||||||
@@ -63,38 +66,38 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String id = Provider.of<MainModel>(context).user.id;
|
String id = Provider.of<MainModel>(context).user.id;
|
||||||
bool owner = _package.userID == id;
|
bool owner = _package?.userID == id;
|
||||||
bool canChangeDeliveryAddress =
|
bool canChangeDeliveryAddress =
|
||||||
_package.status == package_received_status ||
|
_package?.status == package_received_status ||
|
||||||
_package.status == package_processed_status;
|
_package?.status == package_processed_status;
|
||||||
|
|
||||||
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,
|
||||||
);
|
);
|
||||||
final marketBox = DisplayText(
|
final marketBox = DisplayText(
|
||||||
text: _package.market ?? "-",
|
text: _package?.market ?? "-",
|
||||||
labelTextKey: "package.create.market",
|
labelTextKey: "package.create.market",
|
||||||
iconData: Icons.store,
|
iconData: Icons.store,
|
||||||
);
|
);
|
||||||
final descBox = DisplayText(
|
final descBox = DisplayText(
|
||||||
text: _package.desc ?? "-",
|
text: _package?.desc ?? "-",
|
||||||
labelTextKey: "package.edit.desc",
|
labelTextKey: "package.edit.desc",
|
||||||
iconData: MaterialCommunityIcons.message_text_outline,
|
iconData: MaterialCommunityIcons.message_text_outline,
|
||||||
);
|
);
|
||||||
final remarkBox = DisplayText(
|
final remarkBox = DisplayText(
|
||||||
text: _package.remark ?? "-",
|
text: _package?.remark ?? "-",
|
||||||
labelTextKey: "package.edit.remark",
|
labelTextKey: "package.edit.remark",
|
||||||
iconData: Entypo.new_message,
|
iconData: Entypo.new_message,
|
||||||
);
|
);
|
||||||
@@ -109,7 +112,7 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
callBack: _return,
|
callBack: _return,
|
||||||
);
|
);
|
||||||
final deliveryAddressBox = DefaultDeliveryAddress(
|
final deliveryAddressBox = DefaultDeliveryAddress(
|
||||||
deliveryAddress: _package.deliveryAddress,
|
deliveryAddress: _package?.deliveryAddress,
|
||||||
labelKey: "package.delivery.address",
|
labelKey: "package.delivery.address",
|
||||||
onTap: owner && canChangeDeliveryAddress
|
onTap: owner && canChangeDeliveryAddress
|
||||||
? () async {
|
? () async {
|
||||||
@@ -155,10 +158,10 @@ 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.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 &&
|
||||||
widget.isCustomer
|
widget.isCustomer
|
||||||
? returnButton
|
? returnButton
|
||||||
: Container(),
|
: Container(),
|
||||||
@@ -166,8 +169,8 @@ class _PackageInfoState extends State<PackageInfo> {
|
|||||||
widget.isSearchResult
|
widget.isSearchResult
|
||||||
? Container()
|
? Container()
|
||||||
: StatusTree(
|
: StatusTree(
|
||||||
shipmentHistory: _package.shipmentHistory,
|
shipmentHistory: _package?.shipmentHistory,
|
||||||
currentStatus: _package.status),
|
currentStatus: _package?.status),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -60,7 +60,15 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
context,
|
context,
|
||||||
@@ -210,4 +218,13 @@ class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
return _nameController.text != "" ||
|
||||||
|
_accountNameController.text != "" ||
|
||||||
|
_accountNumberController.text != "" ||
|
||||||
|
_phoneController.text != "" ||
|
||||||
|
_mailController.text != "" ||
|
||||||
|
_linkController.text != "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import 'package:fcs/domain/entities/market.dart';
|
import 'package:fcs/domain/entities/market.dart';
|
||||||
import 'package:fcs/domain/entities/package.dart';
|
import 'package:fcs/domain/entities/package.dart';
|
||||||
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/market/market_editor.dart';
|
import 'package:fcs/pages/market/market_editor.dart';
|
||||||
import 'package:fcs/pages/market/model/market_model.dart';
|
import 'package:fcs/pages/market/model/market_model.dart';
|
||||||
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
import 'package:fcs/pages/package/tracking_id_page.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||||
@@ -19,7 +21,9 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
class PackageEditor extends StatefulWidget {
|
class PackageEditor extends StatefulWidget {
|
||||||
final Package package;
|
final Package package;
|
||||||
PackageEditor({this.package});
|
final User consignee;
|
||||||
|
final User sender;
|
||||||
|
PackageEditor({this.package, this.consignee, this.sender});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PackageEditorState createState() => _PackageEditorState();
|
_PackageEditorState createState() => _PackageEditorState();
|
||||||
@@ -260,17 +264,24 @@ class _PackageEditorState extends State<PackageEditor> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
|
PackageModel packageModel =
|
||||||
|
Provider.of<PackageModel>(context, listen: false);
|
||||||
try {
|
try {
|
||||||
this._package.trackingID = _trackingIDCtl.text;
|
Package package=await packageModel.getPackageByTrackingID(_trackingIDCtl.text);
|
||||||
this._package.market = selectedMarket;
|
package.trackingID = _trackingIDCtl.text;
|
||||||
this._package.desc = _descCtl.text;
|
package.market = selectedMarket;
|
||||||
this._package.remark = _remarkCtl.text;
|
package.desc = _descCtl.text;
|
||||||
this._package.photoFiles = _isNew
|
package.remark = _remarkCtl.text;
|
||||||
|
package.photoFiles = _isNew
|
||||||
? multiImgController.getAddedFile
|
? multiImgController.getAddedFile
|
||||||
: multiImgController.getUpdatedFile;
|
: multiImgController.getUpdatedFile;
|
||||||
|
package.fcsID=widget.consignee.fcsID;
|
||||||
|
package.senderFCSID=widget.sender?.fcsID;
|
||||||
|
|
||||||
Navigator.pop<Package>(context, this._package);
|
await packageModel.updateProcessing(package,
|
||||||
|
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||||
|
|
||||||
|
Navigator.pop<Package>(context, package);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMsgDialog(context, "Error", e.toString());
|
showMsgDialog(context, "Error", e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -117,7 +117,15 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
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,
|
||||||
@@ -257,4 +265,12 @@ class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
return _user.fcsID != "" ||
|
||||||
|
selectedMarket != "" ||
|
||||||
|
_descCtl.text != "" ||
|
||||||
|
_remarkCtl.text != "" ||
|
||||||
|
multiImgController.getAddedFile.isNotEmpty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:fcs/domain/entities/processing.dart';
|
|||||||
import 'package:fcs/domain/entities/user.dart';
|
import 'package:fcs/domain/entities/user.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
import 'package:fcs/pages/main/util.dart';
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/package/package_info.dart';
|
||||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
import 'package:fcs/pages/user_search/user_serach.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';
|
||||||
@@ -27,8 +28,8 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
Processing processing = Processing();
|
Processing processing = Processing();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isNew;
|
bool _isNew;
|
||||||
User user;
|
User consignee;
|
||||||
User shipper;
|
User sender;
|
||||||
List<Package> packages = [];
|
List<Package> packages = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -37,11 +38,11 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
_isNew = widget.processing == null;
|
_isNew = widget.processing == null;
|
||||||
if (!_isNew) {
|
if (!_isNew) {
|
||||||
processing = widget.processing;
|
processing = widget.processing;
|
||||||
user = User(
|
consignee = User(
|
||||||
fcsID: processing.userID,
|
fcsID: processing.userID,
|
||||||
name: processing.userName,
|
name: processing.userName,
|
||||||
phoneNumber: processing.userPhoneNumber);
|
phoneNumber: processing.userPhoneNumber);
|
||||||
shipper = User(
|
sender = User(
|
||||||
fcsID: processing.fcsID,
|
fcsID: processing.fcsID,
|
||||||
name: processing.shipperName,
|
name: processing.shipperName,
|
||||||
phoneNumber: processing.shipperPhoneNumber);
|
phoneNumber: processing.shipperPhoneNumber);
|
||||||
@@ -55,7 +56,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: user != null ? user.fcsID : "",
|
text: consignee != null ? consignee.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -63,21 +64,21 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
icon: Icon(Icons.search, color: primaryColor),
|
icon: Icon(Icons.search, color: primaryColor),
|
||||||
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
||||||
setState(() {
|
setState(() {
|
||||||
this.user = u;
|
this.consignee = u;
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final phoneNumberBox = DisplayText(
|
final phoneNumberBox = DisplayText(
|
||||||
text: user != null ? user.phoneNumber : "",
|
text: consignee != null ? consignee.phoneNumber : "",
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
|
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: user != null ? user.name : "",
|
text: consignee != null ? consignee.name : "",
|
||||||
labelTextKey: "processing.consignee.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -97,7 +98,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DisplayText(
|
child: DisplayText(
|
||||||
text: shipper != null ? shipper.fcsID : "",
|
text: sender != null ? sender.fcsID : "",
|
||||||
labelTextKey: "processing.fcs.id",
|
labelTextKey: "processing.fcs.id",
|
||||||
icon: FcsIDIcon(),
|
icon: FcsIDIcon(),
|
||||||
)),
|
)),
|
||||||
@@ -105,21 +106,21 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
icon: Icon(Icons.search, color: primaryColor),
|
icon: Icon(Icons.search, color: primaryColor),
|
||||||
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
||||||
setState(() {
|
setState(() {
|
||||||
this.shipper = u;
|
this.sender = u;
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final shipperPhoneNumberBox = DisplayText(
|
final shipperPhoneNumberBox = DisplayText(
|
||||||
text: shipper != null ? shipper.phoneNumber : "",
|
text: sender != null ? sender.phoneNumber : "",
|
||||||
labelTextKey: "processing.phone",
|
labelTextKey: "processing.phone",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.phone,
|
iconData: Icons.phone,
|
||||||
);
|
);
|
||||||
|
|
||||||
final shipperNamebox = DisplayText(
|
final shipperNamebox = DisplayText(
|
||||||
text: shipper != null ? shipper.name : "",
|
text: sender != null ? sender.name : "",
|
||||||
labelTextKey: "processing.shipper.name",
|
labelTextKey: "processing.shipper.name",
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
@@ -146,9 +147,17 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if (this.consignee == null) {
|
||||||
|
showMsgDialog(context, "Warning", "Please select 'Consignee'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Package _package = await Navigator.push<Package>(
|
Package _package = await Navigator.push<Package>(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => PackageEditor()),
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => PackageEditor(
|
||||||
|
sender: this.sender,
|
||||||
|
consignee: this.consignee,
|
||||||
|
)),
|
||||||
);
|
);
|
||||||
_addPackage(_package);
|
_addPackage(_package);
|
||||||
// _savePackage(_package);
|
// _savePackage(_package);
|
||||||
@@ -171,7 +180,15 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon:
|
icon:
|
||||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
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,
|
||||||
@@ -216,64 +233,17 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
|
|
||||||
List<Widget> _getPackages(BuildContext context, List<Package> packages) {
|
List<Widget> _getPackages(BuildContext context, List<Package> packages) {
|
||||||
return packages.map((p) {
|
return packages.map((p) {
|
||||||
return Container(
|
return InkWell(
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(color: Colors.grey[300]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Package _package = await Navigator.of(context).push<Package>(
|
Package _package = await Navigator.of(context).push<Package>(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => PackageEditor(package: p)));
|
builder: (context) => PackageInfo(package: p)));
|
||||||
// setState(() {
|
|
||||||
// _savePackage(_package);
|
|
||||||
// });
|
|
||||||
_savePackage(_package);
|
_savePackage(_package);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: DisplayText(
|
||||||
children: <Widget>[
|
labelTextKey: "processing.tracking.id",
|
||||||
Expanded(
|
iconData: MaterialCommunityIcons.barcode_scan,
|
||||||
child: new Padding(
|
text: p.trackingID,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
|
||||||
child: new Row(
|
|
||||||
children: <Widget>[
|
|
||||||
new Padding(
|
|
||||||
padding: new EdgeInsets.symmetric(
|
|
||||||
horizontal: 30.0 - 15.0 / 2),
|
|
||||||
child: Stack(
|
|
||||||
alignment: AlignmentDirectional.bottomEnd,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Octicons.package,
|
|
||||||
color: primaryColor,
|
|
||||||
size: 30,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
new Expanded(
|
|
||||||
child: new Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
new Text(
|
|
||||||
p.trackingID,
|
|
||||||
style: new TextStyle(fontSize: 15.0),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.remove, color: primaryColor),
|
|
||||||
onPressed: () => _removePackage(p),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
@@ -320,4 +290,16 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return this.packages.isNotEmpty || consignee != null || sender != null;
|
||||||
|
} else {
|
||||||
|
Processing _processing = Processing(
|
||||||
|
userID: consignee.fcsID,
|
||||||
|
fcsID: sender.fcsID,
|
||||||
|
packages: this.packages);
|
||||||
|
return widget.processing.isChangedForEdit(_processing);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ class _ProfileCurrencyEditState extends State<ProfileCurrencyEdit> {
|
|||||||
size: 35,
|
size: 35,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
|||||||
@@ -74,7 +74,9 @@ class _ProfileEditState extends State<ProfileEdit> {
|
|||||||
size: 35,
|
size: 35,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
if (widget.cargo != null) {
|
if (widget.cargo != null) {
|
||||||
_cargo = widget.cargo;
|
_cargo = widget.cargo;
|
||||||
_descController.text = _cargo.name;
|
_descController.text = _cargo.name;
|
||||||
_rateController.text = _cargo.rate.toString();
|
_rateController.text = _cargo.rate.toStringAsFixed(2);
|
||||||
} else {
|
} else {
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,15 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
title: Text(AppTranslations.of(context).text("cargo.form.title")),
|
title: Text(AppTranslations.of(context).text("cargo.form.title")),
|
||||||
@@ -140,4 +148,14 @@ class _CargoEditorState extends State<CargoEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _descController.text != "" || _rateController.text != "";
|
||||||
|
} else {
|
||||||
|
CargoType _cargo = CargoType(
|
||||||
|
name: _descController.text, rate: double.parse(_rateController.text));
|
||||||
|
return widget.cargo.isChangedForEdit(_cargo);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ class _CargoTypeListState extends State<CargoTypeList> {
|
|||||||
)));
|
)));
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
child: _row(cargo.name, "\$ " + cargo.rate.toString(),
|
child: _row(cargo.name,
|
||||||
'per pound'),
|
"\$ " + cargo.rate.toStringAsFixed(2), 'per pound'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class CustomEditor extends StatefulWidget {
|
|||||||
class _CustomEditorState extends State<CustomEditor> {
|
class _CustomEditorState extends State<CustomEditor> {
|
||||||
TextEditingController _productController = new TextEditingController();
|
TextEditingController _productController = new TextEditingController();
|
||||||
TextEditingController _feeController = new TextEditingController();
|
TextEditingController _feeController = new TextEditingController();
|
||||||
|
TextEditingController _shipmentRateController = new TextEditingController();
|
||||||
|
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
CustomDuty _custom = new CustomDuty();
|
CustomDuty _custom = new CustomDuty();
|
||||||
@@ -33,7 +34,10 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
if (widget.custom != null) {
|
if (widget.custom != null) {
|
||||||
_custom = widget.custom;
|
_custom = widget.custom;
|
||||||
_productController.text = _custom.productType;
|
_productController.text = _custom.productType;
|
||||||
_feeController.text = _custom.fee.toString();
|
_feeController.text = _custom.fee.toStringAsFixed(2);
|
||||||
|
_shipmentRateController.text = _custom.shipmentRate == null
|
||||||
|
? ""
|
||||||
|
: _custom.shipmentRate.toStringAsFixed(2);
|
||||||
} else {
|
} else {
|
||||||
_isNew = true;
|
_isNew = true;
|
||||||
}
|
}
|
||||||
@@ -54,6 +58,11 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
labelTextKey: 'rate.custom.fee',
|
labelTextKey: 'rate.custom.fee',
|
||||||
iconData: Icons.attach_money,
|
iconData: Icons.attach_money,
|
||||||
controller: _feeController);
|
controller: _feeController);
|
||||||
|
|
||||||
|
final shipmentRateBox = InputText(
|
||||||
|
labelTextKey: 'rate.custom.shipment_rate',
|
||||||
|
iconData: Icons.attach_money,
|
||||||
|
controller: _shipmentRateController);
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -63,7 +72,15 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
icon: new Icon(
|
icon: new Icon(
|
||||||
CupertinoIcons.back,
|
CupertinoIcons.back,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
title:
|
title:
|
||||||
@@ -84,6 +101,7 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
productBox,
|
productBox,
|
||||||
feeBox,
|
feeBox,
|
||||||
|
shipmentRateBox,
|
||||||
SizedBox(height: 30),
|
SizedBox(height: 30),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -107,7 +125,8 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
CustomDuty _customduty = CustomDuty(
|
CustomDuty _customduty = CustomDuty(
|
||||||
productType: _productController.text,
|
productType: _productController.text,
|
||||||
fee: double.parse(_feeController.text));
|
fee: double.parse(_feeController.text),
|
||||||
|
shipmentRate: double.parse(_shipmentRateController.text));
|
||||||
print('_customduty => $_customduty');
|
print('_customduty => $_customduty');
|
||||||
if (_isNew) {
|
if (_isNew) {
|
||||||
await shipmentRateModel.addCustomDuty(_customduty);
|
await shipmentRateModel.addCustomDuty(_customduty);
|
||||||
@@ -147,4 +166,19 @@ class _CustomEditorState extends State<CustomEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _productController.text != "" ||
|
||||||
|
_feeController.text != "" ||
|
||||||
|
_shipmentRateController.text != "";
|
||||||
|
} else {
|
||||||
|
CustomDuty _customduty = CustomDuty(
|
||||||
|
productType: _productController.text,
|
||||||
|
fee: double.parse(_feeController.text),
|
||||||
|
// shipmentRate: double.parse(_shipmentRateController.text)
|
||||||
|
);
|
||||||
|
return widget.custom.isChangedForEdit(_customduty);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import 'package:fcs/pages/widgets/progress.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';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'custom_row.dart';
|
|
||||||
import 'model/shipment_rate_model.dart';
|
import 'model/shipment_rate_model.dart';
|
||||||
|
|
||||||
class CustomList extends StatefulWidget {
|
class CustomList extends StatefulWidget {
|
||||||
@@ -88,7 +86,11 @@ class _CustomListState extends State<CustomList> {
|
|||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
child: _row(
|
child: _row(
|
||||||
custom.productType, "\$ " + custom.fee.toString()),
|
custom.productType,
|
||||||
|
"\$ " + custom.fee.toStringAsFixed(2),
|
||||||
|
custom.shipmentRate == null
|
||||||
|
? ""
|
||||||
|
: "\$ " + custom.shipmentRate.toStringAsFixed(2)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@@ -96,7 +98,7 @@ class _CustomListState extends State<CustomList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_row(String desc, String price) {
|
_row(String desc, String fee, String shipmentRate) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -109,10 +111,19 @@ class _CustomListState extends State<CustomList> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 3.0),
|
padding: const EdgeInsets.only(bottom: 3.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'$price',
|
'$fee',
|
||||||
style: TextStyle(color: primaryColor, fontSize: 14),
|
style: TextStyle(color: primaryColor, fontSize: 14),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
shipmentRate == ""
|
||||||
|
? Container()
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 3.0),
|
||||||
|
child: Text(
|
||||||
|
"\$ " + "$shipmentRate",
|
||||||
|
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
@@ -62,7 +62,15 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back),
|
icon: new Icon(CupertinoIcons.back),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
title: Text(AppTranslations.of(context).text("discount.new")),
|
title: Text(AppTranslations.of(context).text("discount.new")),
|
||||||
@@ -145,4 +153,15 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _weightController.text != "" || _discountController.text != "";
|
||||||
|
} else {
|
||||||
|
DiscountByWeight _discount = DiscountByWeight(
|
||||||
|
weight: double.parse(_weightController.text),
|
||||||
|
discount: double.parse(_discountController.text));
|
||||||
|
return widget.discountByWeight.isChangedForEdit(_discount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,11 +138,21 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
_row("Free delivery within Yangon \nfor shipments over",
|
_row("Free delivery within Yangon \nfor shipments over",
|
||||||
"${rate.freeDeliveryWeight}", "pounds"),
|
"${rate.freeDeliveryWeight.toStringAsFixed(2)}", "pounds"),
|
||||||
_row("Delivery fees", "\$ ${rate.deliveryFee}",
|
_row("Delivery fees", "\$ ${rate.deliveryFee.toStringAsFixed(2)}",
|
||||||
"below ${rate.freeDeliveryWeight} pounds"),
|
"below ${rate.freeDeliveryWeight.toStringAsFixed(2)} pounds"),
|
||||||
_row("Volumetric Ratio", "${rate.volumetricRatio}",
|
_row(
|
||||||
|
"Volumetric Ratio",
|
||||||
|
"${rate.volumetricRatio.toStringAsFixed(2)}",
|
||||||
"in3 per pound"),
|
"in3 per pound"),
|
||||||
|
_row(
|
||||||
|
"Weight difference discount",
|
||||||
|
"${rate.diffDiscountWeight.toStringAsFixed(2)}",
|
||||||
|
"pounds"),
|
||||||
|
_row(
|
||||||
|
"Weight difference rate",
|
||||||
|
"\$ ${rate.diffWeightRate.toStringAsFixed(2)}",
|
||||||
|
""),
|
||||||
Divider(
|
Divider(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
@@ -179,7 +189,8 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
List<Widget> getCargoWidget(List<CargoType> cargos) {
|
List<Widget> getCargoWidget(List<CargoType> cargos) {
|
||||||
return cargos.map((cargo) {
|
return cargos.map((cargo) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(cargo.name, "\$ " + cargo.rate.toString(), 'per pound'),
|
child: _row(
|
||||||
|
cargo.name, "\$ " + cargo.rate.toStringAsFixed(2), 'per pound'),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
@@ -187,7 +198,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
List<Widget> getCustonWidget(List<CustomDuty> customs) {
|
List<Widget> getCustonWidget(List<CustomDuty> customs) {
|
||||||
return customs.map((c) {
|
return customs.map((c) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row(c.productType, "\$ " + c.fee.toString(), ''),
|
child: _row(c.productType, "\$ " + c.fee.toStringAsFixed(2), ''),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
@@ -197,7 +208,7 @@ class _ShipmentRatesState extends State<ShipmentRates> {
|
|||||||
return discounts.map((d) {
|
return discounts.map((d) {
|
||||||
return Container(
|
return Container(
|
||||||
child: _row("${d.weight.toStringAsFixed(2)} lb",
|
child: _row("${d.weight.toStringAsFixed(2)} lb",
|
||||||
"\$ " + d.discount.toString(), ''),
|
"\$ " + d.discount.toStringAsFixed(2), ''),
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:fcs/domain/entities/carton.dart';
|
|||||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
import 'package:fcs/domain/entities/rate.dart';
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/main/util.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/widgets/display_text.dart';
|
import 'package:fcs/pages/widgets/display_text.dart';
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
@@ -46,7 +47,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
_lengthController.text = '12';
|
_lengthController.text = '12';
|
||||||
_widthController.text = '12';
|
_widthController.text = '12';
|
||||||
_heightController.text = '12';
|
_heightController.text = '12';
|
||||||
_actualWeightCtl.text = "10";
|
_actualWeightCtl.text = "10.00";
|
||||||
_calShipmentWeight();
|
_calShipmentWeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
_deliveryFee =
|
_deliveryFee =
|
||||||
effectiveWeight > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
effectiveWeight > rate.freeDeliveryWeight ? 0 : rate.deliveryFee;
|
||||||
_amount = amount == null ? 0 : amount + _deliveryFee;
|
_amount = amount == null ? 0 : amount + _deliveryFee;
|
||||||
_shipmentWeight = shipmentWeight;
|
_shipmentWeight = shipmentWeight.toDouble();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +142,9 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
icon: new Icon(CupertinoIcons.back, color: primaryColor),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
@@ -163,7 +166,7 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
LocalText(context, "rate.delivery_fee",
|
LocalText(context, "rate.delivery_fee",
|
||||||
color: primaryColor, fontSize: 16),
|
color: primaryColor, fontSize: 16),
|
||||||
Text(
|
Text(
|
||||||
':\$ $_deliveryFee',
|
':\$ ${_deliveryFee.toStringAsFixed(2)}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -192,41 +195,4 @@ class _ShipmentRatesCalState extends State<ShipmentRatesCal> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_row(String desc, String price, String unit, String value, {bool input}) {
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Text('$desc ', style: TextStyle(fontSize: 15)),
|
|
||||||
Spacer(),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 3.0),
|
|
||||||
child: Text(
|
|
||||||
'$price',
|
|
||||||
style: TextStyle(color: primaryColor, fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'$unit',
|
|
||||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
|
||||||
),
|
|
||||||
// TextFormField(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 50,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 50,
|
|
||||||
child: TextFormField(
|
|
||||||
initialValue: value,
|
|
||||||
textAlign: TextAlign.end,
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,17 +29,23 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
TextEditingController _minWeight = new TextEditingController();
|
TextEditingController _minWeight = new TextEditingController();
|
||||||
TextEditingController _deliveryFee = new TextEditingController();
|
TextEditingController _deliveryFee = new TextEditingController();
|
||||||
TextEditingController _volumetricRatio = new TextEditingController();
|
TextEditingController _volumetricRatio = new TextEditingController();
|
||||||
|
TextEditingController _diffDiscountWeight = new TextEditingController();
|
||||||
|
TextEditingController _diffWeightRate = new TextEditingController();
|
||||||
|
|
||||||
|
Rate rate;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
var shipmentRateModel =
|
var shipmentRateModel =
|
||||||
Provider.of<ShipmentRateModel>(context, listen: false);
|
Provider.of<ShipmentRateModel>(context, listen: false);
|
||||||
Rate rate = shipmentRateModel.rate;
|
rate = shipmentRateModel.rate;
|
||||||
|
|
||||||
_minWeight.text = rate.freeDeliveryWeight?.toStringAsFixed(2) ?? "";
|
_minWeight.text = rate.freeDeliveryWeight?.toStringAsFixed(2) ?? "";
|
||||||
_deliveryFee.text = rate.deliveryFee?.toString() ?? "";
|
_deliveryFee.text = rate.deliveryFee?.toStringAsFixed(2) ?? "";
|
||||||
_volumetricRatio.text = rate.volumetricRatio?.toString() ?? "";
|
_volumetricRatio.text = rate.volumetricRatio?.toStringAsFixed(2) ?? "";
|
||||||
|
_diffDiscountWeight.text = rate.diffDiscountWeight?.toStringAsFixed(2) ?? "";
|
||||||
|
_diffWeightRate.text = rate.diffWeightRate?.toStringAsFixed(2) ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -61,8 +67,16 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
controller: _deliveryFee);
|
controller: _deliveryFee);
|
||||||
final ratioBox = InputText(
|
final ratioBox = InputText(
|
||||||
labelTextKey: 'rate.volumetric_ratio',
|
labelTextKey: 'rate.volumetric_ratio',
|
||||||
iconData: Icons.attach_money,
|
iconData: FontAwesomeIcons.weightHanging,
|
||||||
controller: _volumetricRatio);
|
controller: _volumetricRatio);
|
||||||
|
final diffDiscountWeightBox = InputText(
|
||||||
|
labelTextKey: 'rate.diff_discount_weight',
|
||||||
|
iconData: FontAwesomeIcons.weightHanging,
|
||||||
|
controller: _diffDiscountWeight);
|
||||||
|
final diffWeightRateBox = InputText(
|
||||||
|
labelTextKey: 'rate.diff_weight_rate',
|
||||||
|
iconData: Icons.attach_money,
|
||||||
|
controller: _diffWeightRate);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
@@ -73,7 +87,15 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
icon: new Icon(
|
icon: new Icon(
|
||||||
CupertinoIcons.back,
|
CupertinoIcons.back,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
if (isDataChanged()) {
|
||||||
|
showConfirmDialog(context, "back.button_confirm", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
title: Text(AppTranslations.of(context).text("rate.edit.title")),
|
title: Text(AppTranslations.of(context).text("rate.edit.title")),
|
||||||
@@ -88,6 +110,8 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
minWigBox,
|
minWigBox,
|
||||||
feeBox,
|
feeBox,
|
||||||
ratioBox,
|
ratioBox,
|
||||||
|
diffDiscountWeightBox,
|
||||||
|
diffWeightRateBox,
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -112,7 +136,9 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
Rate _rate = new Rate(
|
Rate _rate = new Rate(
|
||||||
deliveryFee: double.parse(_deliveryFee.text),
|
deliveryFee: double.parse(_deliveryFee.text),
|
||||||
freeDeliveryWeight: double.parse(_minWeight.text),
|
freeDeliveryWeight: double.parse(_minWeight.text),
|
||||||
volumetricRatio: double.parse(_volumetricRatio.text));
|
volumetricRatio: double.parse(_volumetricRatio.text),
|
||||||
|
diffDiscountWeight: double.parse(_diffDiscountWeight.text),
|
||||||
|
diffWeightRate: double.parse(_diffWeightRate.text));
|
||||||
Rate r = new Rate();
|
Rate r = new Rate();
|
||||||
print('_rate =>$r');
|
print('_rate =>$r');
|
||||||
await shipmentRateModel.updateRate(_rate);
|
await shipmentRateModel.updateRate(_rate);
|
||||||
@@ -126,6 +152,17 @@ class _ShipmentRatesEditState extends State<ShipmentRatesEdit> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
Rate _rate = new Rate(
|
||||||
|
deliveryFee: double.parse(_deliveryFee.text),
|
||||||
|
freeDeliveryWeight: double.parse(_minWeight.text),
|
||||||
|
volumetricRatio: double.parse(_volumetricRatio.text),
|
||||||
|
diffDiscountWeight: double.parse(_diffDiscountWeight.text),
|
||||||
|
diffWeightRate: double.parse(_diffWeightRate.text),
|
||||||
|
);
|
||||||
|
return rate.isChangedForEdit(_rate);
|
||||||
|
}
|
||||||
|
|
||||||
List<MyDataRow> getCargoRows(List<CargoType> cargos) {
|
List<MyDataRow> getCargoRows(List<CargoType> cargos) {
|
||||||
return cargos.map((r) {
|
return cargos.map((r) {
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
|
|||||||
@@ -149,7 +149,15 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon:
|
icon:
|
||||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
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,
|
||||||
@@ -249,4 +257,22 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
if (_isNew) {
|
||||||
|
return _trackingIDCtl.text != "" ||
|
||||||
|
_remarkCtl.text != "" ||
|
||||||
|
user != null ||
|
||||||
|
_multiImgController.getAddedFile.isNotEmpty;
|
||||||
|
} else {
|
||||||
|
var _package = Package(
|
||||||
|
trackingID: _trackingIDCtl.text,
|
||||||
|
remark: _remarkCtl.text,
|
||||||
|
fcsID: user.fcsID,
|
||||||
|
photoUrls: widget.package.photoUrls);
|
||||||
|
return widget.package.isChangedForEdit(_package) ||
|
||||||
|
_multiImgController.getAddedFile.isNotEmpty ||
|
||||||
|
_multiImgController.getDeletedUrl.isNotEmpty;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,15 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
CupertinoIcons.back,
|
CupertinoIcons.back,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
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,
|
||||||
@@ -312,4 +320,8 @@ class _ShipmentEditorState extends State<ShipmentEditor> {
|
|||||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||||
launch("${mainModel.setting.courierWebsite}");
|
launch("${mainModel.setting.courierWebsite}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDataChanged() {
|
||||||
|
return _shipment.boxes.isNotEmpty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,10 +171,11 @@ class _StaffEditorState extends State<StaffEditor> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
icon:
|
icon: new Icon(CupertinoIcons.back,
|
||||||
new Icon(CupertinoIcons.back, color: primaryColor, size: 30),
|
color: primaryColor, size: 30),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
),
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ class _TermEditState extends State<TermEdit> {
|
|||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
size: 30,
|
size: 30,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
|||||||
92
lib/pages/widgets/dialog_input.dart
Normal file
92
lib/pages/widgets/dialog_input.dart
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
import 'package:fcs/pages/main/util.dart';
|
||||||
|
import 'package:fcs/pages/widgets/progress.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'local_text.dart';
|
||||||
|
|
||||||
|
class DialogInput extends StatefulWidget {
|
||||||
|
final String value;
|
||||||
|
final String label;
|
||||||
|
const DialogInput({Key key, this.label, this.value}) : super(key: key);
|
||||||
|
@override
|
||||||
|
_DialogInputState createState() => _DialogInputState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DialogInputState extends State<DialogInput> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
TextEditingController _controller = new TextEditingController();
|
||||||
|
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.value != null) {
|
||||||
|
_controller.text = widget.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return LocalProgress(
|
||||||
|
inAsyncCall: _isLoading,
|
||||||
|
child: AlertDialog(
|
||||||
|
title: LocalText(
|
||||||
|
context,
|
||||||
|
widget.label,
|
||||||
|
fontSize: 20,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
content: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: TextField(
|
||||||
|
controller: _controller,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: new InputDecoration(
|
||||||
|
focusedBorder: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: primaryColor, width: 1.0))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
'btn.cancel',
|
||||||
|
color: labelColor,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_controller.clear();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
FlatButton(
|
||||||
|
color: primaryColor,
|
||||||
|
child: LocalText(
|
||||||
|
context,
|
||||||
|
'btn.ok',
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
if (!_formKey.currentState.validate()) return;
|
||||||
|
_save();
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_save() {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Navigator.pop<String>(context, _controller.text);
|
||||||
|
} catch (e) {
|
||||||
|
showMsgDialog(context, "Error", e.toString());
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,6 +54,7 @@ class StatusTree extends StatelessWidget {
|
|||||||
e.done || isPacked
|
e.done || isPacked
|
||||||
? Text(dateFormatter.format(e.date))
|
? Text(dateFormatter.format(e.date))
|
||||||
: Container(),
|
: Container(),
|
||||||
|
e.staffName == null ? Container() : Text(e.staffName)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: fcs
|
|||||||
description: FCS Logistics
|
description: FCS Logistics
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 1.0.5+7
|
version: 1.0.6+8
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
@@ -57,6 +57,7 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
test: ^1.15.7
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
33
test/rate_test.dart
Normal file
33
test/rate_test.dart
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||||
|
import 'package:fcs/domain/entities/carton.dart';
|
||||||
|
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||||
|
import 'package:fcs/domain/entities/rate.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
@TestOn('vm')
|
||||||
|
void main() {
|
||||||
|
var rate = Rate();
|
||||||
|
rate.discountByWeights = [
|
||||||
|
DiscountByWeight(weight: 25, discount: 0.25),
|
||||||
|
DiscountByWeight(weight: 50, discount: 0.5),
|
||||||
|
];
|
||||||
|
rate.volumetricRatio = 166.36;
|
||||||
|
rate.diffDiscountWeight = 5;
|
||||||
|
rate.diffWeightRate = 1.5;
|
||||||
|
|
||||||
|
test('Calculate carton price 1', () {
|
||||||
|
var ct = CargoType(name: "General", weight: 10, rate: 6);
|
||||||
|
var carton = Carton(cargoTypes: [ct], length: 15, width: 15, height: 15);
|
||||||
|
expect(carton.calAmount(rate), equals(67.50));
|
||||||
|
});
|
||||||
|
test('Calculate carton price 2', () {
|
||||||
|
var ct = CargoType(name: "General", weight: 10, rate: 6);
|
||||||
|
var carton = Carton(cargoTypes: [ct], length: 10, width: 10, height: 10);
|
||||||
|
expect(carton.calAmount(rate), equals(60));
|
||||||
|
});
|
||||||
|
test('Calculate carton price 3', () {
|
||||||
|
var ct = CargoType(name: "General", weight: 10, rate: 6);
|
||||||
|
var carton = Carton(cargoTypes: [ct], length: 15, width: 15, height: 10);
|
||||||
|
expect(carton.calAmount(rate), equals(60));
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user