feat : new segment logic
This commit is contained in:
@@ -35,7 +35,6 @@ class SegmentationLogic extends GetxController {
|
||||
|
||||
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -82,12 +81,16 @@ class SegmentationLogic extends GetxController {
|
||||
void clearForm() {
|
||||
weightController.text = '0';
|
||||
selectedSegment.value = null;
|
||||
selectedGuildModel.value = null;
|
||||
}
|
||||
|
||||
void validateForm() {
|
||||
var weight = int.tryParse(weightController.text.clearComma.trim());
|
||||
isSubmitButtonEnabled.value =
|
||||
selectedProduct.value != null && weightController.text.isNotEmpty && weight! > 0;
|
||||
selectedProduct.value != null &&
|
||||
weightController.text.isNotEmpty &&
|
||||
weight! > 0 &&
|
||||
(saleType.value == 1 || (saleType.value == 2 && selectedGuildModel.value != null));
|
||||
}
|
||||
|
||||
Future<void> getAllSegmentation([bool isLoadingMore = false]) async {
|
||||
@@ -177,9 +180,9 @@ class SegmentationLogic extends GetxController {
|
||||
weight: int.tryParse(weightController.text.clearComma) ?? 0,
|
||||
);
|
||||
if (saleType.value == 2) {
|
||||
segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
|
||||
segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
|
||||
}
|
||||
safeCall(
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.createSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
model: segmentationModel,
|
||||
|
||||
@@ -83,10 +83,21 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item.date?.formattedJalaliDate ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
item.toGuild != null ? 'مباشر' : 'قطعهبند',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.date?.formattedJalaliDate ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
@@ -96,14 +107,18 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
item.buyer?.fullname ?? 'N/A',
|
||||
item.toGuild != null
|
||||
? item.toGuild?.user?.fullname ?? 'N/A'
|
||||
: item.buyer?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
|
||||
SizedBox(height: 2),
|
||||
Text(
|
||||
item.buyer?.shop ?? 'N/A',
|
||||
item.toGuild != null
|
||||
? item.toGuild?.guildsName ?? 'N/A'
|
||||
: item.buyer?.shop ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
@@ -111,18 +126,10 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
item.date?.formattedJalaliDate,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
'${item.weight} KG',
|
||||
'${item.weight.separatedByComma} KG',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
@@ -178,9 +185,25 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
],
|
||||
),
|
||||
),
|
||||
buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'),
|
||||
buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'),
|
||||
buildRow(title: 'نام واحد', value: item.buyer?.shop ?? 'N/A'),
|
||||
buildRow(
|
||||
title: 'مشخصات خریدار',
|
||||
value: item.toGuild != null
|
||||
? item.toGuild?.user?.fullname ?? 'N/A'
|
||||
: item.buyer?.fullname ?? 'N/A',
|
||||
),
|
||||
buildRow(
|
||||
title: 'تلفن خریدار',
|
||||
value: item.toGuild != null
|
||||
? item.toGuild?.user?.mobile ?? 'N/A'
|
||||
: item.buyer?.mobile ?? 'N/A',
|
||||
),
|
||||
buildRow(
|
||||
title: 'نام واحد',
|
||||
value: item.toGuild != null
|
||||
? item.toGuild?.guildsName ?? 'N/A'
|
||||
: item.buyer?.shop ?? 'N/A',
|
||||
),
|
||||
buildRow(title: 'ماهیت', value: item.toGuild != null ? 'مباشر' : 'قطعهبند'),
|
||||
buildRow(title: 'وزن قطعهبندی', value: '${item.weight?.separatedByComma}'),
|
||||
|
||||
Row(
|
||||
@@ -268,7 +291,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
controller.selectedGuildModel.refresh();
|
||||
},
|
||||
),
|
||||
Text('خودم', style: AppFonts.yekan14),
|
||||
Text('قطعهبندی(مباشر)', style: AppFonts.yekan14),
|
||||
SizedBox(width: 12),
|
||||
Radio(
|
||||
value: 2,
|
||||
@@ -277,7 +300,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
controller.saleType.value = value!;
|
||||
},
|
||||
),
|
||||
Text('صنف/مباشر', style: AppFonts.yekan14),
|
||||
Text('تخصیص به قطعهبند', style: AppFonts.yekan14),
|
||||
],
|
||||
);
|
||||
}, controller.saleType),
|
||||
|
||||
Reference in New Issue
Block a user