fix : some bug

This commit is contained in:
2025-10-11 17:16:26 +03:30
parent be6e16f54e
commit 9a29b0ea58
20 changed files with 1962 additions and 300 deletions

View File

@@ -1,5 +1,5 @@
sdk.dir=C:/Users/Housh11/AppData/Local/Android/Sdk
flutter.sdk=C:\\src\\flutter
flutter.buildMode=release
flutter.versionName=1.3.20
flutter.versionCode=17
flutter.buildMode=debug
flutter.versionName=1.3.21
flutter.versionCode=18

View File

@@ -104,9 +104,9 @@ abstract class ChickenRemoteDatasource {
required CreateStewardFreeBar body,
});
Future<void> deleteStewardPurchasesOutSideOfTheProvince({
Future<void> editStewardPurchasesOutSideOfTheProvince({
required String token,
required String stewardFreeBarKey,
Map<String, dynamic>? queryParameters,
});
Future<PaginationModel<OutProvinceCarcassesBuyer>?> getOutProvinceCarcassesBuyer({

View File

@@ -318,15 +318,16 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource {
);
}
//todo fix this
@override
Future<void> deleteStewardPurchasesOutSideOfTheProvince({
Future<void> editStewardPurchasesOutSideOfTheProvince({
required String token,
required String stewardFreeBarKey,
Map<String, dynamic>? queryParameters,
}) async {
await _httpClient.delete(
'/steward_free_bar/0/',
headers: {'Authorization': 'Bearer $token'},
queryParameters: {'key': stewardFreeBarKey},
queryParameters: queryParameters
);
}

View File

@@ -8,7 +8,7 @@ abstract class WaitingArrivalModel with _$WaitingArrivalModel {
factory WaitingArrivalModel({
int? id,
ProductModel? product,
dynamic killHouse,
KillHouseModel? killHouse,
dynamic toKillHouse,
StewardModel? steward,
StewardModel? toSteward,
@@ -56,12 +56,10 @@ abstract class WaitingArrivalModel with _$WaitingArrivalModel {
bool? temporaryTrash,
bool? temporaryDeleted,
bool? overhead,
dynamic createdBy,
dynamic modifiedBy,
dynamic wareHouse,
dynamic stewardWareHouse,
dynamic car,
dynamic dispenser,
bool? warehouse,
bool? stewardWarehouse,
String? quota,
}) = _WaitingArrivalModel;
factory WaitingArrivalModel.fromJson(Map<String, dynamic> json) =>
@@ -70,22 +68,99 @@ abstract class WaitingArrivalModel with _$WaitingArrivalModel {
@freezed
abstract class ProductModel with _$ProductModel {
factory ProductModel({String? name, double? weightAverage}) = _ProductModel;
factory ProductModel({
String? name,
double? weightAverage,
}) = _ProductModel;
factory ProductModel.fromJson(Map<String, dynamic> json) => _$ProductModelFromJson(json);
factory ProductModel.fromJson(Map<String, dynamic> json) =>
_$ProductModelFromJson(json);
}
/// =======================
/// KILL HOUSE SECTION
/// =======================
@freezed
abstract class KillHouseModel with _$KillHouseModel {
factory KillHouseModel({
String? key,
String? name,
bool? killer,
KillHouseOperatorModel? killHouseOperator,
}) = _KillHouseModel;
factory KillHouseModel.fromJson(Map<String, dynamic> json) =>
_$KillHouseModelFromJson(json);
}
@freezed
abstract class KillHouseOperatorModel with _$KillHouseOperatorModel {
factory KillHouseOperatorModel({
KillHouseUserModel? user,
}) = _KillHouseOperatorModel;
factory KillHouseOperatorModel.fromJson(Map<String, dynamic> json) =>
_$KillHouseOperatorModelFromJson(json);
}
@freezed
abstract class KillHouseUserModel with _$KillHouseUserModel {
factory KillHouseUserModel({
String? fullname,
String? firstName,
String? lastName,
int? baseOrder,
String? mobile,
String? nationalId,
String? nationalCode,
String? key,
CityDetailModel? city,
String? unitName,
String? unitNationalId,
String? unitRegistrationNumber,
String? unitEconomicalNumber,
String? unitProvince,
String? unitCity,
String? unitPostalCode,
String? unitAddress,
}) = _KillHouseUserModel;
factory KillHouseUserModel.fromJson(Map<String, dynamic> json) =>
_$KillHouseUserModelFromJson(json);
}
@freezed
abstract class CityDetailModel with _$CityDetailModel {
factory CityDetailModel({
int? id,
String? key,
String? createDate,
String? modifyDate,
bool? trash,
int? provinceIdForeignKey,
int? cityIdKey,
String? name,
double? productPrice,
bool? provinceCenter,
int? cityNumber,
String? cityName,
int? provinceNumber,
String? provinceName,
}) = _CityDetailModel;
factory CityDetailModel.fromJson(Map<String, dynamic> json) =>
_$CityDetailModelFromJson(json);
}
/// =======================
/// TO STEWARD SECTION
/// =======================
@freezed
abstract class StewardModel with _$StewardModel {
factory StewardModel({
int? id,
StewardUserModel? user,
AddressModel? address,
dynamic guildAreaActivity,
dynamic guildTypeActivity,
List<dynamic>? killHouse,
List<dynamic>? stewardKillHouse,
List<dynamic>? stewards,
GetPosStatusModel? getPosStatus,
String? key,
String? createDate,
@@ -111,11 +186,10 @@ abstract class StewardModel with _$StewardModel {
bool? stewardLimitationAllocation,
bool? license,
int? wallet,
List<dynamic>? cars,
List<dynamic>? userLevel,
}) = _StewardModel;
factory StewardModel.fromJson(Map<String, dynamic> json) => _$StewardModelFromJson(json);
factory StewardModel.fromJson(Map<String, dynamic> json) =>
_$StewardModelFromJson(json);
}
@freezed
@@ -129,7 +203,8 @@ abstract class StewardUserModel with _$StewardUserModel {
String? city,
}) = _StewardUserModel;
factory StewardUserModel.fromJson(Map<String, dynamic> json) => _$StewardUserModelFromJson(json);
factory StewardUserModel.fromJson(Map<String, dynamic> json) =>
_$StewardUserModelFromJson(json);
}
@freezed
@@ -141,27 +216,39 @@ abstract class AddressModel with _$AddressModel {
String? postalCode,
}) = _AddressModel;
factory AddressModel.fromJson(Map<String, dynamic> json) => _$AddressModelFromJson(json);
factory AddressModel.fromJson(Map<String, dynamic> json) =>
_$AddressModelFromJson(json);
}
@freezed
abstract class ProvinceModel with _$ProvinceModel {
factory ProvinceModel({String? key, String? name}) = _ProvinceModel;
factory ProvinceModel({
String? key,
String? name,
}) = _ProvinceModel;
factory ProvinceModel.fromJson(Map<String, dynamic> json) => _$ProvinceModelFromJson(json);
factory ProvinceModel.fromJson(Map<String, dynamic> json) =>
_$ProvinceModelFromJson(json);
}
@freezed
abstract class CityModel with _$CityModel {
factory CityModel({String? key, String? name}) = _CityModel;
factory CityModel({
String? key,
String? name,
}) = _CityModel;
factory CityModel.fromJson(Map<String, dynamic> json) => _$CityModelFromJson(json);
factory CityModel.fromJson(Map<String, dynamic> json) =>
_$CityModelFromJson(json);
}
@freezed
abstract class GetPosStatusModel with _$GetPosStatusModel {
factory GetPosStatusModel({int? lenActiveSessions, bool? hasPons, bool? hasActivePons}) =
_GetPosStatusModel;
factory GetPosStatusModel({
int? lenActiveSessions,
bool? hasPons,
bool? hasActivePons,
}) = _GetPosStatusModel;
factory GetPosStatusModel.fromJson(Map<String, dynamic> json) =>
_$GetPosStatusModelFromJson(json);

View File

@@ -13,7 +13,9 @@ _WaitingArrivalModel _$WaitingArrivalModelFromJson(
product: json['product'] == null
? null
: ProductModel.fromJson(json['product'] as Map<String, dynamic>),
killHouse: json['kill_house'],
killHouse: json['kill_house'] == null
? null
: KillHouseModel.fromJson(json['kill_house'] as Map<String, dynamic>),
toKillHouse: json['to_kill_house'],
steward: json['steward'] == null
? null
@@ -67,12 +69,9 @@ _WaitingArrivalModel _$WaitingArrivalModelFromJson(
temporaryTrash: json['temporary_trash'] as bool?,
temporaryDeleted: json['temporary_deleted'] as bool?,
overhead: json['overhead'] as bool?,
createdBy: json['created_by'],
modifiedBy: json['modified_by'],
wareHouse: json['ware_house'],
stewardWareHouse: json['steward_ware_house'],
car: json['car'],
dispenser: json['dispenser'],
warehouse: json['warehouse'] as bool?,
stewardWarehouse: json['steward_warehouse'] as bool?,
quota: json['quota'] as String?,
);
Map<String, dynamic> _$WaitingArrivalModelToJson(
@@ -128,12 +127,9 @@ Map<String, dynamic> _$WaitingArrivalModelToJson(
'temporary_trash': instance.temporaryTrash,
'temporary_deleted': instance.temporaryDeleted,
'overhead': instance.overhead,
'created_by': instance.createdBy,
'modified_by': instance.modifiedBy,
'ware_house': instance.wareHouse,
'steward_ware_house': instance.stewardWareHouse,
'car': instance.car,
'dispenser': instance.dispenser,
'warehouse': instance.warehouse,
'steward_warehouse': instance.stewardWarehouse,
'quota': instance.quota,
};
_ProductModel _$ProductModelFromJson(Map<String, dynamic> json) =>
@@ -148,6 +144,118 @@ Map<String, dynamic> _$ProductModelToJson(_ProductModel instance) =>
'weight_average': instance.weightAverage,
};
_KillHouseModel _$KillHouseModelFromJson(Map<String, dynamic> json) =>
_KillHouseModel(
key: json['key'] as String?,
name: json['name'] as String?,
killer: json['killer'] as bool?,
killHouseOperator: json['kill_house_operator'] == null
? null
: KillHouseOperatorModel.fromJson(
json['kill_house_operator'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$KillHouseModelToJson(_KillHouseModel instance) =>
<String, dynamic>{
'key': instance.key,
'name': instance.name,
'killer': instance.killer,
'kill_house_operator': instance.killHouseOperator,
};
_KillHouseOperatorModel _$KillHouseOperatorModelFromJson(
Map<String, dynamic> json,
) => _KillHouseOperatorModel(
user: json['user'] == null
? null
: KillHouseUserModel.fromJson(json['user'] as Map<String, dynamic>),
);
Map<String, dynamic> _$KillHouseOperatorModelToJson(
_KillHouseOperatorModel instance,
) => <String, dynamic>{'user': instance.user};
_KillHouseUserModel _$KillHouseUserModelFromJson(Map<String, dynamic> json) =>
_KillHouseUserModel(
fullname: json['fullname'] as String?,
firstName: json['first_name'] as String?,
lastName: json['last_name'] as String?,
baseOrder: (json['base_order'] as num?)?.toInt(),
mobile: json['mobile'] as String?,
nationalId: json['national_id'] as String?,
nationalCode: json['national_code'] as String?,
key: json['key'] as String?,
city: json['city'] == null
? null
: CityDetailModel.fromJson(json['city'] as Map<String, dynamic>),
unitName: json['unit_name'] as String?,
unitNationalId: json['unit_national_id'] as String?,
unitRegistrationNumber: json['unit_registration_number'] as String?,
unitEconomicalNumber: json['unit_economical_number'] as String?,
unitProvince: json['unit_province'] as String?,
unitCity: json['unit_city'] as String?,
unitPostalCode: json['unit_postal_code'] as String?,
unitAddress: json['unit_address'] as String?,
);
Map<String, dynamic> _$KillHouseUserModelToJson(_KillHouseUserModel instance) =>
<String, dynamic>{
'fullname': instance.fullname,
'first_name': instance.firstName,
'last_name': instance.lastName,
'base_order': instance.baseOrder,
'mobile': instance.mobile,
'national_id': instance.nationalId,
'national_code': instance.nationalCode,
'key': instance.key,
'city': instance.city,
'unit_name': instance.unitName,
'unit_national_id': instance.unitNationalId,
'unit_registration_number': instance.unitRegistrationNumber,
'unit_economical_number': instance.unitEconomicalNumber,
'unit_province': instance.unitProvince,
'unit_city': instance.unitCity,
'unit_postal_code': instance.unitPostalCode,
'unit_address': instance.unitAddress,
};
_CityDetailModel _$CityDetailModelFromJson(Map<String, dynamic> json) =>
_CityDetailModel(
id: (json['id'] as num?)?.toInt(),
key: json['key'] as String?,
createDate: json['create_date'] as String?,
modifyDate: json['modify_date'] as String?,
trash: json['trash'] as bool?,
provinceIdForeignKey: (json['province_id_foreign_key'] as num?)?.toInt(),
cityIdKey: (json['city_id_key'] as num?)?.toInt(),
name: json['name'] as String?,
productPrice: (json['product_price'] as num?)?.toDouble(),
provinceCenter: json['province_center'] as bool?,
cityNumber: (json['city_number'] as num?)?.toInt(),
cityName: json['city_name'] as String?,
provinceNumber: (json['province_number'] as num?)?.toInt(),
provinceName: json['province_name'] as String?,
);
Map<String, dynamic> _$CityDetailModelToJson(_CityDetailModel instance) =>
<String, dynamic>{
'id': instance.id,
'key': instance.key,
'create_date': instance.createDate,
'modify_date': instance.modifyDate,
'trash': instance.trash,
'province_id_foreign_key': instance.provinceIdForeignKey,
'city_id_key': instance.cityIdKey,
'name': instance.name,
'product_price': instance.productPrice,
'province_center': instance.provinceCenter,
'city_number': instance.cityNumber,
'city_name': instance.cityName,
'province_number': instance.provinceNumber,
'province_name': instance.provinceName,
};
_StewardModel _$StewardModelFromJson(Map<String, dynamic> json) =>
_StewardModel(
id: (json['id'] as num?)?.toInt(),
@@ -157,11 +265,6 @@ _StewardModel _$StewardModelFromJson(Map<String, dynamic> json) =>
address: json['address'] == null
? null
: AddressModel.fromJson(json['address'] as Map<String, dynamic>),
guildAreaActivity: json['guild_area_activity'],
guildTypeActivity: json['guild_type_activity'],
killHouse: json['kill_house'] as List<dynamic>?,
stewardKillHouse: json['steward_kill_house'] as List<dynamic>?,
stewards: json['stewards'] as List<dynamic>?,
getPosStatus: json['get_pos_status'] == null
? null
: GetPosStatusModel.fromJson(
@@ -192,8 +295,6 @@ _StewardModel _$StewardModelFromJson(Map<String, dynamic> json) =>
json['steward_limitation_allocation'] as bool?,
license: json['license'] as bool?,
wallet: (json['wallet'] as num?)?.toInt(),
cars: json['cars'] as List<dynamic>?,
userLevel: json['user_level'] as List<dynamic>?,
);
Map<String, dynamic> _$StewardModelToJson(_StewardModel instance) =>
@@ -201,11 +302,6 @@ Map<String, dynamic> _$StewardModelToJson(_StewardModel instance) =>
'id': instance.id,
'user': instance.user,
'address': instance.address,
'guild_area_activity': instance.guildAreaActivity,
'guild_type_activity': instance.guildTypeActivity,
'kill_house': instance.killHouse,
'steward_kill_house': instance.stewardKillHouse,
'stewards': instance.stewards,
'get_pos_status': instance.getPosStatus,
'key': instance.key,
'create_date': instance.createDate,
@@ -231,8 +327,6 @@ Map<String, dynamic> _$StewardModelToJson(_StewardModel instance) =>
'steward_limitation_allocation': instance.stewardLimitationAllocation,
'license': instance.license,
'wallet': instance.wallet,
'cars': instance.cars,
'user_level': instance.userLevel,
};
_StewardUserModel _$StewardUserModelFromJson(Map<String, dynamic> json) =>

View File

@@ -109,9 +109,9 @@ abstract class ChickenRepository {
required CreateStewardFreeBar body,
});
Future<void> deleteStewardPurchasesOutSideOfTheProvince({
Future<void> editStewardPurchasesOutSideOfTheProvince({
required String token,
required String stewardFreeBarKey,
Map<String, dynamic>? queryParameters,
});
Future<PaginationModel<OutProvinceCarcassesBuyer>?> getOutProvinceCarcassesBuyer({

View File

@@ -223,13 +223,13 @@ class ChickenRepositoryImp implements ChickenRepository {
}
@override
Future<void> deleteStewardPurchasesOutSideOfTheProvince({
Future<void> editStewardPurchasesOutSideOfTheProvince({
required String token,
required String stewardFreeBarKey,
Map<String, dynamic>? queryParameters,
}) async {
await remote.deleteStewardPurchasesOutSideOfTheProvince(
await remote.editStewardPurchasesOutSideOfTheProvince(
token: token,
stewardFreeBarKey: stewardFreeBarKey,
queryParameters: queryParameters
);
}

View File

@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/data/models/request/steward_allocation/steward_allocation_request.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
import 'package:rasadyar_chicken/presentation/pages/steward/root/logic.dart';
import 'package:rasadyar_core/core.dart';
class BuyInProvinceAllLogic extends GetxController {
RxList<int> isExpandedList = <int>[].obs;
RxInt isExpandedListIndex = (-1).obs;
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
RxnString searchedValue = RxnString();
@@ -17,6 +18,13 @@ class BuyInProvinceAllLogic extends GetxController {
Rx<Resource<PaginationModel<WaitingArrivalModel>>> allProduct =
Resource<PaginationModel<WaitingArrivalModel>>.loading().obs;
TextEditingController weightController = TextEditingController();
TextEditingController countController = TextEditingController();
TextEditingController lossController = TextEditingController();
TextEditingController approvedWithOtpController = TextEditingController();
RxBool approvedWithOtpCode = false.obs;
@override
void onInit() {
super.onInit();
@@ -87,22 +95,23 @@ class BuyInProvinceAllLogic extends GetxController {
state: 'accepted',
receiverRealNumberOfCarcasses: model.realNumberOfCarcasses ?? 0,
receiverRealWeightOfCarcasses: model.realWeightOfCarcasses?.toInt() ?? 0,
registrationCode: model.registrationCode ?? 0,
registrationCode: model.registrationCode,
weightLossOfCarcasses: model.weightLossOfCarcasses?.toInt() ?? 0,
).toJson();
request.removeWhere((key, value) => value == null);
safeCall(
showError: true,
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
token: rootLogic.tokenService.accessToken.value!,
request: request,
),
onError: (error, stackTrace) {
eLog(error);
},
onSuccess: (result) {
getAllArrivals();
rootLogic.getInventory();
rootLogic.onRefresh();
clearApprovedController();
toggleExpansion();
Get.back();
},
);
}
@@ -125,7 +134,7 @@ class BuyInProvinceAllLogic extends GetxController {
},
onSuccess: (result) {
getAllArrivals();
rootLogic.getInventory();
rootLogic.onRefresh();
},
);
}
@@ -142,4 +151,20 @@ class BuyInProvinceAllLogic extends GetxController {
return Assets.vec.timerSvg.path;
}
}
void clearApprovedController() {
weightController.clear();
countController.clear();
lossController.clear();
approvedWithOtpController.clear();
approvedWithOtpCode.value = false;
}
void toggleExpansion({int? index}) {
if (isExpandedListIndex.value == index || index == null) {
isExpandedListIndex.value = -1;
} else {
isExpandedListIndex.value = index;
}
}
}

View File

@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
import 'package:rasadyar_chicken/presentation/utils/string_utils.dart';
import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart' hide ListItem2;
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -24,20 +23,19 @@ class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
var item = data.value.data!.results![index];
return ObxValue((val) {
return ExpandableListItem2(
selected: val.contains(index),
onTap: () => controller.isExpandedList.toggle(index),
selected: val.value == index,
onTap: () => controller.toggleExpansion(index: index),
index: index,
child: itemListWidget(item),
secondChild: itemListExpandedWidget(item),
labelColor: getLabelColor(item.receiverState),
labelIcon: controller.getVecPathItem(item.receiverState),
);
}, controller.isExpandedList);
}, controller.isExpandedListIndex);
},
itemCount: data.value.data?.results?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
onLoadMore: () async => controller.getAllArrivals(true),
);
}, controller.allProduct),
);
@@ -138,12 +136,11 @@ class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
style: AppFonts.yekan10.copyWith(color: AppColor.darkGreyDark),
),
SizedBox(width: 7),
SvgGenImage.vec(
controller.getVecPathItem(item.receiverState),
).svg(width: 16.w, height: 16.h,
colorFilter: ColorFilter.mode(AppColor.darkGreyDark, BlendMode.srcIn)
SvgGenImage.vec(controller.getVecPathItem(item.receiverState)).svg(
width: 16.w,
height: 16.h,
colorFilter: ColorFilter.mode(AppColor.darkGreyDark, BlendMode.srcIn),
),
],
),
Container(
@@ -187,19 +184,13 @@ class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
),
),
buildRow(
title: 'مشخصات فروشنده',
value: item.steward?.user?.fullname ?? 'N/A',
),
buildRow(title: 'مشخصات فروشنده', value: item.steward?.user?.fullname ?? 'N/A'),
buildRow(
title: 'تلفن فروشنده',
value: item.steward?.user?.mobile ?? 'N/A',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(
title: 'نوع تخصیص',
value: item.allocationType?.faAllocationType ?? 'N/A',
),
buildRow(title: 'نوع تخصیص', value: item.allocationType?.faAllocationType ?? 'N/A'),
buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'),
buildRow(
title: 'وزن خریداری شده',
@@ -219,9 +210,12 @@ class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
height: 40.h,
isLoading: data[item.key!] ?? false,
onPressed: () async {
data[item.key!] = !(data[item.key!] ?? false);
await controller.acceptEntries(item);
data.remove(item.key!);
Get.bottomSheet(conformationBottomSheet(item), isScrollControlled: true).then(
(value) {
Get.back();
controller.clearApprovedController();
},
);
},
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
backgroundColor: AppColor.greenNormal,
@@ -255,7 +249,6 @@ class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
case 'pending':
return AppColor.blueLight;
case 'accepted':
return AppColor.greenLightHover;
case 'rejected':
return AppColor.redLightHover;
@@ -263,4 +256,109 @@ class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
return AppColor.blueLight;
}
}
Widget conformationBottomSheet(WaitingArrivalModel item) {
controller.weightController.text = item.weightOfCarcasses.separatedByComma;
return BaseBottomSheet(
height: 430.h,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
RTextField(
label: 'وزن(کیلوگرم)',
controller: controller.weightController,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
),
SizedBox(height: 16.h),
RTextField(
label: 'حجم(قطعه)',
controller: controller.countController,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
),
SizedBox(height: 16.h),
RTextField(
label: 'افت وزن(کیلوگرم)',
controller: controller.lossController,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
),
SizedBox(height: 16.h),
Text('تایید ', style: AppFonts.yekan16Bold.copyWith(color: AppColor.textColor)),
ObxValue((data) {
return Column(
children: [
RadioGroup(
groupValue: data.value,
onChanged: (value) {
controller.approvedWithOtpCode.value = value ?? false;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
radioRow(
value: true,
label: ' با کد احراز',
onTap: () {
controller.approvedWithOtpCode.value = true;
},
),
radioRow(
value: false,
label: 'بدون کد احراز',
onTap: () {
controller.approvedWithOtpCode.value = false;
},
),
],
),
),
Visibility(
child: RTextField(
controller: controller.approvedWithOtpController,
label: 'کد احراز',
keyboardType: TextInputType.number,
),
visible: data.value,
),
],
);
}, controller.approvedWithOtpCode),
SizedBox(height: 30.h),
ObxValue((data) {
return RElevated(
enabled: controller.approvedWithOtpCode.value
? controller.approvedWithOtpController.text.isNotEmpty
: true,
text: 'تایید',
onPressed: () async {
await controller.acceptEntries(item);
},
isFullWidth: true,
);
}, controller.approvedWithOtpCode),
SizedBox(height: 20.h),
],
),
);
}
Widget radioRow({
required bool value,
required String label,
TextStyle? textStyle,
GestureTapCallback? onTap,
}) {
return GestureDetector(
onTap: onTap,
child: Row(
children: [
Radio(value: value),
Text(label, style: textStyle ?? AppFonts.yekan16.copyWith(color: AppColor.textColor)),
],
),
);
}
}

