feat : search and filter
This commit is contained in:
@@ -16,12 +16,10 @@ class GenocideLogic extends GetxController {
|
||||
|
||||
final RxBool isLoadingMore = false.obs;
|
||||
|
||||
Rx<Jalali> fromDateFilter = Jalali
|
||||
.now()
|
||||
.obs;
|
||||
Rx<Jalali> toDateFilter = Jalali
|
||||
.now()
|
||||
.obs;
|
||||
final RxBool isLoadingDelete = false.obs;
|
||||
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
/* final RxBool isLoadingMoreAllocationsMade = false.obs;
|
||||
@@ -52,20 +50,19 @@ class GenocideLogic extends GetxController {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
await safeCall(
|
||||
call: () =>
|
||||
rootLogic.poultryRepository.getPoultryOderList(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
pageSize: 20,
|
||||
page: currentPage.value,
|
||||
search: 'filter',
|
||||
role: gService.getRole(Module.chicken),
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
queryParams: {'today': null}
|
||||
),
|
||||
),
|
||||
call: () async => await rootLogic.poultryRepository.getPoultryOderList(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
pageSize: 20,
|
||||
page: currentPage.value,
|
||||
search: 'filter',
|
||||
role: gService.getRole(Module.chicken),
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
queryParams: {'today': null},
|
||||
),
|
||||
),
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
@@ -83,4 +80,19 @@ class GenocideLogic extends GetxController {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> deletePoultryOrder(int id) async {
|
||||
isExpandedList.clear();
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.deletePoultryOder(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
orderId: id.toString(),
|
||||
),
|
||||
onSuccess: (_) {
|
||||
defaultShowSuccessMessage('درخواست با موفقیت حذف شد');
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:rasadyar_chicken/data/models/response/poultry_order/poultry_orde
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
@@ -14,8 +15,13 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
Widget build(BuildContext context) {
|
||||
return BasePage(
|
||||
routes: controller.routes,
|
||||
hasSearch: false,
|
||||
hasFilter: false,
|
||||
hasSearch: true,
|
||||
hasFilter: true,
|
||||
onSearchChanged: (data) {
|
||||
controller.searchedValue.value = data;
|
||||
controller.getPoultryOrderList();
|
||||
},
|
||||
filteringWidget: filterBottomSheet(),
|
||||
onBackPressed: () => Get.back(id: poultryFirstKey),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
|
||||
floatingActionButton: RFab.add(
|
||||
@@ -128,8 +134,41 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
|
||||
buildRow(title: 'میانگین وزنی', value: '${(item.indexWeight)} (کیلوگرم)'),
|
||||
buildRow(title: 'قیمت مرغدار', value: '${item.amount.separatedByComma} (ریال)'),
|
||||
buildRow(title: 'مانده در سالن ', value: '${item.hatching?.leftOver.separatedByComma ?? 0} (قطعه)'),
|
||||
buildRow(
|
||||
title: 'مانده در سالن ',
|
||||
value: '${item.hatching?.leftOver.separatedByComma ?? 0} (قطعه)',
|
||||
),
|
||||
buildRow(title: ' وضعیت', value: getState(item)),
|
||||
|
||||
Visibility(
|
||||
visible: item.stateProcess == 'pending',
|
||||
child: ObxValue((data) {
|
||||
return ROutlinedElevatedIcon(
|
||||
height: 40.h,
|
||||
width: Get.width,
|
||||
text: 'حذف',
|
||||
icon: Assets.vec.trashSvg.svg(
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.error, BlendMode.srcIn),
|
||||
),
|
||||
textStyle: AppFonts.yekan16Bold.copyWith(color: AppColor.error),
|
||||
borderColor: AppColor.error,
|
||||
foregroundColor: AppColor.error,
|
||||
pressedBackgroundColor: AppColor.error,
|
||||
onPressed: data.value
|
||||
? null
|
||||
: () => _buildDeleteDialog(
|
||||
onConfirm: () async {
|
||||
Get.back();
|
||||
await controller.deletePoultryOrder(item.id!);
|
||||
controller.getPoultryOrderList();
|
||||
|
||||
},
|
||||
),
|
||||
);
|
||||
}, controller.isLoadingDelete),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -191,32 +230,63 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String getRequestType(PoultryOrder item) {
|
||||
if (item.market ?? false) {
|
||||
return 'پنل معاملات';
|
||||
} else if (item.union ?? false) {
|
||||
return 'اتحادیه';
|
||||
} else {
|
||||
return 'خرید مستقیم';
|
||||
String getRequestType(PoultryOrder item) {
|
||||
if (item.market ?? false) {
|
||||
return 'پنل معاملات';
|
||||
} else if (item.union ?? false) {
|
||||
return 'اتحادیه';
|
||||
} else {
|
||||
return 'خرید مستقیم';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getKillType(PoultryOrder item) {
|
||||
if (item.export ?? false) {
|
||||
return 'صادرات';
|
||||
} else if (item.freezing ?? false) {
|
||||
return 'انجماد';
|
||||
} else {
|
||||
return 'عادی';
|
||||
String getKillType(PoultryOrder item) {
|
||||
if (item.export ?? false) {
|
||||
return 'صادرات';
|
||||
} else if (item.freezing ?? false) {
|
||||
return 'انجماد';
|
||||
} else {
|
||||
return 'عادی';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getState(PoultryOrder item) {
|
||||
if (item.stateProcess == 'pending') {
|
||||
return 'در انتظار تایید';
|
||||
} else {
|
||||
return 'تایید شده';
|
||||
String getState(PoultryOrder item) {
|
||||
if (item.stateProcess == 'pending') {
|
||||
return 'در انتظار تایید';
|
||||
} else {
|
||||
return 'تایید شده';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _buildDeleteDialog({required VoidCallback onConfirm}) {
|
||||
Get.defaultDialog(
|
||||
title: 'حذف درخواست کشتار',
|
||||
middleText: 'آیا از حذف این درخواست کشتار مطمئن هستید؟',
|
||||
confirm: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.error,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: onConfirm,
|
||||
child: Text('بله'),
|
||||
),
|
||||
cancel: ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Text('خیر'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget filterBottomSheet() => filterBottomSheetWidget(
|
||||
fromDate: controller.fromDateFilter,
|
||||
onChangedFromDate: (jalali) => controller.fromDateFilter.value = jalali,
|
||||
toDate: controller.toDateFilter,
|
||||
onChangedToDate: (jalali) => controller.toDateFilter.value = jalali,
|
||||
onSubmit: () => controller.getPoultryOrderList(),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -349,9 +349,14 @@ class KillingRegistrationLogic extends GetxController {
|
||||
onSuccess: (result) async {
|
||||
defaultShowSuccessMessage(
|
||||
'ثبت با موفقیت انجام شد',
|
||||
onDismissed: () {
|
||||
Get.back(id: poultryFirstKey);
|
||||
durationInSeconds: 2,
|
||||
onDismissed: () async {
|
||||
fLog('Kill Registration onDismissed');
|
||||
Future.delayed(Duration(milliseconds: 300), () {
|
||||
Get.back(id: poultryFirstKey);
|
||||
});
|
||||
},
|
||||
|
||||
);
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
|
||||
Reference in New Issue
Block a user