update carton and add staff name
This commit is contained in:
@@ -7,20 +7,16 @@ import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.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_search/carton_search.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/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/length_picker.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_radio_buttons.dart';
|
||||
@@ -31,8 +27,9 @@ 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 'cargo_type_editor.dart';
|
||||
import 'carton_list_row.dart';
|
||||
import 'carton_row.dart';
|
||||
import 'mix_carton_editor.dart';
|
||||
import 'model/carton_model.dart';
|
||||
import '../carton_size/model/carton_size_model.dart';
|
||||
import 'package_carton_editor.dart';
|
||||
@@ -57,14 +54,14 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
DeliveryAddress _deliveryAddress = new DeliveryAddress();
|
||||
User _user;
|
||||
String _selectedCartonType;
|
||||
String _selectedMixType;
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
FcsShipment _fcsShipment;
|
||||
List<FcsShipment> _fcsShipments;
|
||||
Carton _mixCarton;
|
||||
List<Carton> _mixCartons;
|
||||
|
||||
List<Carton> _cartons = [];
|
||||
List<Carton> _mixCartons = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -98,12 +95,14 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_heightController.text = "";
|
||||
_isNew = true;
|
||||
_selectedCartonType = carton_from_packages;
|
||||
_selectedMixType = mix_delivery;
|
||||
_loadFcsShipments();
|
||||
// _cartons = [
|
||||
// Carton(cartonNumber: "A100B-1#1"),
|
||||
// Carton(cartonNumber: "A100B-1#2"),
|
||||
// Carton(cartonNumber: "A100B-1#3")
|
||||
// ];
|
||||
_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"),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,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() {
|
||||
double l = double.parse(_lengthController.text, (s) => 0);
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
@@ -197,17 +184,13 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
Widget build(BuildContext context) {
|
||||
var boxModel = Provider.of<CartonModel>(context);
|
||||
bool isMixBox = _selectedCartonType == carton_mix_box;
|
||||
bool isSmallBag = _selectedCartonType == carton_small_bag;
|
||||
|
||||
final shipmentBox = DisplayText(
|
||||
text: _carton.fcsShipmentNumber,
|
||||
labelTextKey: "box.fcs_shipment_num",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
);
|
||||
final mixCartonNumberBox = DisplayText(
|
||||
text: _carton.mixCartonNumber,
|
||||
labelTextKey: "box.mix.carton",
|
||||
iconData: MaterialCommunityIcons.package,
|
||||
);
|
||||
|
||||
var fcsShipmentsBox = Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: LocalDropdown<FcsShipment>(
|
||||
@@ -215,7 +198,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
setState(() {
|
||||
_fcsShipment = v;
|
||||
});
|
||||
_loadMixCartons();
|
||||
},
|
||||
labelKey: "shipment.pack.fcs.shipment",
|
||||
iconData: Ionicons.ios_airplane,
|
||||
@@ -224,21 +206,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
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(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: Row(
|
||||
@@ -269,41 +236,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
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(
|
||||
textKey: "box.complete.packaging",
|
||||
callBack: _save,
|
||||
@@ -324,35 +256,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
});
|
||||
});
|
||||
|
||||
final cargoTableTitleBox = LocalTitle(
|
||||
textKey: "box.cargo.type",
|
||||
trailing: IconButton(
|
||||
icon: Icon(
|
||||
Icons.add_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
// CargoType cargo = await Navigator.push<CargoType>(context,
|
||||
// CupertinoPageRoute(builder: (context) => CargoTypeEditor()));
|
||||
// _addCargo(cargo);
|
||||
List<CargoType> cargos = await Navigator.push<List<CargoType>>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CargoTypeAddition()));
|
||||
if (cargos == null) return;
|
||||
setState(() {
|
||||
_carton.cargoTypes.clear();
|
||||
_carton.cargoTypes.addAll(cargos);
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
final cargoTableBox = CargoTable(
|
||||
cargoTypes: _carton.cargoTypes,
|
||||
onAdd: (c) => _addCargo(c),
|
||||
onRemove: (c) => _removeCargo(c),
|
||||
);
|
||||
|
||||
final cartonTitleBox = Container(
|
||||
final _cartonTitleBox = Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
@@ -374,6 +278,54 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
),
|
||||
);
|
||||
|
||||
final cartonTitleBox = Container(
|
||||
child: LocalTitle(
|
||||
textKey: "boxes.title",
|
||||
trailing: IconButton(
|
||||
icon: Icon(
|
||||
Icons.add_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Carton _carton = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => PackageCartonEditor()),
|
||||
);
|
||||
_addCarton(_carton);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
final mixTypeBox = Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: LocalRadioButtons(
|
||||
readOnly: !_isNew,
|
||||
values: boxModel.mixTypes,
|
||||
selectedValue: _selectedMixType,
|
||||
callback: (v) {
|
||||
setState(() {
|
||||
_selectedMixType = v;
|
||||
});
|
||||
}));
|
||||
|
||||
final mixcartonTitleBox = Container(
|
||||
child: LocalTitle(
|
||||
textKey: "box.mix_caton_title",
|
||||
trailing: IconButton(
|
||||
icon: Icon(
|
||||
Icons.add_circle,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Carton _carton = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => MixCartonEditor()),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -399,19 +351,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
fontSize: 20,
|
||||
color: primaryColor,
|
||||
),
|
||||
// title: _isNew
|
||||
// ? LocalText(
|
||||
// context,
|
||||
// "boxes.create.title",
|
||||
// fontSize: 20,
|
||||
// color: primaryColor,
|
||||
// )
|
||||
// : LocalText(
|
||||
// context,
|
||||
// "box.edit.title",
|
||||
// fontSize: 20,
|
||||
// color: primaryColor,
|
||||
// ),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -425,21 +364,15 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
_isNew ? fcsShipmentsBox : shipmentBox,
|
||||
isSmallBag
|
||||
? _isNew
|
||||
? mixCartonsBox
|
||||
: mixCartonNumberBox
|
||||
: Container(),
|
||||
isMixBox ? mixTypeBox : Container(),
|
||||
...(isMixBox
|
||||
? [
|
||||
// CartonMixTable(
|
||||
// cartons: _carton.cartons,
|
||||
// onSelect: (c, check) {
|
||||
// setState(() {
|
||||
// c.isChecked = check;
|
||||
// });
|
||||
// },
|
||||
// )
|
||||
mixcartonTitleBox,
|
||||
Column(
|
||||
children: _getMixCartons(
|
||||
context,
|
||||
this._mixCartons,
|
||||
)),
|
||||
]
|
||||
: [
|
||||
fcsIDBox,
|
||||
@@ -464,31 +397,6 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
context,
|
||||
this._cartons,
|
||||
)),
|
||||
// cargoTableTitleBox,
|
||||
// cargoTableBox,
|
||||
// isSmallBag
|
||||
// ? 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,
|
||||
// CupertinoPageRoute(
|
||||
// builder: (context) => DeliveryAddressList(
|
||||
// isAdminCreation: true,
|
||||
// deliveryAddress: _deliveryAddress)));
|
||||
// if (_address == null) return;
|
||||
// setState(() {
|
||||
// _deliveryAddress = _address;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
]),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
@@ -512,52 +420,23 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
List<Widget> _getCartons(BuildContext context, List<Carton> cartons) {
|
||||
return cartons.map((c) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey[300]),
|
||||
),
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
child: CartonRow(
|
||||
key: ValueKey(c.id),
|
||||
box: c,
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding:
|
||||
new EdgeInsets.symmetric(horizontal: 15.0 - 5 / 2),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
children: [
|
||||
Icon(
|
||||
MaterialCommunityIcons.package,
|
||||
color: primaryColor,
|
||||
size: 30,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
c.cartonNumber == null ? "" : c.cartonNumber,
|
||||
style: new TextStyle(fontSize: 15.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).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();
|
||||
@@ -642,30 +521,6 @@ 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 {
|
||||
bool isFromShipment = _selectedCartonType == carton_from_shipments;
|
||||
bool isSmallBag = _selectedCartonType == carton_small_bag;
|
||||
@@ -733,7 +588,10 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
|
||||
isDataChanged() {
|
||||
if (_isNew) {
|
||||
return _fcsShipment != null || _user != null || _cartons.isNotEmpty;
|
||||
return _fcsShipment != null ||
|
||||
_user != null ||
|
||||
_cartons.isNotEmpty ||
|
||||
this._mixCartons.isNotEmpty;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user