View File

@@ -8,7 +8,7 @@ import 'package:rasadyar_chicken/presentation/utils/utils.dart';
import 'package:rasadyar_core/core.dart';
class BuyInProvinceWaitingLogic extends GetxController {
RxList<int> isExpandedList = <int>[].obs;
RxInt isExpandedListIndex = (-1).obs;
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
RxnString searchedValue = RxnString();
@@ -21,6 +21,13 @@ class BuyInProvinceWaitingLogic extends GetxController {
Rx<Resource<PaginationModel<WaitingArrivalModel>>> waitingProduct =
Resource<PaginationModel<WaitingArrivalModel>>.loading().obs;
TextEditingController weightController = TextEditingController();
TextEditingController countController = TextEditingController();
TextEditingController lossController = TextEditingController();
TextEditingController approvedWithOtpController = TextEditingController();
RxBool approvedWithOtpCode = false.obs;
@override
void onInit() {
super.onInit();
@@ -99,12 +106,13 @@ class BuyInProvinceWaitingLogic extends GetxController {
state: 'accepted',
receiverRealNumberOfCarcasses: model.realNumberOfCarcasses ?? 0,
receiverRealWeightOfCarcasses: model.realWeightOfCarcasses?.toInt() ?? 0,
registrationCode: model.registrationCode ?? 0,
registrationCode: model.registrationCode,
weightLossOfCarcasses: model.weightLossOfCarcasses?.toInt() ?? 0,
).toJson();
request.removeWhere((key, value) => value == null);
safeCall(
showError: true,
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
token: rootLogic.tokenService.accessToken.value!,
request: request,
@@ -114,7 +122,10 @@ class BuyInProvinceWaitingLogic extends GetxController {
},
onSuccess: (result) {
getWaitingArrivals();
// getBarGeneralInformation();
rootLogic.onRefresh();
clearApprovedController();
toggleExpansion();
Get.back();
},
);
}
@@ -137,8 +148,7 @@ class BuyInProvinceWaitingLogic extends GetxController {
},
onSuccess: (result) {
getWaitingArrivals();
//TODO
// getBarGeneralInformation();
rootLogic.onRefresh();
},
);
}
@@ -152,4 +162,20 @@ class BuyInProvinceWaitingLogic extends GetxController {
}
});
}
void clearApprovedController() {
weightController.clear();
countController.clear();
lossController.clear();
approvedWithOtpController.clear();
approvedWithOtpCode.value = false;
}
void toggleExpansion({int? index}) {
if (isExpandedListIndex.value == index || index == null) {
isExpandedListIndex.value = -1;
} else {
isExpandedListIndex.value = index;
}
}
}

