add shipment in processing, update package, processing and receiving
This commit is contained in:
@@ -5,8 +5,6 @@ import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_search.dart';
|
||||
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/input_text.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
@@ -16,11 +14,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
typedef void FindCallBack();
|
||||
|
||||
class ReceivingEditor extends StatefulWidget {
|
||||
final Package? package;
|
||||
const ReceivingEditor({this.package});
|
||||
const ReceivingEditor({super.key, this.package});
|
||||
@override
|
||||
_ReceivingEditorState createState() => _ReceivingEditorState();
|
||||
}
|
||||
@@ -29,8 +25,8 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
Package package = Package();
|
||||
bool _isLoading = false;
|
||||
late bool _isNew;
|
||||
User? user;
|
||||
final _receiveFormKey=GlobalKey<FormState>();
|
||||
User? _consignee;
|
||||
final _receiveFormKey = GlobalKey<FormState>();
|
||||
TextEditingController _trackingIDCtl = new TextEditingController();
|
||||
TextEditingController _remarkCtl = new TextEditingController();
|
||||
MultiImgController _multiImgController = MultiImgController();
|
||||
@@ -44,12 +40,12 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
_trackingIDCtl.text = package.trackingID!;
|
||||
_remarkCtl.text = package.remark!;
|
||||
_multiImgController.setImageUrls = package.photoUrls;
|
||||
user = User(
|
||||
_consignee = User(
|
||||
fcsID: package.fcsID,
|
||||
name: package.userName,
|
||||
phoneNumber: package.phoneNumber);
|
||||
} else {
|
||||
package = new Package();
|
||||
package = Package();
|
||||
}
|
||||
_trackingIDCtl.addListener(() {
|
||||
var text = _trackingIDCtl.text;
|
||||
@@ -66,24 +62,6 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var fcsIDBox = Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: DisplayText(
|
||||
text: user != null ? user!.fcsID : "",
|
||||
labelTextKey: "receiving.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search, color: primaryColor),
|
||||
onPressed: () => searchUser(context, onUserSelect: (u) {
|
||||
setState(() {
|
||||
this.user = u;
|
||||
});
|
||||
}, popPage: true)),
|
||||
],
|
||||
);
|
||||
|
||||
final trackingIDBox = Container(
|
||||
padding: EdgeInsets.only(left: 6),
|
||||
child: Row(
|
||||
@@ -95,13 +73,12 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
labelTextKey: "receiving.tracking.id",
|
||||
controller: _trackingIDCtl,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (value){
|
||||
if(value==null || value.isEmpty){
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "invalid tracking ID";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
)),
|
||||
InkWell(
|
||||
onTap: _scan,
|
||||
@@ -130,11 +107,6 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
controller: _multiImgController,
|
||||
title: "Receiving",
|
||||
);
|
||||
final namebox = DisplayText(
|
||||
text: user != null ? user!.name : "",
|
||||
labelTextKey: "receiving.consignee.name",
|
||||
iconData: Icons.person,
|
||||
);
|
||||
|
||||
final createButton = fcsButton(
|
||||
context,
|
||||
@@ -148,6 +120,17 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
callack: _save,
|
||||
);
|
||||
|
||||
final consigneeBox = userSearchBox(context,
|
||||
lableKey: 'box.consignee.title',
|
||||
icon: MaterialCommunityIcons.account_arrow_left,
|
||||
rowMainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
user: _consignee,
|
||||
onSearch: () => searchUser(context, onUserSelect: (u) {
|
||||
setState(() {
|
||||
_consignee = u;
|
||||
});
|
||||
}, popPage: true));
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -183,11 +166,8 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
fcsIDBox,
|
||||
namebox,
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
consigneeBox,
|
||||
SizedBox(height: 20),
|
||||
_isNew ? createButton : updateButton,
|
||||
SizedBox(
|
||||
height: 10,
|
||||
@@ -236,8 +216,8 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
showMsgDialog(context, "Error", "Please select FCS ID");
|
||||
if (_consignee == null) {
|
||||
showMsgDialog(context, "Error", "Please select consignee");
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
@@ -248,12 +228,12 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
try {
|
||||
if (_isNew) {
|
||||
await packageModel.createReceiving(
|
||||
user!, _p, _multiImgController.getAddedFile);
|
||||
_consignee!, _p, _multiImgController.getAddedFile);
|
||||
} else {
|
||||
_p.id = widget.package!.id;
|
||||
_p.photoUrls = package.photoUrls;
|
||||
await packageModel.updateReceiving(
|
||||
user!,
|
||||
_consignee!,
|
||||
_p,
|
||||
_multiImgController.getAddedFile,
|
||||
_multiImgController.getDeletedUrl);
|
||||
@@ -272,15 +252,15 @@ class _ReceivingEditorState extends State<ReceivingEditor> {
|
||||
if (_isNew) {
|
||||
return _trackingIDCtl.text != "" ||
|
||||
_remarkCtl.text != "" ||
|
||||
user != null ||
|
||||
_consignee != null ||
|
||||
_multiImgController.getAddedFile.isNotEmpty;
|
||||
} else {
|
||||
var _package = Package(
|
||||
var package = Package(
|
||||
trackingID: _trackingIDCtl.text,
|
||||
remark: _remarkCtl.text,
|
||||
fcsID: user!.fcsID,
|
||||
fcsID: _consignee!.fcsID,
|
||||
photoUrls: widget.package!.photoUrls);
|
||||
return widget.package!.isChangedForEdit(_package) ||
|
||||
return widget.package!.isChangedForEditReceiving(package) ||
|
||||
_multiImgController.getAddedFile.isNotEmpty ||
|
||||
_multiImgController.getDeletedUrl.isNotEmpty;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_file.dart';
|
||||
@@ -61,16 +60,13 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
||||
labelTextKey: "package.tracking.id",
|
||||
iconData: MaterialCommunityIcons.barcode_scan,
|
||||
);
|
||||
var fcsIDBox = DisplayText(
|
||||
text: _package!.fcsID,
|
||||
labelTextKey: "processing.fcs.id",
|
||||
icon: FcsIDIcon(),
|
||||
);
|
||||
final customerNameBox = DisplayText(
|
||||
text: _package!.userName,
|
||||
labelTextKey: "package.create.name",
|
||||
iconData: Icons.perm_identity,
|
||||
);
|
||||
|
||||
final consigneeBox = userDisplayBox(context,
|
||||
lableKey: "box.consignee.title",
|
||||
icon: MaterialCommunityIcons.account_arrow_left,
|
||||
name: _package?.userName ?? "",
|
||||
fcsID: _package?.fcsID ?? "");
|
||||
|
||||
final remarkBox = DisplayText(
|
||||
text: _package!.remark ?? "-",
|
||||
labelTextKey: "package.edit.remark",
|
||||
@@ -112,16 +108,21 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(children: <Widget>[
|
||||
trackingIdBox,
|
||||
fcsIDBox,
|
||||
customerNameBox,
|
||||
consigneeBox,
|
||||
remarkBox,
|
||||
_package!.photoUrls.length == 0 ? Container() : img,
|
||||
StatusTree(
|
||||
shipmentHistory: _package!.shipmentHistory,
|
||||
currentStatus: _package!.status),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
_package!.photoUrls.isEmpty
|
||||
? Container()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: img,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: StatusTree(
|
||||
shipmentHistory: _package!.shipmentHistory,
|
||||
currentStatus: _package!.status),
|
||||
),
|
||||
SizedBox(height: 20)
|
||||
]),
|
||||
)),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user