fix carton
This commit is contained in:
@@ -294,7 +294,8 @@
|
|||||||
"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.new_carton_btn":"Create new carton",
|
||||||
"box.select.cargo.title":"Select cargos",
|
"box.select.cargo.title":"Cargo Types",
|
||||||
|
"box.select.cargo.special":"Special Cargos",
|
||||||
"box.complete.packaging":"Complete Packaging",
|
"box.complete.packaging":"Complete Packaging",
|
||||||
"box.mix_caton_title":"Mix cartons",
|
"box.mix_caton_title":"Mix cartons",
|
||||||
"box.min_caton.form.title":"Mix Carton",
|
"box.min_caton.form.title":"Mix Carton",
|
||||||
@@ -543,6 +544,8 @@
|
|||||||
"receiving.delete.confirm":"Delete this receiving?",
|
"receiving.delete.confirm":"Delete this receiving?",
|
||||||
"receiving.return.btn":"Return package",
|
"receiving.return.btn":"Return package",
|
||||||
"receiving.return.confirm":"Return package?",
|
"receiving.return.confirm":"Return package?",
|
||||||
|
"receiving.consignee.name":"Consignee name",
|
||||||
|
"receiving.shipper.name":"Sender name",
|
||||||
"Receiving End ================================================================":"",
|
"Receiving End ================================================================":"",
|
||||||
|
|
||||||
"Processing Start ================================================================":"",
|
"Processing Start ================================================================":"",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Package {
|
|||||||
String shipmentNumber;
|
String shipmentNumber;
|
||||||
String senderFCSID;
|
String senderFCSID;
|
||||||
String senderName;
|
String senderName;
|
||||||
|
String senderPhoneNumber;
|
||||||
String boxNumber;
|
String boxNumber;
|
||||||
String cargoDesc;
|
String cargoDesc;
|
||||||
String market;
|
String market;
|
||||||
@@ -68,6 +69,7 @@ class Package {
|
|||||||
this.deliveryAddress,
|
this.deliveryAddress,
|
||||||
this.isChecked = false,
|
this.isChecked = false,
|
||||||
this.photoFiles,
|
this.photoFiles,
|
||||||
|
this.senderPhoneNumber
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Package.fromMap(Map<String, dynamic> map, String docID) {
|
factory Package.fromMap(Map<String, dynamic> map, String docID) {
|
||||||
@@ -92,6 +94,9 @@ class Package {
|
|||||||
remark: map['remark'],
|
remark: map['remark'],
|
||||||
desc: map['desc'],
|
desc: map['desc'],
|
||||||
status: map['status'],
|
status: map['status'],
|
||||||
|
senderFCSID: map['sender_fcs_id'],
|
||||||
|
senderName: map['sender_name'],
|
||||||
|
senderPhoneNumber: map['sender_phone_number'],
|
||||||
deliveryAddress: _da,
|
deliveryAddress: _da,
|
||||||
currentStatusDate: _currentStatusDate != null
|
currentStatusDate: _currentStatusDate != null
|
||||||
? _currentStatusDate.toDate().toLocal()
|
? _currentStatusDate.toDate().toLocal()
|
||||||
@@ -118,6 +123,9 @@ class Package {
|
|||||||
market: json['market'],
|
market: json['market'],
|
||||||
userName: json['user_name'],
|
userName: json['user_name'],
|
||||||
phoneNumber: json['phone_number'],
|
phoneNumber: json['phone_number'],
|
||||||
|
senderFCSID: json['sender_fcs_id'],
|
||||||
|
senderName: json['sender_name'],
|
||||||
|
senderPhoneNumber: json['sender_phone_number'],
|
||||||
status: json['status'],
|
status: json['status'],
|
||||||
currentStatusDate: DateTime.parse(json['status_date']));
|
currentStatusDate: DateTime.parse(json['status_date']));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
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/local_title.dart';
|
||||||
@@ -20,19 +18,31 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
List<CargoType> cargos = [];
|
List<CargoType> cargos = [];
|
||||||
|
List<CargoType> specialCargos = [];
|
||||||
|
|
||||||
@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);
|
||||||
cargos = List.from(shipmentRateModel.rate.cargoTypes);
|
|
||||||
|
cargos = shipmentRateModel.rate.cargoTypes.map((e) => e.clone()).toList();
|
||||||
|
specialCargos = List.from(shipmentRateModel.rate.customDuties);
|
||||||
|
specialCargos =
|
||||||
|
shipmentRateModel.rate.customDuties.map((e) => e.clone()).toList();
|
||||||
|
|
||||||
cargos.forEach((p) {
|
cargos.forEach((p) {
|
||||||
p.isChecked = false;
|
p.isChecked = false;
|
||||||
p.isCutomDuty = false;
|
p.isCutomDuty = false;
|
||||||
p.weight = 0;
|
p.weight = 0;
|
||||||
p.qty = null;
|
p.qty = null;
|
||||||
});
|
});
|
||||||
|
specialCargos.forEach((p) {
|
||||||
|
p.isChecked = false;
|
||||||
|
p.isCutomDuty = true;
|
||||||
|
p.weight = 0;
|
||||||
|
p.qty = 1;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -42,40 +52,31 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Widget> getCargoRowList() {
|
List<Widget> getCargoRowList(List<CargoType> _c) {
|
||||||
return cargos.map((c) {
|
return _c.map((c) {
|
||||||
return Container(
|
return Container(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding:
|
padding:
|
||||||
EdgeInsets.only(left: 10.0, right: 5.0, top: 3.0, bottom: 3.0),
|
EdgeInsets.only(left: 10.0, right: 5.0, top: 3.0, bottom: 3.0),
|
||||||
child: Row(
|
child: InkWell(
|
||||||
children: <Widget>[
|
onTap: () {
|
||||||
Checkbox(
|
setState(() {
|
||||||
value: c.isChecked,
|
c.isChecked = !c.isChecked;
|
||||||
activeColor: primaryColor,
|
});
|
||||||
onChanged: (bool check) {
|
},
|
||||||
setState(() {
|
child: Row(
|
||||||
c.isChecked = check;
|
children: <Widget>[
|
||||||
});
|
Checkbox(
|
||||||
}),
|
value: c.isChecked,
|
||||||
new Text(c.name, style: textStyle),
|
activeColor: primaryColor,
|
||||||
c.isCutomDuty
|
onChanged: (bool check) {
|
||||||
? Padding(
|
setState(() {
|
||||||
padding: const EdgeInsets.only(left: 15),
|
c.isChecked = check;
|
||||||
child: IconButton(
|
});
|
||||||
onPressed: () {
|
}),
|
||||||
setState(() {
|
new Text(c.name, style: textStyle),
|
||||||
cargos.removeWhere((t) => t.name == c.name);
|
],
|
||||||
});
|
),
|
||||||
},
|
|
||||||
icon: Icon(
|
|
||||||
Icons.remove_circle,
|
|
||||||
color: Colors.black45,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -88,6 +89,9 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
callack: () {
|
callack: () {
|
||||||
List<CargoType> _cargos =
|
List<CargoType> _cargos =
|
||||||
this.cargos.where((c) => c.isChecked).toList();
|
this.cargos.where((c) => c.isChecked).toList();
|
||||||
|
List<CargoType> _scargos =
|
||||||
|
this.specialCargos.where((c) => c.isChecked).toList();
|
||||||
|
_cargos.addAll(_scargos);
|
||||||
Navigator.pop(context, _cargos);
|
Navigator.pop(context, _cargos);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -117,21 +121,15 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
LocalTitle(
|
LocalTitle(
|
||||||
textKey: "box.select.cargo.title",
|
textKey: "box.select.cargo.title",
|
||||||
trailing: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.add_circle,
|
|
||||||
color: primaryColor,
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
CargoType customDuty = await Navigator.of(context).push(
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
CustomList(selected: true)));
|
|
||||||
_addCustom(customDuty);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: getCargoRowList(),
|
children: getCargoRowList(cargos),
|
||||||
|
),
|
||||||
|
LocalTitle(
|
||||||
|
textKey: "box.select.cargo.title",
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: getCargoRowList(specialCargos),
|
||||||
),
|
),
|
||||||
SizedBox(height: 30),
|
SizedBox(height: 30),
|
||||||
saveBtn,
|
saveBtn,
|
||||||
@@ -142,21 +140,4 @@ class _CargoTypeAdditionState extends State<CargoTypeAddition> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_addCustom(CargoType customDuty) {
|
|
||||||
if (customDuty == null) return;
|
|
||||||
|
|
||||||
if (cargos.any((c) => c.name == customDuty.name)) return;
|
|
||||||
|
|
||||||
// setState(() {
|
|
||||||
// cargos.add(CargoType(
|
|
||||||
// name: customDuty.productType, isCutomDuty: true, qty: 1, weight: 0));
|
|
||||||
// });
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
customDuty.qty = 1;
|
|
||||||
customDuty.isChecked = false;
|
|
||||||
cargos.add(customDuty);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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/model/main_model.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/rates/model/shipment_rate_model.dart';
|
||||||
import 'package:fcs/pages/widgets/input_text.dart';
|
import 'package:fcs/pages/widgets/input_text.dart';
|
||||||
|
|||||||
@@ -7,19 +7,17 @@ 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';
|
|
||||||
|
|
||||||
typedef OnAdd(CargoType cargoType);
|
|
||||||
typedef OnRemove(CargoType cargoType);
|
typedef OnRemove(CargoType cargoType);
|
||||||
|
typedef OnUpdate(CargoType cargoType);
|
||||||
|
|
||||||
class CargoTable extends StatefulWidget {
|
class CargoTable extends StatefulWidget {
|
||||||
final List<CargoType> cargoTypes;
|
final List<CargoType> cargoTypes;
|
||||||
final bool isNew;
|
final bool isNew;
|
||||||
final OnAdd onAdd;
|
|
||||||
final OnRemove onRemove;
|
final OnRemove onRemove;
|
||||||
|
final OnUpdate onUpdate;
|
||||||
|
|
||||||
const CargoTable(
|
const CargoTable(
|
||||||
{Key key, this.cargoTypes, this.isNew, this.onAdd, this.onRemove})
|
{Key key, this.cargoTypes, this.isNew, this.onRemove, this.onUpdate})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -28,26 +26,23 @@ class CargoTable extends StatefulWidget {
|
|||||||
|
|
||||||
class _CargoTableState extends State<CargoTable> {
|
class _CargoTableState extends State<CargoTable> {
|
||||||
double totalWeight = 0;
|
double totalWeight = 0;
|
||||||
List<CargoType> _cargos = [];
|
List<CargoType> cargoTypes;
|
||||||
double remainingWeight = 0;
|
|
||||||
List<String> _list = [];
|
|
||||||
List<String> _types = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
cargoTypes = widget.cargoTypes;
|
||||||
if (!widget.isNew) {
|
if (!widget.isNew) {
|
||||||
totalWeight = widget.cargoTypes
|
totalWeight =
|
||||||
.fold(0, (previous, current) => previous + current.weight);
|
cargoTypes.fold(0, (previous, current) => previous + current.weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
remainingWeight =
|
print("Cargotypes:${cargoTypes.length}");
|
||||||
widget.cargoTypes.length == 0 ? this.totalWeight : remainingWeight;
|
|
||||||
this._cargos = widget.cargoTypes.length == 0 ? [] : this._cargos;
|
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: MyDataTable(
|
child: MyDataTable(
|
||||||
@@ -82,13 +77,10 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> getCargoRows(BuildContext context) {
|
List<MyDataRow> getCargoRows(BuildContext context) {
|
||||||
if (widget.cargoTypes == null) {
|
if (cargoTypes == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
var rows = cargoTypes.map((c) {
|
||||||
CargoType cargo;
|
|
||||||
|
|
||||||
var rows = widget.cargoTypes.map((c) {
|
|
||||||
return MyDataRow(
|
return MyDataRow(
|
||||||
onSelectChanged: (bool selected) async {},
|
onSelectChanged: (bool selected) async {},
|
||||||
cells: [
|
cells: [
|
||||||
@@ -109,8 +101,9 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
|
|
||||||
if (_t == null) return;
|
if (_t == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
c.qty = int.parse(_t);
|
c.qty = int.tryParse(_t) ?? 0;
|
||||||
});
|
});
|
||||||
|
if (widget.onUpdate != null) widget.onUpdate(c);
|
||||||
},
|
},
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -155,37 +148,12 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
|
|
||||||
if (_t == null) return;
|
if (_t == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
c.weight = double.parse(_t);
|
c.weight = double.tryParse(_t) ?? 0;
|
||||||
});
|
});
|
||||||
|
if (c.weight != 0) {
|
||||||
cargo = c;
|
_cal();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
if (widget.onUpdate != null) widget.onUpdate(c);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(7.0),
|
padding: const EdgeInsets.all(7.0),
|
||||||
@@ -246,9 +214,9 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
|
|
||||||
if (_t == null) return;
|
if (_t == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
totalWeight = double.parse(_t);
|
totalWeight = double.tryParse(_t) ?? 0;
|
||||||
remainingWeight = totalWeight;
|
|
||||||
});
|
});
|
||||||
|
_cal();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(7.0),
|
padding: const EdgeInsets.all(7.0),
|
||||||
@@ -268,77 +236,29 @@ class _CargoTableState extends State<CargoTable> {
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MyDataRow> _getCargoRows(BuildContext context) {
|
_cal() {
|
||||||
if (widget.cargoTypes == null) {
|
var cargoType = autoCalWeight(cargoTypes, totalWeight);
|
||||||
return [];
|
if (cargoType == null) return;
|
||||||
}
|
|
||||||
double total = 0;
|
|
||||||
var rows = widget.cargoTypes.map((c) {
|
|
||||||
total += c.weight;
|
|
||||||
return MyDataRow(
|
|
||||||
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: [
|
|
||||||
MyDataCell(new Text(
|
|
||||||
c.name == null ? "" : c.name,
|
|
||||||
style: textStyle,
|
|
||||||
)),
|
|
||||||
MyDataCell(
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Text(c.weight == null ? "0" : 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(
|
setState(() {
|
||||||
onSelectChanged: (bool selected) {},
|
cargoTypes.remove(cargoType);
|
||||||
cells: [
|
cargoTypes.add(cargoType);
|
||||||
MyDataCell(Align(
|
});
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: LocalText(
|
if (widget.onUpdate != null) {
|
||||||
context,
|
widget.onUpdate(cargoType);
|
||||||
"shipment.cargo.total",
|
}
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CargoType autoCalWeight(List<CargoType> cargoTypes, double total) {
|
||||||
|
if ((cargoTypes?.length ?? 0) == 0 || total == 0) return null;
|
||||||
|
List<CargoType> noWeight = cargoTypes.where((c) => c.weight == 0).toList();
|
||||||
|
if (noWeight.length != 1) return null;
|
||||||
|
|
||||||
|
var _existing =
|
||||||
|
cargoTypes.fold(0, (previous, current) => previous + current.weight);
|
||||||
|
|
||||||
|
noWeight[0].weight = total - _existing;
|
||||||
|
return noWeight[0];
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
User sender;
|
User sender;
|
||||||
List<Carton> _cartonsFromCartons = [];
|
List<Carton> _cartonsFromCartons = [];
|
||||||
|
|
||||||
|
double totalWeight;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -410,8 +412,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||||
if (cargos == null) return;
|
if (cargos == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes.clear();
|
_cargoTypes.addAll(
|
||||||
_cargoTypes.addAll(cargos);
|
cargos.where((e) => !_cargoTypes.contains(e)).toList());
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -419,8 +421,8 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
final cargoTableBox = CargoTable(
|
final cargoTableBox = CargoTable(
|
||||||
isNew: _isNew,
|
isNew: _isNew,
|
||||||
cargoTypes: _cargoTypes,
|
cargoTypes: _cargoTypes,
|
||||||
onAdd: (c) => _addCargo(c),
|
|
||||||
onRemove: (c) => _removeCargo(c),
|
onRemove: (c) => _removeCargo(c),
|
||||||
|
onUpdate: (c) => _updateCargo(c),
|
||||||
);
|
);
|
||||||
|
|
||||||
final lengthBox = LengthPicker(
|
final lengthBox = LengthPicker(
|
||||||
@@ -779,20 +781,23 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_addCargo(CargoType cargo) {
|
|
||||||
if (cargo == null) return;
|
|
||||||
setState(() {
|
|
||||||
_cargoTypes.remove(cargo);
|
|
||||||
_cargoTypes.add(cargo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_removeCargo(CargoType cargo) {
|
_removeCargo(CargoType cargo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes.remove(cargo);
|
_cargoTypes.remove(cargo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateCargo(CargoType cargo) {
|
||||||
|
setState(() {
|
||||||
|
var _c =
|
||||||
|
_cargoTypes.firstWhere((e) => e.id == cargo.id, orElse: () => null);
|
||||||
|
if (_c != null) {
|
||||||
|
_c.weight = cargo.weight;
|
||||||
|
_c.qty = cargo.qty;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_addCarton() async {
|
_addCarton() async {
|
||||||
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
bool isFromPackages = _selectedCartonType == carton_from_packages;
|
||||||
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
bool isFromCartons = _selectedCartonType == carton_from_cartons;
|
||||||
@@ -931,6 +936,10 @@ class _CartonEditorState extends State<CartonEditor> {
|
|||||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (_cargoTypes.where((c) => c.weight <= 0).isNotEmpty) {
|
||||||
|
showMsgDialog(context, "Error", "Invalid cargo weight");
|
||||||
|
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);
|
||||||
|
|||||||
@@ -138,9 +138,10 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
context,
|
context,
|
||||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||||
if (cargos == null) return;
|
if (cargos == null) return;
|
||||||
|
if (cargos == null) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes.clear();
|
_cargoTypes.addAll(
|
||||||
_cargoTypes.addAll(cargos);
|
cargos.where((e) => !_cargoTypes.contains(e)).toList());
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -148,8 +149,8 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
final cargoTableBox = CargoTable(
|
final cargoTableBox = CargoTable(
|
||||||
isNew: widget.isNew,
|
isNew: widget.isNew,
|
||||||
cargoTypes: _cargoTypes,
|
cargoTypes: _cargoTypes,
|
||||||
onAdd: (c) => _addCargo(c),
|
|
||||||
onRemove: (c) => _removeCargo(c),
|
onRemove: (c) => _removeCargo(c),
|
||||||
|
onUpdate: (c) => _updateCargo(c),
|
||||||
);
|
);
|
||||||
|
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
@@ -286,20 +287,23 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_addCargo(CargoType cargo) {
|
|
||||||
if (cargo == null) return;
|
|
||||||
setState(() {
|
|
||||||
_cargoTypes.remove(cargo);
|
|
||||||
_cargoTypes.add(cargo);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_removeCargo(CargoType cargo) {
|
_removeCargo(CargoType cargo) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_cargoTypes.remove(cargo);
|
_cargoTypes.remove(cargo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateCargo(CargoType cargo) {
|
||||||
|
setState(() {
|
||||||
|
var _c =
|
||||||
|
_cargoTypes.firstWhere((e) => e.id == cargo.id, orElse: () => null);
|
||||||
|
if (_c != null) {
|
||||||
|
_c.weight = cargo.weight;
|
||||||
|
_c.qty = cargo.qty;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_creatCarton() async {
|
_creatCarton() async {
|
||||||
if ((_cargoTypes?.length ?? 0) == 0) {
|
if ((_cargoTypes?.length ?? 0) == 0) {
|
||||||
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
showMsgDialog(context, "Error", "Expect at least one cargo type");
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'package:fcs/domain/entities/package.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/model/package_model.dart';
|
import 'package:fcs/pages/package/model/package_model.dart';
|
||||||
import 'package:fcs/pages/widgets/bottom_up_page_route.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/local_text.dart';
|
import 'package:fcs/pages/widgets/local_text.dart';
|
||||||
@@ -71,7 +70,22 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
);
|
);
|
||||||
final customerNameBox = DisplayText(
|
final customerNameBox = DisplayText(
|
||||||
text: _package.userName,
|
text: _package.userName,
|
||||||
labelTextKey: "processing.name",
|
labelTextKey: "processing.consignee.name",
|
||||||
|
iconData: Icons.perm_identity,
|
||||||
|
);
|
||||||
|
var senderFcsIDBox = DisplayText(
|
||||||
|
text: _package.senderFCSID,
|
||||||
|
labelTextKey: "processing.fcs.id",
|
||||||
|
icon: FcsIDIcon(),
|
||||||
|
);
|
||||||
|
final senderPhoneNumberBox = DisplayText(
|
||||||
|
text: _package.senderPhoneNumber,
|
||||||
|
labelTextKey: "processing.phone",
|
||||||
|
iconData: Icons.phone,
|
||||||
|
);
|
||||||
|
final senderNameBox = DisplayText(
|
||||||
|
text: _package.senderName,
|
||||||
|
labelTextKey: "processing.shipper.name",
|
||||||
iconData: Icons.perm_identity,
|
iconData: Icons.perm_identity,
|
||||||
);
|
);
|
||||||
final marketBox = DisplayText(
|
final marketBox = DisplayText(
|
||||||
@@ -95,6 +109,24 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
title: "Receipt File",
|
title: "Receipt File",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final consigneeBox = Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
fcsIDBox,
|
||||||
|
phoneNumberBox,
|
||||||
|
customerNameBox,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final shipperBox = Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
senderFcsIDBox,
|
||||||
|
senderPhoneNumberBox,
|
||||||
|
senderNameBox,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
return LocalProgress(
|
return LocalProgress(
|
||||||
inAsyncCall: _isLoading,
|
inAsyncCall: _isLoading,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -131,9 +163,12 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
|||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: ListView(children: <Widget>[
|
child: ListView(children: <Widget>[
|
||||||
trackingIdBox,
|
trackingIdBox,
|
||||||
fcsIDBox,
|
Row(
|
||||||
customerNameBox,
|
children: [
|
||||||
phoneNumberBox,
|
Flexible(child: consigneeBox),
|
||||||
|
Flexible(child: shipperBox)
|
||||||
|
],
|
||||||
|
),
|
||||||
marketBox,
|
marketBox,
|
||||||
descBox,
|
descBox,
|
||||||
remarkBox,
|
remarkBox,
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
|||||||
);
|
);
|
||||||
final namebox = DisplayText(
|
final namebox = DisplayText(
|
||||||
text: user != null ? user.name : "",
|
text: user != null ? user.name : "",
|
||||||
labelTextKey: "receiving.name",
|
labelTextKey: "receiving.consignee.name",
|
||||||
iconData: Icons.person,
|
iconData: Icons.person,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user