View File

@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
import 'package:rasadyar_chicken/presentation/utils/string_utils.dart';
import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart' hide ListItem2;
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -26,15 +25,15 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
var item = data.value.data!.results![index];
return ObxValue((val) {
return ExpandableListItem2(
selected: val.contains(index),
onTap: () => controller.isExpandedList.toggle(index),
selected: controller.isExpandedListIndex.value == index,
onTap: () => controller.toggleExpansion(index: index),
index: index,
child: itemListWidget(item),
secondChild: itemListExpandedWidget(item),
labelColor: AppColor.blueLight,
labelIcon: Assets.vec.timerSvg.path,
);
}, controller.isExpandedList);
}, controller.isExpandedListIndex);
},
itemCount: data.value.data?.results?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
@@ -184,25 +183,22 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
),
),
buildRow(
title: 'مشخصات فروشنده',
value: item.steward?.user?.fullname ?? 'N/A',
),
buildRow(title: 'مشخصات فروشنده', value: item.toSteward?.user?.fullname ?? 'N/A'),
buildRow(
title: 'تلفن فروشنده',
value: item.steward?.user?.mobile ?? 'N/A',
value: item.toSteward?.user?.mobile ?? 'N/A',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(
title: 'نوع تخصیص',
value: item.allocationType?.faAllocationType ?? 'N/A',
),
buildRow(title: 'نوع تخصیص', value: item.quota?.faTitle ?? 'N/A'),
buildRow(title: 'سهمیه', value: item.allocationType?.faAllocationType ?? 'N/A'),
buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'),
buildRow(
title: 'وزن خریداری شده',
value: '${item.weightOfCarcasses?.separatedByCommaFa} کیلوگرم',
),
buildRow(title: 'قیمت هر کیلو', value: '${item.amount?.separatedByCommaFa} ریال'),
buildRow(title: 'قیمت کل', value: '${item.totalAmount?.separatedByCommaFa} ریال'),
Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 16.w,
@@ -214,9 +210,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
height: 40.h,
isLoading: data[item.key!] ?? false,
onPressed: () async {
data[item.key!] = !(data[item.key!] ?? false);
await controller.acceptEntries(item);
data.remove(item.key!);
await Get.bottomSheet(conformationBottomSheet(item), isScrollControlled: true);
},
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
backgroundColor: AppColor.greenNormal,
@@ -243,4 +237,109 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
),
);
}
Widget conformationBottomSheet(WaitingArrivalModel item) {
controller.weightController.text = item.weightOfCarcasses.separatedByComma;
return BaseBottomSheet(
height: 430.h,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
RTextField(
label: 'وزن(کیلوگرم)',
controller: controller.weightController,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
),
SizedBox(height: 16.h),
RTextField(
label: 'حجم(قطعه)',
controller: controller.countController,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
),
SizedBox(height: 16.h),
RTextField(
label: 'افت وزن(کیلوگرم)',
controller: controller.lossController,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
),
SizedBox(height: 16.h),
Text('تایید ', style: AppFonts.yekan16Bold.copyWith(color: AppColor.textColor)),
ObxValue((data) {
return Column(
children: [
RadioGroup(
groupValue: data.value,
onChanged: (value) {
controller.approvedWithOtpCode.value = value ?? false;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
radioRow(
value: true,
label: ' با کد احراز',
onTap: () {
controller.approvedWithOtpCode.value = true;
},
),
radioRow(
value: false,
label: 'بدون کد احراز',
onTap: () {
controller.approvedWithOtpCode.value = false;
},
),
],
),
),
Visibility(
child: RTextField(
controller: controller.approvedWithOtpController,
label: 'کد احراز',
keyboardType: TextInputType.number,
),
visible: data.value,
),
],
);
}, controller.approvedWithOtpCode),
SizedBox(height: 30.h),
ObxValue((data) {
return RElevated(
enabled: controller.approvedWithOtpCode.value
? controller.approvedWithOtpController.text.isNotEmpty
: true,
text: 'تایید',
onPressed: () async {
await controller.acceptEntries(item);
},
isFullWidth: true,
);
}, controller.approvedWithOtpCode),
SizedBox(height: 20.h),
],
),
);
}
Widget radioRow({
required bool value,
required String label,
TextStyle? textStyle,
GestureTapCallback? onTap,
}) {
return GestureDetector(
onTap: onTap,
child: Row(
children: [
Radio(value: value),
Text(label, style: textStyle ?? AppFonts.yekan16.copyWith(color: AppColor.textColor)),
],
),
);
}
}

