feat : buy in province

This commit is contained in:
2025-07-07 11:38:37 +03:30
parent 21d3490d0c
commit 80dabe991d
23 changed files with 568 additions and 605 deletions

View File

@@ -33,26 +33,7 @@ class EnteringTheWarehouseLogic extends GetxController {
@override
void onReady() {
super.onReady();
getBarGeneralInformation();
getImportedEntried();
scrollControllerImportedLoad.addListener(() {
if (scrollControllerImportedLoad.position.pixels >=
scrollControllerImportedLoad.position.maxScrollExtent - 100) {
addPageImportedLoad.value = true;
getImportedEntried();
}
});
scrollControllerWaitingForArrival.addListener(() {
if (scrollControllerWaitingForArrival.position.pixels >=
scrollControllerWaitingForArrival.position.maxScrollExtent - 100) {
addPageWaitingForArrival.value = true;
}
});
}
Future<void> getBarGeneralInformation() async {
@@ -74,68 +55,6 @@ class EnteringTheWarehouseLogic extends GetxController {
Future<void> acceptEntried(String key) async {
var request = StewardAllocationRequest(
allocationKey: key,
checkAllocation: true,
state: 'accepted',
receiverRealNumberOfCarcasses: int.parse(
volumeController.text.isNotEmpty ? volumeController.text : '0',
),
receiverRealWeightOfCarcasses: int.parse(
weightController.text.isNotEmpty ? weightController.text : '0',
),
registrationCode: acceptType.value == 1
? int.parse(
authenticationCodeController.text.isNotEmpty
? authenticationCodeController.text
: '0',
)
: null,
weightLossOfCarcasses: int.parse(
weightLossController.text.isNotEmpty ? weightLossController.text : '0',
),
).toJson();
request.removeWhere((key, value) => value == null);
safeCall(
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
token: rootLogic.tokenService.accessToken.value!,
request: request,
),
onError: (error, stackTrace) {
eLog(error);
},
onSuccess: (result) {
clearControllers();
getBarGeneralInformation();
},
);
}
Future<void> denyEntried(String key) async {
var request = StewardAllocationRequest(
allocationKey: key,
checkAllocation: true,
state: 'rejected',
).toJson();
request.removeWhere((key, value) => value == null);
safeCall(
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
token: rootLogic.tokenService.accessToken.value!,
request: request,
),
onError: (error, stackTrace) {
eLog(error);
},
onSuccess: (result) {
getBarGeneralInformation();
},
);
}
Future<void> getImportedEntried() async {
if (isLoadingMoreImportedLoad.value || !hasMoreDataImportedLoad.value) {
@@ -146,7 +65,7 @@ class EnteringTheWarehouseLogic extends GetxController {
currentPageImportedLoad.value++;
}
safeCall(
/* safeCall(
call: () async => await rootLogic.chickenRepository.getImportedLoadsModel(
token: rootLogic.tokenService.accessToken.value!,
page: currentPageImportedLoad.value,
@@ -164,7 +83,7 @@ class EnteringTheWarehouseLogic extends GetxController {
isLoadingMoreImportedLoad.value = false;
}
},
);
);*/
}
clearControllers() {

View File

@@ -1,33 +0,0 @@
extension xStringUtils on String {
get faAllocationType {
final tmp = split('_');
tmp.insert(1, '_');
if (tmp.length > 1) {
return tmp.map((e) => utilsMap[e] ?? e).join(' ');
} else {
return utilsMap[this] ?? this;
}
}
get faItem => utilsMap[this] ?? this;
get buyerIsGuild {
final tmp = split('_');
if (tmp.length > 1) {
return tmp.last == 'guild';
} else {
return false;
}
}
}
Map<String, String> utilsMap = {
'killhouse': 'کشتارگاه',
'_': 'به',
'steward': 'مباشر',
'exclusive': 'اختصاصی',
'free': 'آزاد',
'pending': 'در انتظار',
'accepted': 'تایید شده',
'guild': 'صنف',
};

View File

@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart';
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
import 'package:rasadyar_chicken/presentation/pages/entering_the_warehouse/string_utils.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
@@ -22,7 +20,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
return generalBarInformation(data.value);
}, controller.barInformation),
importedLoads(),
// importedLoads(),
],
),
),
@@ -43,7 +41,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
),
),
SizedBox(height: 4),
/* ObxValue(
/* ObxValue(
(data) => data.isEmpty
? Container(
margin: const EdgeInsets.symmetric(vertical: 2),
@@ -135,14 +133,8 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
'کل ورودی به انبار (کیلوگرم)',
model.totalFreeBarsCarcassesWeight.toString(),
),
buildRow(
'کل فروش (کیلوگرم)',
model.realAllocatedWeight.toString(),
),
buildRow(
'مانده انبار (کیلوگرم)',
model.totalRemainWeight.toString(),
),
buildRow('کل فروش (کیلوگرم)', model.realAllocatedWeight.toString()),
buildRow('مانده انبار (کیلوگرم)', model.totalRemainWeight.toString()),
],
),
),
@@ -161,9 +153,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
child: Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
Flexible(
@@ -172,9 +162,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
value,
textAlign: TextAlign.left,
style: AppFonts.yekan14.copyWith(
color: AppColor.darkGreyDarkHover,
),
style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover),
),
),
],
@@ -209,14 +197,8 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
buildRow(
'تعداد کل بارها',
model.totalBars!.toInt().toString(),
),
buildRow(
'وزن کل بارها (کیلوگرم)',
model.totalBarsWeight!.toInt().toString(),
),
buildRow('تعداد کل بارها', model.totalBars!.toInt().toString()),
buildRow('وزن کل بارها (کیلوگرم)', model.totalBarsWeight!.toInt().toString()),
buildRow(
'تعداد کل بارهای وارد شده',
model.totalEnteredBars!.toInt().toString(),
@@ -231,14 +213,9 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
),
buildRow(
'وزن کل بار وارد نشده (کیلوگرم)',
model.totalNotEnteredKillHouseRequestsWeight!
.toInt()
.toString(),
),
buildRow(
'تعداد کل بارهای رد شده',
model.totalRejectedBars!.toInt().toString(),
model.totalNotEnteredKillHouseRequestsWeight!.toInt().toString(),
),
buildRow('تعداد کل بارهای رد شده', model.totalRejectedBars!.toInt().toString()),
buildRow(
' وزن کل بارهای رد شده',
model.totalRejectedBarsWeight!.toInt().toString(),
@@ -251,7 +228,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
);
}
/* Widget waitingForArrival() {
/* Widget waitingForArrival() {
return Column(
children: [
const SizedBox(height: 8),
@@ -400,153 +377,72 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
);
}*/
Widget importedLoads() {
return Column(
children: [
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Align(
alignment: Alignment.centerRight,
child: Text(
'بارهای وارد شده',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
),
/* Widget importedLoads() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildRow('ردیف', '${index + 1}'),
buildRow(
'تاریخ ثبت',
result.date!.formattedJalaliDate ?? 'N/A',
),
),
ObxValue((data) {
if (data.value == null) {
return Container(
height: 80,
margin: const EdgeInsets.all(8),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.blueNormal, width: 1),
),
child: Center(child: CircularProgressIndicator()),
);
} else if (data.value?.results?.isEmpty ?? true) {
return Container(
height: 80,
margin: const EdgeInsets.all(8),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.blueNormal, width: 1),
),
child: Center(child: Text('هیچ بار وارد شده‌ای وجود ندارد')),
);
} else {
return Container(
margin: const EdgeInsets.symmetric(vertical: 2),
height: 700,
padding: const EdgeInsets.all(6),
child: ListView.separated(
controller: controller.scrollControllerImportedLoad,
padding: const EdgeInsets.all(8.0),
itemCount: data.value!.results!.length + 1,
itemBuilder: (BuildContext context, int index) {
if (index == data.value!.results!.length) {
return Obx(
() => controller.isLoadingMoreImportedLoad.value
? const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Center(child: CircularProgressIndicator()),
)
: const SizedBox(),
);
}
final result = data.value!.results![index];
return Card(
color: Colors.white,
margin: const EdgeInsets.symmetric(vertical: 4.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
color: AppColor.blueNormal,
width: 1,
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildRow('ردیف', '${index + 1}'),
buildRow(
'تاریخ ثبت',
result.date!.formattedJalaliDate ?? 'N/A',
),
buildRow(
'نوع تخصیص',
result.allocationType?.faAllocationType ?? 'N/A',
),
buildRow(
'مشخصات خریدار',
'${result.toSteward?.user?.fullname} - ${result.toSteward?.guildsName}' ??
'N/A',
),
buildRow(
'مشخصات فروشنده',
result.killHouse?.name ?? 'N/A',
),
buildRow(
'نوع فروش',
result.sellType?.faItem ?? 'N/A',
),
buildRow(
'قیمت هر کیلو',
'${result.amount ?? 0} ریال ',
),
buildRow(
'قیمت کل',
'${result.totalAmount ?? 0} ریال',
),
buildRow(
'وزن تخصیصی',
'${result.weightOfCarcasses?.toInt() ?? 0} کیلوگرم',
),
buildRow(
'کداحراز',
result.registrationCode?.toString() ?? 'N/A',
),
buildRow(
'وضعیت کد احراز',
result.systemRegistrationCode == true
? "ارسال شده"
: "ارسال نشده" ?? 'N/A',
),
buildRow(
'افت وزن(کیلوگرم)',
result.weightLossOfCarcasses?.toInt().toString() ??
'N/A',
),
buildRow(
'وضعیت',
result.receiverState?.faItem ?? 'N/A',
),
],
),
),
);
},
separatorBuilder: (BuildContext context, int index) =>
SizedBox(height: 8),
),
);
}
}, controller.importedLoads),
],
buildRow(
'نوع تخصیص',
result.allocationType?.faAllocationType ?? 'N/A',
),
buildRow(
'مشخصات خریدار',
'${result.toSteward?.user?.fullname} - ${result.toSteward?.guildsName}' ??
'N/A',
),
buildRow(
'مشخصات فروشنده',
result.killHouse?.name ?? 'N/A',
),
buildRow(
'نوع فروش',
result.sellType?.faItem ?? 'N/A',
),
buildRow(
'قیمت هر کیلو',
'${result.amount ?? 0} ریال ',
),
buildRow(
'قیمت کل',
'${result.totalAmount ?? 0} ریال',
),
buildRow(
'وزن تخصیصی',
'${result.weightOfCarcasses?.toInt() ?? 0} کیلوگرم',
),
buildRow(
'کداحراز',
result.registrationCode?.toString() ?? 'N/A',
),
buildRow(
'وضعیت کد احراز',
result.systemRegistrationCode == true
? "ارسال شده"
: "ارسال نشده" ?? 'N/A',
),
buildRow(
'افت وزن(کیلوگرم)',
result.weightLossOfCarcasses?.toInt().toString() ??
'N/A',
),
buildRow(
'وضعیت',
result.receiverState?.faItem ?? 'N/A',
),
],
),
);
}
}*/
/* Widget acceptBottomSheet(ResultModel resultModel) {
/* Widget acceptBottomSheet(ResultModel resultModel) {
return BaseBottomSheet(
height: 500,
child: Column(