feat: changed like production date and quota and sale Type

This commit is contained in:
2025-11-01 08:26:33 +03:30
parent 4bc356a0df
commit 627497a840
16 changed files with 731 additions and 571 deletions

View File

@@ -82,45 +82,47 @@ class ProfilePage extends GetView<ProfileLogic> {
} else if (data.value.status == ResourceStatus.error) {
return ErrorWidget('خطا در دریافت اطلاعات کاربر');
} else if (data.value.status == ResourceStatus.success) {
return Column(
spacing: 6,
children: [
ObxValue((isOpen) {
return GestureDetector(
onTap: () => isOpen.toggle(),
child: AnimatedContainer(
height: isOpen.value ? 320.h : 47.h,
duration: Duration(milliseconds: 500),
curve: Curves.linear,
child: userProfileInformation(data.value),
),
);
}, controller.isUserInformationOpen),
Visibility(
visible:
data.value.data?.unitName != null ||
data.value.data?.unitAddress != null ||
data.value.data?.unitPostalCode != null ||
data.value.data?.unitRegistrationNumber != null ||
data.value.data?.unitEconomicalNumber != null ||
data.value.data?.unitCity != null ||
data.value.data?.unitProvince != null ||
data.value.data?.unitNationalId != null,
child: ObxValue((isOpen) {
return SingleChildScrollView(
child: Column(
spacing: 6,
children: [
ObxValue((isOpen) {
return GestureDetector(
onTap: () => isOpen.toggle(),
child: AnimatedContainer(
height: isOpen.value ? 320.h : 47.h,
duration: Duration(milliseconds: 500),
curve: Curves.linear,
child: unitInformation(data.value),
child: userProfileInformation(data.value),
),
);
}, controller.isUnitInformationOpen),
),
],
}, controller.isUserInformationOpen),
Visibility(
visible:
data.value.data?.unitName != null ||
data.value.data?.unitAddress != null ||
data.value.data?.unitPostalCode != null ||
data.value.data?.unitRegistrationNumber != null ||
data.value.data?.unitEconomicalNumber != null ||
data.value.data?.unitCity != null ||
data.value.data?.unitProvince != null ||
data.value.data?.unitNationalId != null,
child: ObxValue((isOpen) {
return GestureDetector(
onTap: () => isOpen.toggle(),
child: AnimatedContainer(
height: isOpen.value ? 320.h : 47.h,
duration: Duration(milliseconds: 500),
curve: Curves.linear,
child: unitInformation(data.value),
),
);
}, controller.isUnitInformationOpen),
),
],
),
);
} else {
return SizedBox.shrink();

View File

@@ -113,7 +113,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
spacing: 3,
children: [
Text(
(item.approvedPriceStatus ?? false) ? 'مصوب' : 'آزاد',
(item.approvedPriceStatus ?? false) ? 'دولتی' : 'آزاد',
style: AppFonts.yekan12Bold.copyWith(
color: (item.approvedPriceStatus ?? false)
? AppColor.blueNormal
@@ -206,6 +206,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
),
buildRow(title: 'نوع تخصیص', value: item.allocationType?.faAllocationType ?? 'ندارد'),
buildRow(title: ' سهمیه', value: item.quota?.faTitle ?? 'ندارد'),
buildRow(title: 'نوع فروش', value: item.saleType == "governmental" ? 'دولتی' : 'آزاد'),
buildRow(title: 'محصول', value: item.product?.name ?? 'ندارد'),
buildRow(
title: 'تاریخ تولید گوشت',
@@ -217,7 +218,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
),
buildRow(
title: 'قیمت هر کیلوگرم',
titleLabel: (item.approvedPriceStatus ?? false) ? 'مصوب' : 'آزاد',
titleLabel: (item.approvedPriceStatus ?? false) ? 'دولتی' : 'آزاد',
titleLabelStyle: AppFonts.yekan14Bold.copyWith(color: AppColor.greenNormal),
value: '${item.amount?.separatedByCommaFa} ریال',
),

View File

@@ -151,6 +151,10 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
title: 'وزن خریداری شده',
value: '${item.weightOfCarcasses?.separatedByCommaFa} کیلوگرم',
),
buildRow(
title: 'حجم خریداری شده',
value: '${item.numberOfCarcasses?.separatedByCommaFa} قطعه',
),
buildRowOnTapped(
title: 'مشاهده بارنامه',
titleStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),

View File

@@ -437,7 +437,7 @@ class SalesInProvinceLogic extends GetxController {
toggleExpansion();
currentPage.value = 1;
hasMoreDataAllocationsMade.value = true;
await Future.wait([getAllocatedMade(), rootLogic.onRefresh()]);
await Future.wait([getAllocatedMade(), getRolesProducts(), rootLogic.onRefresh()]);
}
void toggleExpansion({int? index}) {

View File

@@ -154,14 +154,14 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
spacing: 4,
children: [
Text(
controller.getBuyerInformation(item)?.user?.fullname ?? 'N/Aشششش',
controller.getBuyerInformation(item)?.user?.fullname ?? 'نداردشششش',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
SizedBox(height: 2),
Text(
item.createDate?.formattedJalaliDate ?? 'N/A',
item.createDate?.formattedJalaliDate ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
),
@@ -226,14 +226,6 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
: AppColor.greenNormal,
),
),
Visibility(
visible: item.productionDate != null,
child: Text(
item.productionDate?.formattedJalaliDate ?? '-',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
),
),
],
),
),
@@ -254,7 +246,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
controller.getBuyerInformation(item)?.user?.fullname ?? 'N/A',
controller.getBuyerInformation(item)?.user?.fullname ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
),
@@ -294,12 +286,12 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
spacing: 3,
children: [
Text(
item.date?.toJalali.formatter.wN ?? 'N/A',
item.date?.toJalali.formatter.wN ?? 'ندارد',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
Text(
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}',
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'ندارد'}',
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
],
@@ -311,7 +303,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
),
Text(
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}',
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'ندارد'}',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
],
@@ -319,20 +311,30 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
),
buildRow(
title: 'تلفن خریدار',
value: controller.getBuyerInformation(item)?.user?.mobile ?? 'N/A',
value: controller.getBuyerInformation(item)?.user?.mobile ?? 'ندارد',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'),
buildRow(title: 'نوع فروش', value: item.sellType?.faItem ?? 'N/A'),
buildRow(title: 'محصول', value: item.product?.name ?? 'ندارد'),
buildRow(
title: 'تاریخ تولید گوشت',
value: item.productionDate?.toJalali.formatCompactDate() ?? 'ندارد',
),
buildRow(title: 'نوع تخصیص', value: item.allocationType?.faAllocationType ?? 'ندارد'),
buildRow(
title: 'نوع فروش',
value: (item.approvedPriceStatus ?? false) ? 'دولتی' : 'آزاد',
),
buildRow(title: 'نوع انبار', value: (item.quota == 'governmental') ? 'دولتی' : 'آزاد'),
buildRow(title: 'نوع تخصیص', value: item.allocationType?.faAllocationType ?? 'N/A'),
buildRow(
title: 'وزن خریداری شده',
value: '${item.weightOfCarcasses?.separatedByCommaFa} کیلوگرم',
),
buildRow(
title: 'افت وزن(کیلوگرم)',
value: item.weightLossOfCarcasses?.toInt().toString() ?? 'N/A',
value: item.weightLossOfCarcasses?.toInt().toString() ?? 'ندارد',
),
buildRow(
title: 'قیمت هر کیلوگرم',
@@ -482,33 +484,25 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
child: Column(
spacing: 12,
children: [
Visibility(
visible: isEditMode == false,
child: Column(
spacing: 12,
children: [
const SizedBox(height: 8),
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.fromDateFilter.value = value;
controller.fromDateFilter.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: (data.value ?? Jalali.now()).formatCompactDate(),
);
}, controller.fromDateFilter),
],
),
),
const SizedBox(height: 8),
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.fromDateFilter.value = value;
controller.fromDateFilter.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: (data.value ?? Jalali.now()).formatCompactDate(),
);
}, controller.fromDateFilter),
RTextField(
controller: controller.weightController,
@@ -533,6 +527,136 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
},
label: 'وزن لاشه (کیلوگرم)',
),
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ تولید گوشت',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.productionData.value = value;
controller.productionData.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: data.value?.formatCompactDate(),
);
}, controller.productionData),
Visibility(
visible: isEditMode == false,
child: Column(
spacing: 12,
children: [
SizedBox(height: 12.h),
Container(
height: 58.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع انبار")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.quotaType.value,
onChanged: (value) {
controller.quotaType.value = value!;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Row(
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
],
),
),
Expanded(
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
],
),
),
],
),
);
}),
],
),
),
SizedBox(height: 12.h),
Container(
height: 58.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع فروش")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.priceType.value,
onChanged: (value) {
controller.priceType.value = value!;
},
child: Row(
children: [
Expanded(
child: Row(
children: [
Radio(value: 1),
Text('قیمت دولتی', style: AppFonts.yekan14),
],
),
),
Expanded(
child: Row(
children: [
Radio(value: 2),
Text('قیمت آزاد', style: AppFonts.yekan14),
],
),
),
],
),
);
}),
],
),
),
],
),
),
Obx(() {
return Visibility(
visible: controller.broadcastPrice.value?.active == true,
@@ -546,7 +670,9 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
],
filledColor: AppColor.bgLight,
filled: true,
enabled: (controller.priceType.value == 2),
enabled:
(controller.priceType.value == 2 ||
(controller.selectedProductModel.value?.approvedPriceStatus == false)),
onChanged: (p0) {
controller.pricePerKilo.value = int.tryParse(p0.clearComma) ?? 0;
},
@@ -572,129 +698,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
],
),
),
const SizedBox(height: 12),
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ تولید گوشت',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.productionData.value = value;
controller.productionData.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: data.value?.formatCompactDate(),
);
}, controller.productionData),
SizedBox(height: 12.h),
Container(
height: 58.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع فروش")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.priceType.value,
onChanged: (value) {
controller.priceType.value = value!;
},
child: Row(
children: [
Expanded(
child: Row(
children: [
Radio(value: 1),
Text('قیمت دولتی', style: AppFonts.yekan14),
],
),
),
Expanded(
child: Row(
children: [
Radio(value: 2),
Text('قیمت آزاد', style: AppFonts.yekan14),
],
),
),
],
),
);
}),
],
),
),
SizedBox(height: 12.h),
Container(
height: 58.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع انبار")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.quotaType.value,
onChanged: (value) {
controller.quotaType.value = value!;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Row(
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
],
),
),
Expanded(
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
],
),
),
],
),
);
}),
],
),
),
SizedBox(height: 12.h),
ObxValue((data) {
return RElevated(
@@ -922,7 +926,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
children: [
buildRow(
title: 'تاریخ ثبت',
value: controller.tmpStewardAllocation?.date?.formattedJalaliDate ?? 'N/A',
value: controller.tmpStewardAllocation?.date?.formattedJalaliDate ?? 'ندارد',
),
buildRow(
title: 'نام و نام خانوادگی خریدار',
@@ -931,7 +935,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
.firstWhere((p0) => p0.key == controller.tmpStewardAllocation?.guildKey)
.user
?.fullname ??
'N/A',
'ندارد',
),
buildRow(
title: 'شماره خریدار',
@@ -940,7 +944,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
.firstWhere((p0) => p0.key == controller.tmpStewardAllocation?.guildKey)
.user
?.mobile ??
'N/A',
'ندارد',
),
buildRow(

View File

@@ -135,7 +135,7 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
spacing: 4,
children: [
Text(
item.date?.formattedJalaliDate ?? 'N/A',
item.date?.formattedJalaliDate ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
@@ -156,14 +156,14 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item.buyer?.fullname ?? 'N/A',
item.buyer?.fullname ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
SizedBox(height: 2),
Text(
item.buyer?.mobile ?? 'N/A',
item.buyer?.mobile ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
),
@@ -178,12 +178,12 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
spacing: 8,
children: [
Text(
item.buyer?.province ?? 'N/A',
item.buyer?.province ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
Text(
item.buyer?.city ?? 'N/A',
item.buyer?.city ?? 'ندارد',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
@@ -228,12 +228,12 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
spacing: 3,
children: [
Text(
item.date?.toJalali.formatter.wN ?? 'N/A',
item.date?.toJalali.formatter.wN ?? 'ندارد',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
Text(
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}',
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'ندارد'}',
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
],
@@ -245,15 +245,15 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
),
Text(
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}',
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'ندارد'}',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
],
),
),
buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'),
buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'),
buildRow(title: 'نام واحد', value: item.buyer?.unitName ?? 'N/A'),
buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'ندارد'),
buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'ندارد'),
buildRow(title: 'نام واحد', value: item.buyer?.unitName ?? 'ندارد'),
buildRow(
title: 'وزن لاشه ',
value: '${item.weightOfCarcasses?.separatedByCommaFa}',
@@ -264,6 +264,10 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
value: '${item.numberOfCarcasses?.separatedByCommaFa}',
valueLabel: 'قطعه',
),
buildRow(
title: 'تاریخ تولید گوشت',
value: item.productionDate?.toJalali.formatCompactDate() ?? 'ندارد',
),
buildRow(title: 'انبار فروش', value: '${item.quota?.faTitle}'),
buildRow(title: 'کد قرنطینه ', value: item.clearanceCode ?? 'بدون کد'),
@@ -362,26 +366,171 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
initText: data.value?.formatCompactDate(),
);
}, controller.saleDate),
Visibility(visible: isOnEdit == false, child: _buyerWidget()),
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ تولید گوشت',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.productionData.value = value;
controller.productionData.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: data.value?.formatCompactDate(),
);
}, controller.productionData),
_buyerWidget(),
RTextField(
controller: controller.quarantineCodeController,
label: 'کد قرنطینه',
borderColor: AppColor.darkGreyLight,
filledColor: AppColor.bgLight,
filled: true,
validator: (value) {
if (value == null) {
return 'لطفاً کد قرنطینه را وارد کنید';
}
return null;
},
),
Visibility(
visible: isOnEdit == false,
child: Column(
spacing: 12,
children: [
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ تولید گوشت',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.productionData.value = value;
controller.productionData.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: data.value?.formatCompactDate(),
);
}, controller.productionData),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع انبار")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.quotaType.value,
onChanged: (value) {
controller.quotaType.value = value ?? 0;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: GestureDetector(
onTap: () {
controller.quotaType.value = 1;
},
child: Row(
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
],
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
controller.quotaType.value = 2;
},
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
],
),
),
),
],
),
);
}),
],
),
),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع فروش")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.saleType.value,
onChanged: (value) {
controller.saleType.value = value ?? 0;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: GestureDetector(
onTap: () {
controller.saleType.value = 1;
},
child: Row(
children: [
Radio(value: 1),
Text('قیمت دولتی', style: AppFonts.yekan14),
],
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
controller.saleType.value = 2;
},
child: Row(
children: [
Radio(value: 2),
Text('قیمت آزاد', style: AppFonts.yekan14),
],
),
),
),
],
),
);
}),
],
),
),
],
),
),
RTextField(
controller: controller.saleWeightController,
label: 'وزن لاشه (کیلوگرم)',
@@ -423,139 +572,6 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
return null;
},
),
RTextField(
controller: controller.quarantineCodeController,
label: 'کد قرنطینه',
borderColor: AppColor.darkGreyLight,
filledColor: AppColor.bgLight,
filled: true,
validator: (value) {
if (value == null) {
return 'لطفاً کد قرنطینه را وارد کنید';
}
return null;
},
),
],
),
),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع فروش")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.saleType.value,
onChanged: (value) {
controller.saleType.value = value ?? 0;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
controller.saleType.value = 1;
},
child: Expanded(
child: Row(
children: [
Radio(value: 1),
Text('قیمت دولتی', style: AppFonts.yekan14),
],
),
),
),
GestureDetector(
onTap: () {
controller.saleType.value = 2;
},
child: Expanded(
child: Row(
children: [
Radio(value: 2),
Text('قیمت آزاد', style: AppFonts.yekan14),
],
),
),
),
],
),
);
}),
],
),
),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع انبار")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.quotaType.value,
onChanged: (value) {
controller.quotaType.value = value ?? 0;
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
controller.quotaType.value = 1;
},
child: Row(
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
],
),
),
GestureDetector(
onTap: () {
controller.quotaType.value = 2;
},
child: Expanded(
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
],
),
),
),
],
),
);
}),
],
),
),