View File

@@ -11,9 +11,9 @@ import 'package:rasadyar_core/core.dart';
class BuyOutOfProvinceLogic extends GetxController {
late List<String> routesName;
RxBool isExpanded = false.obs;
RxBool isSubmitButtonEnabled = false.obs;
RxList<int> isExpandedList = <int>[].obs;
RxInt expandedListIndex = (-1).obs;
final RxInt currentPage = 1.obs;
final RxBool isLoadingMoreAllocationsMade = false.obs;
final RxBool isOnLoadingSubmitOrEdit = false.obs;
@@ -34,14 +34,15 @@ class BuyOutOfProvinceLogic extends GetxController {
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
BuyLogic get buyLogic => Get.find<BuyLogic>();
BuyLogic buyLogic = Get.find<BuyLogic>();
SaleLogic get outOfTheProvinceLogic => Get.find<SaleLogic>();
SaleLogic outOfTheProvinceLogic = Get.find<SaleLogic>();
GlobalKey<FormState> formKey = GlobalKey<FormState>();
TextEditingController sellerNameController = TextEditingController();
TextEditingController sellerPhoneController = TextEditingController();
TextEditingController carcassWeightController = TextEditingController();
TextEditingController carcassCountController = TextEditingController();
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
@@ -51,8 +52,6 @@ class BuyOutOfProvinceLogic extends GetxController {
void onInit() {
super.onInit();
routesName = [...buyLogic.routesName, 'خارج استان'].toList();
fLog('BuyOutOfProvinceLogic ${rootLogic.stewardSalesInfoDashboard}');
}
@override
@@ -76,7 +75,6 @@ class BuyOutOfProvinceLogic extends GetxController {
sellerNameController.dispose();
sellerPhoneController.dispose();
carcassWeightController.dispose();
isExpandedList.clear();
super.onClose();
}
@@ -144,9 +142,15 @@ class BuyOutOfProvinceLogic extends GetxController {
}
void setupListeners() {
sellerNameController.addListener(checkFormValid);
sellerNameController.addListener(() {
checkFormValid();
if (!isSubmitButtonEnabled.value) {
isSubmitButtonEnabled.value = !isSubmitButtonEnabled.value;
}
});
sellerPhoneController.addListener(checkFormValid);
carcassWeightController.addListener(checkFormValid);
carcassCountController.addListener(checkFormValid);
ever(selectedProvince, (_) => checkFormValid());
ever(selectedCity, (_) => checkFormValid());
@@ -164,19 +168,26 @@ class BuyOutOfProvinceLogic extends GetxController {
sellerNameController.text.isNotEmpty &&
sellerPhoneController.text.isNotEmpty &&
carcassWeightController.text.isNotEmpty &&
carcassCountController.text.isNotEmpty &&
selectedProvince.value != null &&
selectedCity.value != null &&
selectedProduct.value != null &&
selectedImage.value != null;
if (isSubmitButtonEnabled.value) {
isOnLoadingSubmitOrEdit.value = false;
}
}
Future<bool> createStewardPurchaseOutOfProvince() async {
bool res = false;
isOnLoadingSubmitOrEdit.value = true;
if (!(formKey.currentState?.validate() ?? false)) {
isOnLoadingSubmitOrEdit.value = false;
return res;
}
await safeCall(
showError: true,
call: () async {
CreateStewardFreeBar createStewardFreeBar = CreateStewardFreeBar(
productKey: selectedProduct.value!.key,
@@ -188,7 +199,7 @@ class BuyOutOfProvinceLogic extends GetxController {
barImage: _base64Image.value,
date: DateTime.now().formattedYHMS,
);
final res = await rootLogic.chickenRepository.createStewardPurchasesOutSideOfTheProvince(
await rootLogic.chickenRepository.createStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!,
body: createStewardFreeBar,
);
@@ -196,6 +207,7 @@ class BuyOutOfProvinceLogic extends GetxController {
onSuccess: (result) {
getStewardPurchaseOutOfProvince();
resetSubmitForm();
toggleExpansion();
res = true;
},
);
@@ -229,11 +241,31 @@ class BuyOutOfProvinceLogic extends GetxController {
isSubmitButtonEnabled.value = true;
}
Future<void> editStewardPurchaseOutOfProvince(StewardFreeBar item) async {
CreateStewardFreeBar edit = CreateStewardFreeBar(
productKey: selectedProduct.value!.key,
killHouseName: sellerNameController.text,
killHouseMobile: sellerPhoneController.text,
province: selectedProvince.value!.name,
city: selectedCity.value!.name,
weightOfCarcasses: int.parse(carcassWeightController.text.clearComma),
barImage: _base64Image.value,
date: DateTime.now().formattedYHMS,
);
await safeCall(
call: () => rootLogic.chickenRepository.editStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!,
queryParameters: buildRawQueryParams(queryParams: {'key': key}),
),
);
}
Future<void> deleteStewardPurchaseOutOfProvince(String key) async {
await safeCall(
call: () => rootLogic.chickenRepository.deleteStewardPurchasesOutSideOfTheProvince(
call: () => rootLogic.chickenRepository.editStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!,
stewardFreeBarKey: key,
queryParameters: buildRawQueryParams(queryParams: {'key': key}),
),
);
}
@@ -243,4 +275,12 @@ class BuyOutOfProvinceLogic extends GetxController {
await rootLogic.onRefresh();
await getStewardPurchaseOutOfProvince();
}
void toggleExpansion({int? index}) {
if (expandedListIndex.value == index || index == null) {
expandedListIndex.value = -1; // Collapse if the same index is tapped
} else {
expandedListIndex.value = index; // Expand the new index
}
}
}

View File

@@ -43,15 +43,15 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
var item = data.value.data!.results![index];
return ObxValue((val) {
return ExpandableListItem2(
selected: val.contains(index),
onTap: () => controller.isExpandedList.toggle(index),
selected: val.value == index,
onTap: () => controller.toggleExpansion(index: index),
index: index,
child: itemListWidget(item),
secondChild: itemListExpandedWidget(item),
labelColor: AppColor.blueLight,
labelIcon: Assets.vec.truckFastOutlinedSvg.path,
);
}, controller.isExpandedList);
}, controller.expandedListIndex);
},
itemCount: data.value.data?.results?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
@@ -380,6 +380,16 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
SeparatorInputFormatter(),
],
),
UnitTextField(
controller: controller.carcassCountController,
hint: 'حجم',
unit: 'قطعه',
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
SeparatorInputFormatter(),
],
),
],
),
),

