fix : has more in list

This commit is contained in:
2025-07-08 12:17:39 +03:30
parent 8b656d4915
commit a9b012b016
5 changed files with 108 additions and 102 deletions

View File

@@ -18,6 +18,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
return RPaginatedListView( return RPaginatedListView(
listType: ListType.separated, listType: ListType.separated,
resource: data.value, resource: data.value,
hasMore: data.value.data?.next!= null,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80), padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
itemBuilder: (context, index) { itemBuilder: (context, index) {
var item = data.value.data!.results![index]; var item = data.value.data!.results![index];

View File

@@ -58,10 +58,8 @@ class BuyOutOfProvinceLogic extends GetxController {
super.onReady(); super.onReady();
getStewardPurchaseOutOfProvince(); getStewardPurchaseOutOfProvince();
selectedProvince.listen((p0) => getCites()); selectedProvince.listen((p0) => getCites());
outOfTheProvinceLogic.rolesProductsModel.listen((lists) {
selectedProduct.value = lists.first;
});
selectedProduct.value = outOfTheProvinceLogic.rolesProductsModel.first;
setupListeners(); setupListeners();
debounce( debounce(
@@ -101,7 +99,7 @@ class BuyOutOfProvinceLogic extends GetxController {
call: () => rootLogic.chickenRepository.getStewardPurchasesOutSideOfTheProvince( call: () => rootLogic.chickenRepository.getStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!, token: rootLogic.tokenService.accessToken.value!,
queryParameters: buildQueryParams( queryParameters: buildQueryParams(
pageSize: 10, pageSize: 20,
page: currentPage.value, page: currentPage.value,
search: 'filter', search: 'filter',
role: 'Steward', role: 'Steward',

View File

@@ -30,6 +30,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
return RPaginatedListView( return RPaginatedListView(
listType: ListType.separated, listType: ListType.separated,
resource: data.value, resource: data.value,
hasMore:data.value.data?.next!=null ,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80), padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
itemBuilder: (context, index) { itemBuilder: (context, index) {
var item = data.value.data!.results![index]; var item = data.value.data!.results![index];
@@ -295,59 +296,84 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
child: Form( child: Form(
key: controller.formKey, key: controller.formKey,
child: Column( child: Column(
spacing: 16, spacing: 8,
children: [ children: [
Text( Text(
isOnEdit ? 'ویرایش اطلاعات خرید' : 'ثبت اطلاعات خرید', isOnEdit ? 'ویرایش اطلاعات خرید' : 'ثبت اطلاعات خرید',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover), style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
), ),
_productTypeWidget(), _productDropDown(),
RTextField(
controller: controller.sellerNameController, Container(
label: 'نام فروشنده', padding: EdgeInsets.all(8),
borderColor: AppColor.darkGreyLight, decoration: BoxDecoration(
filled: true, color: Colors.white,
filledColor: AppColor.bgLight, borderRadius: BorderRadius.circular(8),
), border: Border.all(color: AppColor.darkGreyLight, width: 1),
RTextField( ),
controller: controller.sellerPhoneController,
label: 'تلفن فروشنده', child: Column(spacing: 12, children: [_provinceWidget(), _cityWidget()]),
keyboardType: TextInputType.phone, ),
borderColor: AppColor.darkGreyLight,
maxLength: 11, Container(
filled: true, padding: EdgeInsets.all(8),
filledColor: AppColor.bgLight, decoration: BoxDecoration(
validator: (value) { color: Colors.white,
if (value == null || value.isEmpty) { borderRadius: BorderRadius.circular(8),
return 'لطفاً شماره موبایل را وارد کنید'; border: Border.all(color: AppColor.darkGreyLight, width: 1),
} ),
String cleaned = value.replaceAll(',', '');
if (cleaned.length != 11) { child: Column(
return 'شماره موبایل باید ۱۱ رقم باشد'; spacing: 12,
} children: [
if (!cleaned.startsWith('09')) { RTextField(
return 'شماره موبایل باید با 09 شروع شود'; controller: controller.sellerNameController,
} label: 'نام فروشنده',
return null; borderColor: AppColor.darkGreyLight,
}, filled: true,
), filledColor: AppColor.bgLight,
_provinceWidget(), ),
_cityWidget(), RTextField(
RTextField( controller: controller.sellerPhoneController,
controller: controller.carcassWeightController, label: 'تلفن فروشنده',
label: 'وزن', keyboardType: TextInputType.phone,
filled: true, borderColor: AppColor.darkGreyLight,
suffixIcon: Padding( maxLength: 11,
padding: const EdgeInsets.symmetric(horizontal: 8), filled: true,
child: Assets.vec.killogramSvg.svg(), filledColor: AppColor.bgLight,
validator: (value) {
if (value == null || value.isEmpty) {
return 'لطفاً شماره موبایل را وارد کنید';
}
String cleaned = value.replaceAll(',', '');
if (cleaned.length != 11) {
return 'شماره موبایل باید ۱۱ رقم باشد';
}
if (!cleaned.startsWith('09')) {
return 'شماره موبایل باید با 09 شروع شود';
}
return null;
},
),
RTextField(
controller: controller.carcassWeightController,
label: 'وزن',
filled: true,
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Assets.vec.killogramSvg.svg(),
),
filledColor: AppColor.bgLight,
keyboardType: TextInputType.number,
borderColor: AppColor.darkGreyLight,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
SeparatorInputFormatter(),
],
),
],
), ),
filledColor: AppColor.bgLight,
keyboardType: TextInputType.number,
borderColor: AppColor.darkGreyLight,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
SeparatorInputFormatter(),
],
), ),
_imageCarcasesWidget(isOnEdit), _imageCarcasesWidget(isOnEdit),
submitButtonWidget(isOnEdit), submitButtonWidget(isOnEdit),
@@ -362,7 +388,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
Widget submitButtonWidget(bool isOnEdit) { Widget submitButtonWidget(bool isOnEdit) {
return ObxValue((data) { return ObxValue((data) {
return RElevated( return RElevated(
text: isOnEdit ? 'ویرایش' : 'ثبت خرید', text: isOnEdit ? 'ویرایش' : 'ثبت',
width: Get.width, width: Get.width,
backgroundColor: AppColor.greenNormal, backgroundColor: AppColor.greenNormal,
onPressed: data.value onPressed: data.value
@@ -378,25 +404,33 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
}, controller.isSubmitButtonEnabled); }, controller.isSubmitButtonEnabled);
} }
Widget _productTypeWidget() { Widget _productDropDown() {
return Obx(() { return Obx(() {
return OverlayDropdownWidget<ProductModel>( return OverlayDropdownWidget<ProductModel>(
items: controller.outOfTheProvinceLogic.rolesProductsModel, items: controller.outOfTheProvinceLogic.rolesProductsModel,
height: 56,
hasDropIcon: false,
background: Colors.white,
onChanged: (value) { onChanged: (value) {
controller.selectedProduct.value = value; controller.selectedProduct.value = value;
}, },
selectedItem: controller.selectedProduct.value, selectedItem: controller.selectedProduct.value,
initialValue: controller.selectedProduct.value, initialValue: controller.selectedProduct.value,
itemBuilder: (item) => Text( itemBuilder: (item) => Text(item.name ?? 'بدون نام'),
item.name ?? 'بدون نام', labelBuilder: (item) => Row(
style: AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarker), spacing: 8,
children: [
(item?.name?.contains('مرغ گرم') ?? false)
? Assets.images.chicken.image(width: 40, height: 40)
: Assets.vec.placeHolderSvg.svg(width: 40, height: 40),
Text(item?.name ?? 'انتخاب محصول'),
Spacer(),
Text(
'موجودی:${controller.rootLogic.inventoryModel.value?.totalRemainWeight.separatedByComma ?? 0}',
),
],
), ),
labelBuilder: (item) => item?.name != null
? Text(item!.name!, style: AppFonts.yekan14.copyWith(color: AppColor.textColor))
: Text(
'انتخاب محصول',
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
),
); );
}); });
} }
@@ -575,5 +609,4 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
}, controller.rootLogic.inventoryModel), }, controller.rootLogic.inventoryModel),
); );
} }
} }

View File

@@ -20,6 +20,7 @@ class SalesOutOfProvinceBuyersPage extends GetView<SalesOutOfProvinceBuyersLogic
controller.currentPage.value = 1; controller.currentPage.value = 1;
await controller.getOutProvinceCarcassesBuyer(); await controller.getOutProvinceCarcassesBuyer();
}, },
hasMore: data.value.data?.next!= null,
listType: ListType.separated, listType: ListType.separated,
resource: data.value, resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80), padding: EdgeInsets.fromLTRB(8, 8, 8, 80),

View File

@@ -9,8 +9,7 @@ import 'package:rasadyar_core/core.dart';
import 'logic.dart'; import 'logic.dart';
class SalesOutOfProvinceSalesListPage class SalesOutOfProvinceSalesListPage extends GetView<SalesOutOfProvinceSalesListLogic> {
extends GetView<SalesOutOfProvinceSalesListLogic> {
const SalesOutOfProvinceSalesListPage({super.key}); const SalesOutOfProvinceSalesListPage({super.key});
@override @override
@@ -23,6 +22,7 @@ class SalesOutOfProvinceSalesListPage
controller.currentPage.value = 1; controller.currentPage.value = 1;
await controller.getOutProvinceSales(); await controller.getOutProvinceSales();
}, },
hasMore: data.value.data?.next != null,
listType: ListType.separated, listType: ListType.separated,
resource: data.value, resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80), padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
@@ -123,10 +123,7 @@ class SalesOutOfProvinceSalesListPage
return Container( return Container(
padding: EdgeInsets.fromLTRB(8, 12, 14, 12), padding: EdgeInsets.fromLTRB(8, 12, 14, 12),
decoration: BoxDecoration( decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column( child: Column(
spacing: 8, spacing: 8,
children: [ children: [
@@ -150,21 +147,12 @@ class SalesOutOfProvinceSalesListPage
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
), ),
child: buildRow( child: buildRow(title: 'تاریخ', value: item.date?.formattedJalaliDateYHMS ?? 'N/A'),
title: 'تاریخ',
value: item.date?.formattedJalaliDateYHMS ?? 'N/A',
),
),
buildRow(
title: 'مشخصات خریدار',
value: item.buyer?.fullname ?? 'N/A',
), ),
buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'),
buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'), buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'),
buildRow(title: 'نام واحد', value: item.buyer?.unitName ?? 'N/A'), buildRow(title: 'نام واحد', value: item.buyer?.unitName ?? 'N/A'),
buildRow( buildRow(title: 'وزن لاشه', value: '${item.weightOfCarcasses?.separatedByComma}'),
title: 'وزن لاشه',
value: '${item.weightOfCarcasses?.separatedByComma}',
),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -220,13 +208,10 @@ class SalesOutOfProvinceSalesListPage
children: [ children: [
Text( Text(
isOnEdit ? 'ویرایش فروش' : 'افزودن فروش', isOnEdit ? 'ویرایش فروش' : 'افزودن فروش',
style: AppFonts.yekan16Bold.copyWith( style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
color: AppColor.darkGreyDarkHover,
),
), ),
_productDropDown(), _productDropDown(),
Container( Container(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -301,9 +286,7 @@ class SalesOutOfProvinceSalesListPage
text: isOnEdit ? 'ویرایش' : 'ثبت', text: isOnEdit ? 'ویرایش' : 'ثبت',
onPressed: data.value onPressed: data.value
? () async { ? () async {
var res = isOnEdit var res = isOnEdit ? await controller.editSale() : await controller.createSale();
? await controller.editSale()
: await controller.createSale();
if (res) { if (res) {
controller.getOutProvinceSales(); controller.getOutProvinceSales();
controller.clearSaleForm(); controller.clearSaleForm();
@@ -330,7 +313,6 @@ class SalesOutOfProvinceSalesListPage
}); });
} }
Widget _productDropDown() { Widget _productDropDown() {
return Obx(() { return Obx(() {
return OverlayDropdownWidget<ProductModel>( return OverlayDropdownWidget<ProductModel>(
@@ -362,7 +344,6 @@ class SalesOutOfProvinceSalesListPage
}); });
} }
GestureDetector timeFilterWidget({ GestureDetector timeFilterWidget({
isFrom = true, isFrom = true,
required Rx<Jalali> date, required Rx<Jalali> date,
@@ -375,7 +356,7 @@ class SalesOutOfProvinceSalesListPage
child: Container( child: Container(
height: 40, height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
color:AppColor.bgLight, color: AppColor.bgLight,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.darkGreyLight), border: Border.all(width: 1, color: AppColor.darkGreyLight),
), ),
@@ -386,23 +367,15 @@ class SalesOutOfProvinceSalesListPage
Assets.vec.calendarSvg.svg( Assets.vec.calendarSvg.svg(
width: 24, width: 24,
height: 24, height: 24,
colorFilter: const ColorFilter.mode( colorFilter: const ColorFilter.mode(AppColor.bgDark, BlendMode.srcIn),
AppColor.bgDark,
BlendMode.srcIn,
),
),
Text(
'تاریخ',
style: AppFonts.yekan16.copyWith(color: AppColor.bgDark),
), ),
Text('تاریخ', style: AppFonts.yekan16.copyWith(color: AppColor.bgDark)),
Expanded( Expanded(
child: ObxValue((data) { child: ObxValue((data) {
return Text( return Text(
date.value.formatCompactDate(), date.value.formatCompactDate(),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: AppFonts.yekan16.copyWith( style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDark),
color: AppColor.darkGreyDark,
),
); );
}, date), }, date),
), ),