update carton and cargo type
This commit is contained in:
@@ -23,17 +23,20 @@ class PackageModel extends BaseModel {
|
||||
PaginatorListener<Package>? activePackages;
|
||||
|
||||
bool isLoading = false;
|
||||
int selectedIndex = 1;
|
||||
int selectedIndexForCustomer = 1;
|
||||
int selectedIndex = 0;
|
||||
|
||||
initData(int index, bool isCustomer) {
|
||||
selectedIndex = index;
|
||||
if (isCustomer) {
|
||||
_loadPaginationCustomerPackages(selectedIndex == 2);
|
||||
} else {
|
||||
_loadPaginationPackages(selectedIndex == 2);
|
||||
}
|
||||
initDataForCustomer(int index) {
|
||||
selectedIndexForCustomer = index;
|
||||
_loadPaginationCustomerPackages(selectedIndexForCustomer == 2);
|
||||
}
|
||||
|
||||
initData(int index) {
|
||||
selectedIndex = index;
|
||||
_loadPaginationPackages(selectedIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
void privilegeChanged() {
|
||||
if (user != null) {
|
||||
_loadPaginationActivePackages();
|
||||
@@ -47,30 +50,57 @@ class PackageModel extends BaseModel {
|
||||
if (activePackages != null) activePackages!.close();
|
||||
}
|
||||
|
||||
onChanged(int index, bool isCustomer) {
|
||||
selectedIndex = index;
|
||||
if (isCustomer) {
|
||||
_loadPaginationCustomerPackages(selectedIndex == 2);
|
||||
} else {
|
||||
_loadPaginationPackages(selectedIndex == 2);
|
||||
}
|
||||
onChangedForCustomer(int index) {
|
||||
selectedIndexForCustomer = index;
|
||||
_loadPaginationCustomerPackages(selectedIndexForCustomer == 2);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
_loadPaginationPackages(bool isDelivered) {
|
||||
_loadPaginationPackages(int index) {
|
||||
if (user == null) return;
|
||||
if (!((user!.hasPackages() ||
|
||||
user!.hasReceiving() ||
|
||||
user!.hasProcessing()))) return;
|
||||
user!.hasProcessing()))) {
|
||||
return;
|
||||
}
|
||||
String path = "/$packages_collection";
|
||||
|
||||
Query col = FirebaseFirestore.instance
|
||||
.collection(path)
|
||||
.where("is_delivered", isEqualTo: isDelivered);
|
||||
Query pageQuery = FirebaseFirestore.instance
|
||||
.collection(path)
|
||||
.where("is_delivered", isEqualTo: isDelivered)
|
||||
.orderBy("update_time", descending: true);
|
||||
Query col = FirebaseFirestore.instance.collection(path);
|
||||
Query pageQuery = FirebaseFirestore.instance.collection(path);
|
||||
|
||||
// received status
|
||||
if (index == 1) {
|
||||
col = col.where("status", isEqualTo: package_received_status);
|
||||
pageQuery = pageQuery.where("status", isEqualTo: package_received_status);
|
||||
}
|
||||
|
||||
// processed status
|
||||
if (index == 2) {
|
||||
col = col.where("status", isEqualTo: package_processed_status);
|
||||
pageQuery =
|
||||
pageQuery.where("status", isEqualTo: package_processed_status);
|
||||
}
|
||||
|
||||
// packed status
|
||||
if (index == 3) {
|
||||
col = col.where("status", isEqualTo: package_packed_status);
|
||||
pageQuery = pageQuery.where("status", isEqualTo: package_packed_status);
|
||||
}
|
||||
|
||||
// shipped status
|
||||
if (index == 4) {
|
||||
col = col.where("status", isEqualTo: package_shipped_status);
|
||||
pageQuery = pageQuery.where("status", isEqualTo: package_shipped_status);
|
||||
}
|
||||
|
||||
// delivered status
|
||||
if (index == 5) {
|
||||
col = col.where("status", isEqualTo: package_delivered_status);
|
||||
pageQuery =
|
||||
pageQuery.where("status", isEqualTo: package_delivered_status);
|
||||
}
|
||||
|
||||
pageQuery = pageQuery.orderBy("update_time", descending: true);
|
||||
|
||||
packages?.close();
|
||||
packages = PaginatorListener<Package>(
|
||||
@@ -78,6 +108,12 @@ class PackageModel extends BaseModel {
|
||||
rowPerLoad: 30);
|
||||
}
|
||||
|
||||
onChanged(int index) {
|
||||
selectedIndex = index;
|
||||
_loadPaginationPackages(index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
_loadPaginationCustomerPackages(bool isDelivered) {
|
||||
if (user == null) return;
|
||||
String path = "/$packages_collection";
|
||||
@@ -102,7 +138,9 @@ class PackageModel extends BaseModel {
|
||||
if (user == null) return;
|
||||
if (!((user!.hasPackages() ||
|
||||
user!.hasReceiving() ||
|
||||
user!.hasProcessing()))) return;
|
||||
user!.hasProcessing()))) {
|
||||
return;
|
||||
}
|
||||
String path = "/$packages_collection";
|
||||
|
||||
Query col = FirebaseFirestore.instance
|
||||
@@ -142,7 +180,7 @@ class PackageModel extends BaseModel {
|
||||
String path = "/$packages_collection";
|
||||
try {
|
||||
var snaps = await FirebaseFirestore.instance
|
||||
.collection("$path")
|
||||
.collection(path)
|
||||
.where("tracking_id", isEqualTo: trackingID)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.get(const GetOptions(source: Source.server));
|
||||
|
||||
Reference in New Issue
Block a user