View File

@@ -15,7 +15,7 @@ import 'package:rasadyar_core/core.dart';
class SalesOutOfProvinceLogic extends GetxController {
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
SaleLogic get saleLogic => Get.find<SaleLogic>();
SaleLogic saleLogic = Get.find<SaleLogic>();
@@ -148,7 +148,7 @@ class SalesOutOfProvinceLogic extends GetxController {
Future<void> deleteStewardPurchaseOutOfProvince(String key) async {
await safeCall(
call: () => rootLogic.chickenRepository.deleteStewardPurchasesOutSideOfTheProvince(
call: () => rootLogic.chickenRepository.editStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!,
stewardFreeBarKey: key,
),

View File

@@ -32,45 +32,7 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
child: Column(
children: [
inventoryWidget(controller.rootLogic),
/*Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
spacing: 8,
children: [
Expanded(
child: _informationLabelCard(
title: 'مانده دولتی',
titleColor: AppColor.textColor,
borderColor: Color(0xFFFFAE00),
description: 356952222222.separatedByCommaFa,
iconPath: Assets.vec.cubeCardGovermentSvg.path,
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFD47A), Colors.white],
),
),
),
Expanded(
child: _informationLabelCard(
title: 'مانده آزاد',
borderColor: const Color(0xFF9758FF),
description: 9658554788.separatedByCommaFa,
unit: 'KG',
iconPath: Assets.vec.cubeCardFreeSvg.path,
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [const Color(0xFFD3B9FF), Colors.white],
),
),
),
],
),
),*/
ObxValue((data) {
return RPaginatedListView(
onLoadMore: () async => controller.getOutProvinceSales(true),

View File

@@ -148,7 +148,7 @@ class SalesOutOfProvinceSalesListLogic extends GetxController {
Future<void> deleteStewardPurchaseOutOfProvince(String key) async {
await safeCall(
call: () => rootLogic.chickenRepository
.deleteStewardPurchasesOutSideOfTheProvince(
.editStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!,
stewardFreeBarKey: key,
),

View File

@@ -19,6 +19,10 @@ extension XStringUtils on String {
return false;
}
}
String get faTitle {
return utilsMap[this] ?? this;
}
}
Map<String, String> utilsMap = {
@@ -30,4 +34,5 @@ Map<String, String> utilsMap = {
'pending': 'در انتظار',
'accepted': 'تایید شده',
'guild': 'صنف',
'governmental': 'دولتی',
};

View File

@@ -107,3 +107,44 @@ class ContainerBreadcrumb extends Breadcrumb {
);
}
}
/*
class _TriangleClipper extends CustomClipper<Path> {
final bool isFirst;
final bool isLast;
_TriangleClipper({required this.isFirst, required this.isLast});
@override
Path getClip(Size size) {
final Path path = Path();
if (isFirst) {
path.moveTo(20, 0);
path.lineTo(size.width, 0);
path.lineTo(size.width, size.height);
path.lineTo(20, size.height);
} else {
path.moveTo(20, 0);
path.lineTo(size.width, 0);
path.lineTo(size.width - 20, size.height / 2);
path.lineTo(size.width, size.height);
path.lineTo(20, size.height);
}
if (isLast) {
path.moveTo(0, 0);
path.lineTo(0, size.height);
} else {
path.moveTo(20, 0);
path.lineTo(0, size.height / 2);
path.lineTo(20, size.height);
}
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}*/

View File

@@ -1,7 +1,7 @@
name: rasadyar_app
description: "A new Flutter project."
publish_to: 'none'
version: 1.3.20+17
version: 1.3.21+18
environment:
sdk: ^3.9.2