add package return
This commit is contained in:
@@ -499,6 +499,8 @@
|
||||
"receiving.create_btn":"Complete receiving",
|
||||
"receiving.update_btn":"Update reveiving",
|
||||
"receiving.delete.confirm":"Delete this receiving?",
|
||||
"receiving.return.btn":"Return package",
|
||||
"receiving.return.confirm":"Return package?",
|
||||
"Receiving End ================================================================":"",
|
||||
|
||||
"Processing Start ================================================================":"",
|
||||
|
||||
@@ -497,6 +497,8 @@
|
||||
"receiving.create_btn":"လက်ခံမည်",
|
||||
"receiving.update_btn":"ပြင်ဆင်မည်",
|
||||
"receiving.delete.confirm":"လက်ခံခြင်းကို ဖျက်မလား?",
|
||||
"receiving.return.btn":"ပစ္စည်း ပြန်ပို့မည်",
|
||||
"receiving.return.confirm":"ပစ္စည်းကို ပြန်ပို့မလား?",
|
||||
"Receiving End ================================================================":"",
|
||||
|
||||
"Processing Start ================================================================":"",
|
||||
|
||||
@@ -48,6 +48,14 @@ class PackageDataProvider {
|
||||
token: await getToken());
|
||||
}
|
||||
|
||||
Future<void> packageReturn(String packageID) async {
|
||||
return await requestAPI("/packages/return", "PUT",
|
||||
payload: {
|
||||
"id": packageID,
|
||||
},
|
||||
token: await getToken());
|
||||
}
|
||||
|
||||
Future<List<Package>> searchPackage(String term) async {
|
||||
if (term == null || term == '') return List();
|
||||
|
||||
|
||||
@@ -53,4 +53,9 @@ class PackageServiceImp implements PackageService {
|
||||
Future<void> changeDeliveryAddress(String packageID, String deliveryID) {
|
||||
return packageDataProvider.changeDeliveryAddress(packageID, deliveryID);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> packageReturn(String packageID) {
|
||||
return packageDataProvider.packageReturn(packageID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ abstract class PackageService {
|
||||
Future<void> deleteProcessing(Package package);
|
||||
Future<List<Package>> searchPackage(String term);
|
||||
Future<void> changeDeliveryAddress(String packageID, String deliveryID);
|
||||
Future<void> packageReturn(String packageID);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ class Package {
|
||||
String fcsID;
|
||||
String userName;
|
||||
String phoneNumber;
|
||||
String currentStatus;
|
||||
DateTime currentStatusDate;
|
||||
List<String> photoUrls;
|
||||
List<ShipmentStatus> shipmentHistory;
|
||||
@@ -68,7 +67,6 @@ class Package {
|
||||
this.cargoDesc,
|
||||
this.market,
|
||||
this.shipmentHistory,
|
||||
this.currentStatus,
|
||||
this.currentStatusDate,
|
||||
this.photoUrls,
|
||||
this.desc,
|
||||
@@ -96,7 +94,7 @@ class Package {
|
||||
phoneNumber: map['phone_number'],
|
||||
remark: map['remark'],
|
||||
desc: map['desc'],
|
||||
currentStatus: map['status'],
|
||||
status: map['status'],
|
||||
deliveryAddress: _da,
|
||||
currentStatusDate:
|
||||
_currentStatusDate != null ? _currentStatusDate.toDate() : null,
|
||||
@@ -121,12 +119,12 @@ class Package {
|
||||
market: json['market'],
|
||||
userName: json['user_name'],
|
||||
phoneNumber: json['phone_number'],
|
||||
currentStatus: json['status'],
|
||||
status: json['status'],
|
||||
currentStatusDate: DateTime.parse(json['status_date']));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Package{id: $id, currentStatus: $currentStatus, market:$market, trackingID: $trackingID,}';
|
||||
return 'Package{id: $id, status: $status, market:$market, trackingID: $trackingID,}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,6 @@ class PackageModel extends BaseModel {
|
||||
return Package(
|
||||
id: m.id,
|
||||
status: package_delivered_status,
|
||||
currentStatus: package_delivered_status,
|
||||
currentStatusDate: m.date,
|
||||
trackingID: (count++).toString(),
|
||||
market: m.message);
|
||||
});
|
||||
@@ -310,4 +308,8 @@ class PackageModel extends BaseModel {
|
||||
return Services.instance.packageService
|
||||
.changeDeliveryAddress(package.id, deliveryAddress.id);
|
||||
}
|
||||
|
||||
Future<void> packageReturn(Package package) {
|
||||
return Services.instance.packageService.packageReturn(package.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
|
||||
iconData: MaterialCommunityIcons.barcode_scan,
|
||||
);
|
||||
final statusBox = DisplayText(
|
||||
text: _package.currentStatus,
|
||||
text: _package.status,
|
||||
labelTextKey: "package.edit.status",
|
||||
iconData: AntDesign.exclamationcircleo,
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
@@ -9,6 +10,7 @@ import 'package:fcs/pages/widgets/defalut_delivery_address.dart';
|
||||
import 'package:fcs/pages/widgets/delivery_address_selection.dart';
|
||||
import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_file.dart';
|
||||
@@ -25,6 +27,7 @@ final DateFormat dateFormat = DateFormat("d MMM yyyy");
|
||||
class PackageInfo extends StatefulWidget {
|
||||
final isSearchResult;
|
||||
final Package package;
|
||||
|
||||
PackageInfo({this.package, this.isSearchResult = false});
|
||||
|
||||
@override
|
||||
@@ -95,6 +98,11 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
controller: multiImgController,
|
||||
title: "Receipt File",
|
||||
);
|
||||
|
||||
final returnButton = LocalButton(
|
||||
textKey: "receiving.return.btn",
|
||||
callBack: _return,
|
||||
);
|
||||
final deliveryAddressBox = DefaultDeliveryAddress(
|
||||
deliveryAddress: _package.deliveryAddress,
|
||||
labelKey: "package.delivery.address",
|
||||
@@ -145,12 +153,15 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
_package.photoUrls.length == 0 ? Container() : img,
|
||||
widget.isSearchResult ? Container() : descBox,
|
||||
remarkBox,
|
||||
_package.status == package_processed_status
|
||||
? returnButton
|
||||
: Container(),
|
||||
widget.isSearchResult ? Container() : deliveryAddressBox,
|
||||
widget.isSearchResult
|
||||
? Container()
|
||||
: StatusTree(
|
||||
shipmentHistory: _package.shipmentHistory,
|
||||
currentStatus: _package.currentStatus),
|
||||
currentStatus: _package.status),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
@@ -188,4 +199,26 @@ class _PackageInfoState extends State<PackageInfo> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_return() {
|
||||
showConfirmDialog(context, "receiving.return.confirm", _returnReceiving);
|
||||
}
|
||||
|
||||
_returnReceiving() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
PackageModel packageModel =
|
||||
Provider.of<PackageModel>(context, listen: false);
|
||||
await packageModel.packageReturn(_package);
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class PackageListRow extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: getStatus(package.currentStatus),
|
||||
child: getStatus(package.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
|
||||
@@ -140,7 +140,7 @@ class _ProcessingInfoState extends State<ProcessingInfo> {
|
||||
_package.photoUrls.length == 0 ? Container() : img,
|
||||
StatusTree(
|
||||
shipmentHistory: _package.shipmentHistory,
|
||||
currentStatus: _package.currentStatus),
|
||||
currentStatus: _package.status),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
|
||||
@@ -81,7 +81,7 @@ class ProcessingListRow extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: getStatus(package.currentStatus),
|
||||
child: getStatus(package.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
|
||||
@@ -3,10 +3,9 @@ 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/package/model/package_model.dart';
|
||||
import 'package:fcs/pages/package/package_editor.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/local_button.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_controller.dart';
|
||||
import 'package:fcs/pages/widgets/multi_img_file.dart';
|
||||
@@ -17,8 +16,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeline_list/timeline.dart';
|
||||
import 'package:timeline_list/timeline_model.dart';
|
||||
|
||||
import 'receiving_editor.dart';
|
||||
|
||||
@@ -129,7 +126,7 @@ class _ReceivingInfoState extends State<ReceivingInfo> {
|
||||
_package.photoUrls.length == 0 ? Container() : img,
|
||||
StatusTree(
|
||||
shipmentHistory: _package.shipmentHistory,
|
||||
currentStatus: _package.currentStatus),
|
||||
currentStatus: _package.status),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
|
||||
@@ -79,7 +79,7 @@ class ReceivingListRow extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: getStatus(package.currentStatus),
|
||||
child: getStatus(package.status),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(0),
|
||||
|
||||
Reference in New Issue
Block a user