update carton info

This commit is contained in:
tzw
2024-02-09 12:21:49 +06:30
parent aa5b7881d6
commit 62c0da8a96

View File

@@ -60,8 +60,8 @@ class _CartonInfoState extends State<CartonInfo> {
bool isFromPackages = false; bool isFromPackages = false;
bool isSmallBag = false; bool isSmallBag = false;
bool isFromCartons = false; bool isFromCartons = false;
bool isEdiable = false;
bool isCutomDuty=false; bool isCutomDuty = false;
final List<CargoType> cargoTypes = []; final List<CargoType> cargoTypes = [];
final List<CargoType> surchareItems = []; final List<CargoType> surchareItems = [];
final List<Carton> cartons = []; final List<Carton> cartons = [];
@@ -71,9 +71,6 @@ class _CartonInfoState extends State<CartonInfo> {
super.initState(); super.initState();
_box = widget.box; _box = widget.box;
_box?.billToValue = "Bill to sender"; _box?.billToValue = "Bill to sender";
//initPackage(widget.package!); //initPackage(widget.package!);
//for shipment weight //for shipment weight
@@ -100,8 +97,6 @@ class _CartonInfoState extends State<CartonInfo> {
isSmallBag = _box!.cartonType == carton_small_bag; isSmallBag = _box!.cartonType == carton_small_bag;
isFromCartons = _box!.cartonType == carton_from_cartons; isFromCartons = _box!.cartonType == carton_from_cartons;
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
_box!.status == carton_packed_status;
selectMixBoxType = _box!.mixBoxType; selectMixBoxType = _box!.mixBoxType;
getCartonSize(); getCartonSize();
} }
@@ -337,70 +332,7 @@ class _CartonInfoState extends State<CartonInfo> {
controller: multiImgController, controller: multiImgController,
title: "Receipt File", title: "Receipt File",
); );
final consigneeBox=Container(
child: Padding(
padding: const EdgeInsets.only(left: 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
consigneeNameBox,
],
),
),
_cartonSubmit?.billToValue == billToSender
? Expanded(
child: Padding(
padding: EdgeInsets.only(left: 0, top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Ionicons.document_text_outline,
color: primaryColor, size: 20),
Text("Bill to",
style: TextStyle(
color: primaryColor, fontSize: 15))
],
)))
: const SizedBox()
],
),
));
final customerBox= Container(
child: Row(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
customerNameBox,
],
),
),
_box?.billToValue == billToSender
? Expanded(
child: Padding(
padding: EdgeInsets.only(left: 0, top: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Ionicons.document_text_outline,
color: primaryColor, size: 20),
Text("Bill to",
style: TextStyle(
color: primaryColor, fontSize: 15))
],
)))
: const SizedBox()
],
),
);
final billWidget = Expanded( final billWidget = Expanded(
child: Padding( child: Padding(
padding: EdgeInsets.only(left: 0, top: 15), padding: EdgeInsets.only(left: 0, top: 15),
@@ -418,23 +350,15 @@ class _CartonInfoState extends State<CartonInfo> {
inAsyncCall: _isLoading, inAsyncCall: _isLoading,
child: Scaffold( child: Scaffold(
appBar: LocalAppBar( appBar: LocalAppBar(
labelKey: "box.info.title", labelKey: "box.info.title",
backgroundColor: Colors.white, backgroundColor: Colors.white,
labelColor: primaryColor, labelColor: primaryColor,
arrowColor: primaryColor, arrowColor: primaryColor,
actions: isEdiable actions: <Widget>[
? <Widget>[ IconButton(
IconButton( icon: Icon(Icons.edit, color: primaryColor),
icon: Icon(Icons.edit, color: primaryColor), onPressed: _gotoEditor),
onPressed: _gotoEditor, ]),
),
IconButton(
icon: Icon(Icons.delete, color: primaryColor),
onPressed: _delete,
),
]
: [],
),
body: Container( body: Container(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: ListView(children: <Widget>[ child: ListView(children: <Widget>[
@@ -458,79 +382,81 @@ class _CartonInfoState extends State<CartonInfo> {
// isMixBox // isMixBox
// ? // ?
// displayMixBox:Container(), // displayMixBox:Container(),
isMixBox?
Row( isMixBox
mainAxisAlignment: MainAxisAlignment.start, ? Row(
children: [ mainAxisAlignment: MainAxisAlignment.start,
Expanded(
child: Row(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Expanded(
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, //crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
customerNameBox, Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
customerNameBox,
],
),
),
_box?.billToValue == billToSender
? billWidget
: const SizedBox(
height: 300.0,
)
], ],
), ),
), ),
_box?.billToValue == billToSender
? billWidget
: const SizedBox( height: 300.0,)
],
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded( Expanded(
child: Column( child: Padding(
padding: const EdgeInsets.only(left: 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
consigneeNameBox, Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
consigneeNameBox,
],
),
),
_cartonSubmit?.billToValue == billToSender
? billWidget
: const SizedBox()
], ],
), ),
))
],
)
// ,
// Row(
// children: getPackageList(_box!.packages),
// ),
// ])
: Container(),
isMixBox
? Column(
children: [
packageBox,
Row(
children: getPackageList(_box!.packages),
),
],
)
: Column(
children: [
cartonBox,
Row(
children: getCartonList(_box!.mixCartons),
), ),
_cartonSubmit?.billToValue == billToSender
? billWidget
: const SizedBox()
], ],
), ),
)) isCutomDuty ? surchargeItemBox : cargosBox,
],
)
// ,
// Row(
// children: getPackageList(_box!.packages),
// ),
// ])
:Container(),
isMixBox ?
Column(children: [
packageBox,
Row(
children: getPackageList(_box!.packages),
),
],):Column(
children: [
cartonBox,
Row(
children: getCartonList(_box!.mixCartons),
),
],
),
isCutomDuty
?
surchargeItemBox:
cargosBox,
Padding( Padding(
padding: EdgeInsets.only(left: 200.0, right: 8.0), padding: EdgeInsets.only(left: 200.0, right: 8.0),
child: ElevatedButton( child: ElevatedButton(
@@ -571,20 +497,19 @@ class _CartonInfoState extends State<CartonInfo> {
} }
_gotoEditor() async { _gotoEditor() async {
_box!.mixCartons = _box!.mixCartons;
bool? updated = await Navigator.push<bool>( bool? updated = await Navigator.push<bool>(
context, context,
CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)), CupertinoPageRoute(builder: (context) => CartonEditor(carton: _box)),
); );
if (updated ?? false) { if (updated ?? false) {
var cartonModel = Provider.of<CartonModel>(context, listen: false); // var cartonModel = Provider.of<CartonModel>(context, listen: false);
var c = await cartonModel.getCarton(widget.box.id ?? ""); // var c = await cartonModel.getCarton(widget.box.id ?? "");
setState(() { // setState(() {
_box = c; // _box = c;
_loadPackages(); // _loadPackages();
_loadMixCartons(); // _loadMixCartons();
_updateBoxData(); // _updateBoxData();
}); // });
} }
} }
@@ -622,7 +547,8 @@ class _CartonInfoState extends State<CartonInfo> {
)); ));
}).toList(); }).toList();
} }
List<Widget> getCartonList(List<Carton> _c) {
List<Widget> getCartonList(List<Carton> _c) {
return _c.map((c) { return _c.map((c) {
return Container( return Container(
padding: EdgeInsets.only(top: 0), padding: EdgeInsets.only(top: 0),