View File

@@ -22,7 +22,7 @@ class SegmentationLogic extends GetxController {
Rx<Jalali> toDateFilter = Jalali.now().obs;
RxnString searchedValue = RxnString();
RxInt segmentType = 1.obs;
RxInt saleType = 1.obs;
RxInt saleType = 2.obs;
RxInt quotaType = 1.obs;
GlobalKey<FormState> formKey = GlobalKey<FormState>();
TextEditingController weightController = TextEditingController(text: '0');
@@ -35,6 +35,8 @@ class SegmentationLogic extends GetxController {
Resource<PaginationModel<SegmentationModel>>.loading().obs;
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
Rxn<Jalali?> productionData = Rxn();
Rx<Jalali> saleDate = Jalali.now().obs;
@override
void onInit() {
@@ -83,6 +85,7 @@ class SegmentationLogic extends GetxController {
weightController.text = '0';
selectedSegment.value = null;
selectedGuildModel.value = null;
productionData.value = null;
segmentType.value = 1;
saleType.value = 1;
quotaType.value = 1;
@@ -111,6 +114,8 @@ class SegmentationLogic extends GetxController {
}
await safeCall(
showError: true,
showSuccess: true,
call: () async => await rootLogic.chickenRepository.getSegmentation(
token: rootLogic.tokenService.accessToken.value!,
queryParameters: buildQueryParams(
@@ -148,7 +153,8 @@ class SegmentationLogic extends GetxController {
Future<void> deleteSegmentation(String key) async {
await safeCall(
showError: false,
showError: true,
showSuccess: true,
call: () => rootLogic.chickenRepository.deleteSegmentation(
token: rootLogic.tokenService.accessToken.value!,
key: key,
@@ -165,6 +171,7 @@ class SegmentationLogic extends GetxController {
model: SegmentationModel(
key: selectedSegment.value?.key,
weight: int.tryParse(weightController.text.clearComma) ?? 0,
productionDate: productionData.value?.toDateTime().formattedDashedGregorian,
),
),
onSuccess: (result) {
@@ -189,7 +196,14 @@ class SegmentationLogic extends GetxController {
if (segmentType.value == 2) {
segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
}
if (productionData.value != null) {
segmentationModel = segmentationModel.copyWith(
productionDate: productionData.value?.toDateTime().formattedDashedGregorian,
);
}
await safeCall(
showError: true,
showSuccess: true,
call: () async => await rootLogic.chickenRepository.createSegmentation(
token: rootLogic.tokenService.accessToken.value!,
model: segmentationModel,

View File

@@ -91,7 +91,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
spacing: 4,
children: [
Text(
item.toGuild != null ? 'مباشر' : 'قطعه‌بند',
item.toGuild != null ? 'قطعه‌بند' : 'مباشر',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
@@ -131,11 +131,27 @@ class SegmentationPage extends GetView<SegmentationLogic> {
SizedBox(width: 4),
Expanded(
flex: 2,
child: Text(
item.weight.separatedByCommaFa.addKg,
textAlign: TextAlign.center,
textDirection: TextDirection.ltr,
style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueNormal),
child: Column(
spacing: 4,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item.weight.separatedByCommaFa.addKg,
textAlign: TextAlign.center,
textDirection: TextDirection.ltr,
style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueNormal),
),
Text(
item.saleType == "governmental" ? 'دولتی' : 'آزاد',
textAlign: TextAlign.center,
textDirection: TextDirection.ltr,
style: AppFonts.yekan14Bold.copyWith(
color: item.saleType == "governmental"
? AppColor.blueNormal
: AppColor.greenNormal,
),
),
],
),
),
],
@@ -207,7 +223,14 @@ class SegmentationPage extends GetView<SegmentationLogic> {
? item.toGuild?.guildsName ?? 'N/A'
: item.buyer?.shop ?? 'N/A',
),
buildRow(title: 'ماهیت', value: item.toGuild != null ? 'مباشر' : 'قطعه‌بند'),
buildRow(title: 'ماهیت', value: item.toGuild != null ? 'قطعه‌بند' : 'مباشر'),
buildRow(title: 'نوع فروش', value: item.saleType == "governmental" ? 'دولتی' : 'آزاد'),
buildRow(title: 'انبار فروش', value: item.quota == "governmental" ? 'دولتی' : 'آزاد'),
buildRow(
title: 'تاریخ تولید گوشت',
value: item.productionDate?.toJalali.formatCompactDate() ?? 'ندارد',
),
buildRow(
title: 'وزن قطعه‌بندی',
value: item.weight!.separatedByCommaFa,
@@ -260,7 +283,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
Widget addOrEditBottomSheet([bool isOnEdit = false]) {
return BaseBottomSheet(
height: 550.h,
height: isOnEdit ? 350.h : 650.h,
child: SingleChildScrollView(
child: Form(
key: controller.formKey,
@@ -272,168 +295,201 @@ class SegmentationPage extends GetView<SegmentationLogic> {
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
),
_productDropDown(),
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
Visibility(
visible: isOnEdit == false,
child: Column(
spacing: 12,
children: [
const SizedBox(height: 8),
SizedBox(
height: 40,
child: ObxValue((data) {
return RadioGroup(
onChanged: (value) {
controller.segmentType.value = value!;
controller.selectedGuildModel.value = null;
controller.selectedGuildModel.refresh();
},
groupValue: controller.segmentType.value,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Radio(value: 1),
Text('قطعه‌بندی(کاربر)', style: AppFonts.yekan14),
SizedBox(width: 12),
Radio(value: 2),
Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14),
],
),
);
}, controller.saleType),
),
const SizedBox(height: 12),
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
ObxValue((data) {
return Visibility(visible: data.value == 2, child: guildsDropDown());
}, controller.segmentType),
],
),
),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع فروش")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.saleType.value,
onChanged: (value) {
controller.saleType.value = value ?? 0;
controller.selectedGuildModel.value = null;
controller.selectedGuildModel.refresh();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
controller.saleType.value = 1;
},
child: Expanded(
child: Column(
children: [
const SizedBox(height: 8),
SizedBox(
height: 40,
child: ObxValue((data) {
return RadioGroup(
onChanged: (value) {
controller.segmentType.value = value!;
controller.selectedGuildModel.value = null;
controller.selectedGuildModel.refresh();
},
groupValue: controller.segmentType.value,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Radio(value: 1),
Text('قیمت دولتی', style: AppFonts.yekan14),
],
),
),
),
GestureDetector(
onTap: () {
controller.saleType.value = 2;
},
child: Expanded(
child: Row(
children: [
Text('قطعه‌بندی(کاربر)', style: AppFonts.yekan14),
SizedBox(width: 12),
Radio(value: 2),
Text('قیمت آزاد', style: AppFonts.yekan14),
Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14),
],
),
),
),
],
),
);
}),
],
),
),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع انبار")),
top: -10,
right: 8,
);
}, controller.saleType),
),
const SizedBox(height: 12),
ObxValue((data) {
return Visibility(visible: data.value == 2, child: guildsDropDown());
}, controller.segmentType),
],
),
),
Obx(() {
return RadioGroup(
groupValue: controller.quotaType.value,
onChanged: (value) {
controller.quotaType.value = value ?? 0;
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ تولید گوشت',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.productionData.value = value;
controller.productionData.refresh();
}),
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
controller.quotaType.value = 1;
borderColor: AppColor.darkGreyLight,
initText: data.value?.formatCompactDate(),
);
}, controller.productionData),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع فروش")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.saleType.value,
onChanged: (value) {
controller.saleType.value = 2 ?? 0;
controller.selectedGuildModel.value = null;
controller.selectedGuildModel.refresh();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
Expanded(
child: GestureDetector(
onTap: () {
//controller.saleType.value = 1;
},
child: Row(
children: [
Radio(value: 1, enabled: false),
Text(
'قیمت دولتی',
style: AppFonts.yekan14.copyWith(
color: AppColor.mediumGreyDark,
),
),
],
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
controller.saleType.value = 2;
},
child: Row(
children: [
Radio(value: 2),
Text('قیمت آزاد', style: AppFonts.yekan14),
],
),
),
),
],
),
),
GestureDetector(
onTap: () {
controller.quotaType.value = 2;
);
}),
],
),
),
Container(
height: 50.h,
clipBehavior: Clip.none,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Stack(
fit: StackFit.expand,
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
Positioned(
child: Container(color: Colors.white, child: Text("نوع انبار")),
top: -10,
right: 8,
),
Obx(() {
return RadioGroup(
groupValue: controller.quotaType.value,
onChanged: (value) {
controller.quotaType.value = value ?? 0;
},
child: Expanded(
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: GestureDetector(
onTap: () {
controller.quotaType.value = 1;
},
child: Row(
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
],
),
),
),
Expanded(
child: GestureDetector(
onTap: () {
controller.quotaType.value = 2;
},
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
],
),
),
),
],
),
),
],
),
);
}),
);
}),
],
),
),
],
),
),
@@ -551,4 +607,59 @@ class SegmentationPage extends GetView<SegmentationLogic> {
);
});
}
Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
Jalali? tempPickedDate;
return Container(
height: 250,
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
child: Row(
children: [
SizedBox(width: 20),
RElevated(
height: 35,
width: 70,
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
onPressed: () {
onDateSelected(tempPickedDate ?? Jalali.now());
Get.back();
},
text: 'تایید',
),
Spacer(),
RElevated(
height: 35,
width: 70,
backgroundColor: AppColor.error,
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
onPressed: () {
onDateSelected(tempPickedDate ?? Jalali.now());
Get.back();
},
text: 'لغو',
),
SizedBox(width: 20),
],
),
),
Divider(height: 0, thickness: 1),
Expanded(
child: Container(
child: PersianCupertinoDatePicker(
initialDateTime: controller.saleDate.value,
mode: PersianCupertinoDatePickerMode.date,
onDateTimeChanged: (dateTime) {
tempPickedDate = dateTime;
},
),
),
),
],
),
);
}
}