update processing
This commit is contained in:
@@ -24,14 +24,7 @@ class ProcessingModel extends BaseModel {
|
||||
processings = [];
|
||||
}
|
||||
|
||||
Future<void> createProcessing(Processing carton) {}
|
||||
Future<void> createProcessing(Processing processing) {}
|
||||
|
||||
Future<void> updateProcessing(Processing carton) {}
|
||||
|
||||
Future<void> createPackage(Package package, List<File> files) {}
|
||||
|
||||
Future<void> updatePackage(
|
||||
Package package, List<File> files, List<String> deletedUrls) {}
|
||||
|
||||
Future<void> deletePackage(String id) {}
|
||||
Future<void> updateProcessing(Processing processing) {}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/market/market_editor.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/main/util.dart';
|
||||
import 'package:fcs/pages/widgets/barcode_scanner.dart';
|
||||
@@ -18,8 +17,6 @@ import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'model/processing_model.dart';
|
||||
|
||||
class PackageEditor extends StatefulWidget {
|
||||
final Package package;
|
||||
PackageEditor({this.package});
|
||||
@@ -36,7 +33,7 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
bool _isLoading = false;
|
||||
bool _isNew;
|
||||
MultiImgController multiImgController = MultiImgController();
|
||||
Package _package;
|
||||
Package _package = Package();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -45,10 +42,11 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
_isNew = false;
|
||||
_package = widget.package;
|
||||
_trackingIDCtl.text = _package.trackingID;
|
||||
multiImgController.setImageUrls = _package.photoUrls;
|
||||
|
||||
selectedMarket = _package.market ?? "";
|
||||
_descCtl.text = _package.desc;
|
||||
_remarkCtl.text = _package.remark;
|
||||
multiImgController.setImageFiles = _package.photoFiles;
|
||||
} else {
|
||||
_isNew = true;
|
||||
}
|
||||
@@ -259,26 +257,20 @@ class _PackageEditorState extends State<PackageEditor> {
|
||||
}
|
||||
|
||||
_selectPackage() async {
|
||||
Package package = Package();
|
||||
package.id = _package.id;
|
||||
package.trackingID = _package.trackingID;
|
||||
package.market = selectedMarket;
|
||||
package.desc = _descCtl.text;
|
||||
package.remark = _remarkCtl.text;
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
ProcessingModel processingModel =
|
||||
Provider.of<ProcessingModel>(context, listen: false);
|
||||
|
||||
try {
|
||||
if (_isNew) {
|
||||
await processingModel.createPackage(
|
||||
package, multiImgController.getAddedFile);
|
||||
} else {
|
||||
await processingModel.updatePackage(package,
|
||||
multiImgController.getAddedFile, multiImgController.getDeletedUrl);
|
||||
}
|
||||
Navigator.pop(context, true);
|
||||
this._package.trackingID = _trackingIDCtl.text;
|
||||
this._package.market = selectedMarket;
|
||||
this._package.desc = _descCtl.text;
|
||||
this._package.remark = _remarkCtl.text;
|
||||
this._package.photoFiles = _isNew
|
||||
? multiImgController.getAddedFile
|
||||
: multiImgController.getUpdatedFile;
|
||||
|
||||
Navigator.pop<Package>(context, this._package);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/package/tracking_id_page.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.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';
|
||||
@@ -22,15 +21,15 @@ import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ProcessingEditor extends StatefulWidget {
|
||||
class ProcessingEditEditor extends StatefulWidget {
|
||||
final Package package;
|
||||
ProcessingEditor({this.package});
|
||||
ProcessingEditEditor({this.package});
|
||||
|
||||
@override
|
||||
_ProcessingEditorState createState() => _ProcessingEditorState();
|
||||
_ProcessingEditEditorState createState() => _ProcessingEditEditorState();
|
||||
}
|
||||
|
||||
class _ProcessingEditorState extends State<ProcessingEditor> {
|
||||
class _ProcessingEditEditorState extends State<ProcessingEditEditor> {
|
||||
TextEditingController _remarkCtl = new TextEditingController();
|
||||
TextEditingController _descCtl = new TextEditingController();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/processing.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton/carton_package_table.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
@@ -50,13 +46,6 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
name: processing.shipperName,
|
||||
phoneNumber: processing.shipperPhoneNumber);
|
||||
packages = processing.packages;
|
||||
} else {
|
||||
packages = [
|
||||
Package(trackingID: "REC 4", market: "New Market"),
|
||||
Package(trackingID: "REC 3", market: "Macy"),
|
||||
Package(trackingID: "REC 2", market: "New Market"),
|
||||
Package(trackingID: "REC 1", market: "New Market")
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +146,12 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.push(
|
||||
Package _package = await Navigator.push<Package>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => PackageEditor()),
|
||||
);
|
||||
_addPackage(_package);
|
||||
// _savePackage(_package);
|
||||
}),
|
||||
],
|
||||
),
|
||||
@@ -172,12 +163,6 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
callack: _save,
|
||||
);
|
||||
|
||||
final updateButton = fcsButton(
|
||||
context,
|
||||
getLocalString(context, 'processing.edit.complete.btn'),
|
||||
callack: _save,
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
@@ -219,7 +204,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
_isNew ? createButton : updateButton,
|
||||
createButton,
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
@@ -238,9 +223,14 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(CupertinoPageRoute(
|
||||
builder: (context) => PackageEditor(package: p)));
|
||||
onTap: () async {
|
||||
Package _package = await Navigator.of(context).push<Package>(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => PackageEditor(package: p)));
|
||||
// setState(() {
|
||||
// _savePackage(_package);
|
||||
// });
|
||||
_savePackage(_package);
|
||||
},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
@@ -276,7 +266,7 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.remove, color: primaryColor),
|
||||
onPressed: () => _remove(p),
|
||||
onPressed: () => _removePackage(p),
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -289,30 +279,22 @@ class _ProcesingEditorState extends State<ProcesingEditor> {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
_remove(Package package) {
|
||||
if (package == null) {
|
||||
showMsgDialog(context, "Esrror", "Invalid package!");
|
||||
return;
|
||||
}
|
||||
showConfirmDialog(context, "processing.package.delete_confirm",
|
||||
() => _removePackage(package));
|
||||
_addPackage(Package package) {
|
||||
if (package == null) return;
|
||||
|
||||
this.packages.add(package);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_removePackage(Package package) async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
ProcessingModel processingModel =
|
||||
Provider.of<ProcessingModel>(context, listen: false);
|
||||
try {
|
||||
await processingModel.deletePackage(package.id);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
_savePackage(Package package) {
|
||||
if (package == null) return;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_removePackage(Package package) {
|
||||
if (package == null) return;
|
||||
this.packages.removeWhere((p) => p.trackingID == package.trackingID);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_save() async {
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'processing_editor_old.dart';
|
||||
import 'processing_edit_editor.dart';
|
||||
|
||||
final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
|
||||
@@ -179,7 +179,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
bool deleted = await Navigator.push<bool>(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => ProcessingEditor(
|
||||
builder: (context) => ProcessingEditEditor(
|
||||
package: widget.package,
|
||||
)));
|
||||
if (deleted ?? false) {
|
||||
|
||||
Reference in New Issue
Block a user