From 34ce98d31fd9dfda7235f0c4c88957acbe593a66 Mon Sep 17 00:00:00 2001 From: MrM Date: Fri, 6 Jun 2025 09:27:11 +0330 Subject: [PATCH] some change --- .../steward_free_bar/steward_free_bar.dart | 152 +++++ .../steward_free_bar_dashboard.dart | 17 + .../lib/presentation/pages/root/view.dart | 4 +- .../pages/sales_with_out_province/logic.dart | 205 ++++++ .../pages/sales_with_out_province/view.dart | 604 ++++++++++++++++++ .../lib/presentation/routes/pages.dart | 14 +- .../lib/presentation/routes/routes.dart | 1 + 7 files changed, 995 insertions(+), 2 deletions(-) create mode 100644 packages/chicken/lib/data/models/response/steward_free_bar/steward_free_bar.dart create mode 100644 packages/chicken/lib/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart create mode 100644 packages/chicken/lib/presentation/pages/sales_with_out_province/logic.dart create mode 100644 packages/chicken/lib/presentation/pages/sales_with_out_province/view.dart diff --git a/packages/chicken/lib/data/models/response/steward_free_bar/steward_free_bar.dart b/packages/chicken/lib/data/models/response/steward_free_bar/steward_free_bar.dart new file mode 100644 index 0000000..359451a --- /dev/null +++ b/packages/chicken/lib/data/models/response/steward_free_bar/steward_free_bar.dart @@ -0,0 +1,152 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'steward_free_bar.freezed.dart'; +part 'steward_free_bar.g.dart'; + +@freezed +abstract class StewardFreeBar with _$StewardFreeBar { + const factory StewardFreeBar({ + int? count, + String? next, + String? previous, + List? results, + }) = _StewardFreeBar; + + factory StewardFreeBar.fromJson(Map json) => + _$StewardFreeBarFromJson(json); +} + +@freezed +abstract class Result with _$Result { + const factory Result({ + int? id, + Steward? steward, + dynamic guild, + Product? product, + String? key, + String? create_date, + String? modify_date, + bool? trash, + String? kill_house_name, + String? kill_house_mobile, + String? kill_house_vet_name, + String? kill_house_vet_mobile, + String? province, + String? city, + String? driver_name, + String? driver_mobile, + dynamic car, + String? pelak, + int? number_of_carcasses, + int? weight_of_carcasses, + String? bar_image, + String? date, + bool? temporary_trash, + bool? temporary_deleted, + String? created_by, + String? modified_by, + }) = _Result; + + factory Result.fromJson(Map json) => _$ResultFromJson(json); +} + +@freezed +abstract class Steward with _$Steward { + const factory Steward({ + User? user, + String? guilds_name, + bool? steward, + dynamic allocation_limit, + Address? address, + String? license_number, + String? type_activity, + String? area_activity, + String? guilds_id, + String? create_date, + }) = _Steward; + + factory Steward.fromJson(Map json) => _$StewardFromJson(json); +} + +@freezed +abstract class User with _$User { + const factory User({ + String? fullname, + String? first_name, + String? last_name, + int? base_order, + String? mobile, + String? national_id, + String? national_code, + String? key, + City? city, + String? unit_name, + String? unit_national_id, + String? unit_registration_number, + String? unit_economical_number, + String? unit_province, + String? unit_city, + String? unit_postal_code, + String? unit_address, + }) = _User; + + factory User.fromJson(Map json) => _$UserFromJson(json); +} + +@freezed +abstract class City with _$City { + const factory City({ + int? id, + String? key, + String? create_date, + String? modify_date, + bool? trash, + int? province_id_foreign_key, + int? city_id_key, + String? name, + int? product_price, + bool? province_center, + int? city_number, + String? city_name, + int? province_number, + String? province_name, + String? created_by, + String? modified_by, + int? province, + }) = _City; + + factory City.fromJson(Map json) => _$CityFromJson(json); +} + +@freezed +abstract class Address with _$Address { + const factory Address({ + Province? province, + City? city, + String? address, + String? postal_code, + }) = _Address; + + factory Address.fromJson(Map json) => _$AddressFromJson(json); +} + +@freezed +abstract class Province with _$Province { + const factory Province({ + String? key, + String? name, + }) = _Province; + + factory Province.fromJson(Map json) => + _$ProvinceFromJson(json); +} + +@freezed +abstract class Product with _$Product { + const factory Product({ + String? key, + String? name, + }) = _Product; + + factory Product.fromJson(Map json) => _$ProductFromJson(json); +} \ No newline at end of file diff --git a/packages/chicken/lib/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart b/packages/chicken/lib/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart new file mode 100644 index 0000000..11bcb46 --- /dev/null +++ b/packages/chicken/lib/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart @@ -0,0 +1,17 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'steward_free_bar_dashboard.freezed.dart'; +part 'steward_free_bar_dashboard.g.dart'; + +@freezed +abstract class StewardFreeBarDashboard with _$StewardFreeBarDashboard { + const factory StewardFreeBarDashboard({ + String? product, + int? totalBars, + double? totalQuantity, + double? totalWeight, + }) = _StewardFreeBarDashboard; + + factory StewardFreeBarDashboard.fromJson(Map json) => + _$StewardFreeBarDashboardFromJson(json); +} diff --git a/packages/chicken/lib/presentation/pages/root/view.dart b/packages/chicken/lib/presentation/pages/root/view.dart index 2fb3977..9fe687d 100644 --- a/packages/chicken/lib/presentation/pages/root/view.dart +++ b/packages/chicken/lib/presentation/pages/root/view.dart @@ -42,7 +42,9 @@ class RootPage extends GetView { cardWidget( title: 'فروش خارج استان', iconPath: Assets.icons.outside.path, - onTap: () {}, + onTap: () { + Get.toNamed(ChickenRoutes.salesWithOutProvince); + }, ), ], ), diff --git a/packages/chicken/lib/presentation/pages/sales_with_out_province/logic.dart b/packages/chicken/lib/presentation/pages/sales_with_out_province/logic.dart new file mode 100644 index 0000000..da14cb4 --- /dev/null +++ b/packages/chicken/lib/presentation/pages/sales_with_out_province/logic.dart @@ -0,0 +1,205 @@ +import 'package:flutter/material.dart'; +import 'package:rasadyar_auth/data/utils/safe_call.dart'; +import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart'; +import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart'; +import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; +import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; +import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart'; +import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; +import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart'; +import 'package:rasadyar_chicken/presentation/pages/root/logic.dart'; +import 'package:rasadyar_core/core.dart'; + +class SalesWithOutProvinceLogic extends GetxController { + var rootLogic = Get.find(); + Rxn allocatedMadeModel = Rxn(); + RxList rolesProductsModel = RxList(); + + RxList guildsModel = [].obs; + + Rxn stewardFreeDashboard = Rxn(); + + + @override + void onInit() { + super.onInit(); + rootLogic.getInventory(); + getAllocatedMade(); + getRolesProducts(); + getGuilds(); + getGuildProfile(); + ever(saleType, (callback) { + getGuilds(); + }); + + weight.listen((num) { + totalCost.value = num * pricePerKilo.value; + }); + + pricePerKilo.listen((num) { + totalCost.value = num * weight.value; + }); + + totalCost.listen((data) { + totalCostController.text = data.toString(); + + isValid.value = + weight.value > 0 && + pricePerKilo.value > 0 && + totalCost.value > 0 && + selectedProductModel.value != null && + selectedGuildModel.value != null; + }); + } + + Future getAllocatedMade() async { + safeCall( + call: () async => await rootLogic.chickenRepository.getAllocatedMade( + token: rootLogic.tokenService.accessToken.value!, + page: 1, + ), + onSuccess: (result) { + if (result != null) { + allocatedMadeModel.value = result; + } + }, + onError: (error, stacktrace) {}, + ); + } + + void checkVerfication() { + isValid.value = + weight.value > 0 && + pricePerKilo.value > 0 && + totalCost.value > 0 && + selectedProductModel.value != null && + selectedGuildModel.value != null; + } + + void confirmAllocation(ConformAllocation allocation) { + safeCall( + call: () async => await rootLogic.chickenRepository.confirmAllocation( + token: rootLogic.tokenService.accessToken.value!, + allocation: allocation.toJson(), + ), + onSuccess: (result) { + getAllocatedMade(); + }, + onError: (error, stacktrace) {}, + ); + } + + void denyAllocation(String token) { + safeCall( + call: () async => await rootLogic.chickenRepository.denyAllocation( + token: rootLogic.tokenService.accessToken.value!, + allocationToken: token, + ), + onSuccess: (result) { + getAllocatedMade(); + }, + onError: (error, stacktrace) {}, + ); + } + + Future confirmAllAllocations() async { + safeCall( + call: () async => await rootLogic.chickenRepository.confirmAllAllocation( + token: rootLogic.tokenService.accessToken.value!, + allocationTokens: + allocatedMadeModel.value?.results?.map((e) => e.key!).toList() ?? + [], + ), + onSuccess: (result) { + getAllocatedMade(); + }, + onError: (error, stacktrace) {}, + ); + } + + Future getRolesProducts() async { + safeCall( + call: () async => await rootLogic.chickenRepository.getRolesProducts( + token: rootLogic.tokenService.accessToken.value!, + ), + onSuccess: (result) { + if (result != null) { + rolesProductsModel.value = result; + } + }, + onError: (error, stacktrace) {}, + ); + } + + Future getGuilds() async { + safeCall( + call: () async => await rootLogic.chickenRepository.getGuilds( + token: rootLogic.tokenService.accessToken.value!, + isFree: saleType.value == 2 ? true : false, + ), + onSuccess: (result) { + if (result != null) { + guildsModel.clear(); + guildsModel.addAll(result); + } + }, + onError: (error, stacktrace) {}, + ); + } + + Future addSale() async {} + + void setSelectedGuild(GuildModel value) { + selectedGuildModel.value = value; + update(); + } + + void setSelectedProduct(ProductModel value) { + selectedProductModel.value = value; + update(); + } + + Future getGuildProfile() async { + await safeCall( + call: () async => await rootLogic.chickenRepository.getProfile( + token: rootLogic.tokenService.accessToken.value!, + ), + onError: (error, stackTrace) {}, + onSuccess: (result) { + guildProfile.value = result; + }, + ); + } + + Future submitAllocation() async { + SubmitStewardAllocation stewardAllocation = SubmitStewardAllocation( + approvedPriceStatus: false, + allocationType: + '${guildProfile.value?.steward == true ? "steward" : "guild"}-${selectedGuildModel.value?.steward == true ? "steward" : "guild"}', + sellerType: guildProfile.value?.steward == true ? "Steward" : "Guild", + buyerType: selectedGuildModel.value?.steward == true + ? "Steward" + : "Guild", + amount: pricePerKilo.value, + totalAmount: totalCost.value, + weightOfCarcasses: weight.value, + guildKey: selectedGuildModel.value?.key, + productKey: selectedProductModel.value?.key, + date: DateTime.now().formattedGregorianDate, + type: "manual", + ); + + safeCall( + call: () async => + await rootLogic.chickenRepository.postSubmitStewardAllocation( + token: rootLogic.tokenService.accessToken.value!, + request: stewardAllocation, + ), + + onSuccess: (result) { + getAllocatedMade(); + }, + onError: (error, stackTrace) {}, + ); + } +} diff --git a/packages/chicken/lib/presentation/pages/sales_with_out_province/view.dart b/packages/chicken/lib/presentation/pages/sales_with_out_province/view.dart new file mode 100644 index 0000000..5017f06 --- /dev/null +++ b/packages/chicken/lib/presentation/pages/sales_with_out_province/view.dart @@ -0,0 +1,604 @@ +import 'package:flutter/material.dart'; +import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart'; +import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; +import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart'; +import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; +import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart'; +import 'package:rasadyar_chicken/presentation/pages/entering_the_warehouse/string_utils.dart'; +import 'package:rasadyar_core/core.dart'; + +import 'logic.dart'; + +class SalesWithOutProvincePage extends GetView { + SalesWithOutProvincePage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: RAppBar(title: 'فروش خارج استان'), + body: SingleChildScrollView( + child: Column( + spacing: 10, + children: [ + ObxValue( + (model) => summaryOfInformation(model.value), + controller.stewardFreeDashboard, + ), + ], + ), + ), + ); + } + + Widget summaryOfInformation(StewardFreeBarDashboard? model) { + return Column( + children: [ + Text( + 'خلاصه اطلاعات', + textAlign: TextAlign.right, + style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), + ), + Container( + height: 140, + 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: model == null + ? const Center(child: CircularProgressIndicator()) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 10, + children: [ + const SizedBox(height: 12), + buildRow('تعداد کل بارها', model.totalQuantity.toString()), + buildRow('تعداد کل', model.totalBars.toString()), + buildRow('وزن کل (کیلوگرم)', model.totalWeight.toString()), + ], + ), + ), + ], + ); + } + + Widget inventoryWidget() { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Column( + children: [ + const SizedBox(height: 20), + Align( + alignment: Alignment.centerRight, + child: Text( + 'موجودی انبار', + style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), + ), + ), + SizedBox(height: 4), + ObxValue( + (data) => data.isEmpty + ? Container( + margin: const EdgeInsets.symmetric(vertical: 2), + height: 80, + padding: EdgeInsets.all(6), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.blueNormal, width: 1), + ), + child: Center(child: CircularProgressIndicator()), + ) + : ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: controller.rootLogic.inventoryList.length, + separatorBuilder: (context, index) => + const SizedBox(height: 8), + itemBuilder: (context, index) { + return ObxValue((expand) { + return GestureDetector( + onTap: () { + controller.rootLogic.toggleExpanded(index); + }, + behavior: HitTestBehavior.opaque, + child: AnimatedContainer( + onEnd: () { + controller + .rootLogic + .inventoryExpandedList[index] = !controller + .rootLogic + .inventoryExpandedList[index]!; + }, + margin: const EdgeInsets.symmetric(vertical: 2), + padding: EdgeInsets.all(6), + curve: Curves.easeInOut, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all( + color: AppColor.blueNormal, + width: 1, + ), + ), + duration: const Duration(seconds: 1), + height: expand.keys.contains(index) ? 250 : 80, + child: inventoryItem( + isExpanded: + expand.keys.contains(index) && expand[index]!, + index: index, + model: controller.rootLogic.inventoryList[index], + ), + ), + ); + }, controller.rootLogic.inventoryExpandedList); + }, + ), + controller.rootLogic.inventoryList, + ), + ], + ), + ); + } + + Widget inventoryItem({ + required bool isExpanded, + required int index, + required InventoryModel model, + }) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 8, + children: [ + buildRow('نام محصول', model.name ?? ''), + Visibility( + visible: isExpanded, + child: Column( + spacing: 8, + children: [ + buildRow('وزن خریدهای دولتی داخل استان (کیلوگرم)', '0326598653'), + buildRow( + 'وزن خریدهای آزاد داخل استان (کیلوگرم)', + model.receiveFreeCarcassesWeight.toString(), + ), + buildRow( + 'وزن خریدهای خارج استان (کیلوگرم)', + model.freeBuyingCarcassesWeight.toString(), + ), + buildRow( + 'کل ورودی به انبار (کیلوگرم)', + model.totalFreeBarsCarcassesWeight.toString(), + ), + buildRow( + 'کل فروش (کیلوگرم)', + model.realAllocatedWeight.toString(), + ), + buildRow( + 'مانده انبار (کیلوگرم)', + model.totalRemainWeight.toString(), + ), + ], + ), + ), + ], + ); + } + + Widget buildRow(String title, String value) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + flex: 2, + child: Text( + title, + textAlign: TextAlign.right, + style: AppFonts.yekan14.copyWith( + color: AppColor.darkGreyDarkHover, + ), + ), + ), + Flexible( + flex: 2, + child: Text( + value, + textAlign: TextAlign.left, + style: AppFonts.yekan14.copyWith( + color: AppColor.darkGreyDarkHover, + ), + ), + ), + ], + ), + ); + } + + Widget allocationsMade() { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Column( + children: [ + const SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'تخصیصات صورت گرفته', + style: AppFonts.yekan16Bold.copyWith( + color: AppColor.blueNormal, + ), + ), + RElevated( + text: 'تایید یکجا', + height: 30, + onPressed: () { + controller.confirmAllAllocations(); + }, + ), + ], + ), + SizedBox(height: 4), + 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( + padding: const EdgeInsets.all(8.0), + itemCount: data.value?.results?.length ?? 0, + itemBuilder: (BuildContext context, int index) { + final result = data.value!.results![index]; + return Card( + 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.allocation_type?.faAllocationType ?? 'N/A', + ), + buildRow( + 'مشخصات خریدار', + '${result.to_guilds?.user?.fullname} - ${result.to_guilds?.guilds_name}' ?? + 'N/A', + ), + buildRow( + 'مشخصات فروشنده', + result.steward?.user?.fullname ?? 'N/A', + ), + buildRow( + 'نوع فروش', + result.sell_type?.faItem ?? 'N/A', + ), + buildRow( + 'قیمت هر کیلو', + '${result.amount ?? 0} ریال ', + ), + buildRow( + 'قیمت کل', + '${result.total_amount ?? 0} ریال', + ), + buildRow( + 'وزن تخصیصی', + '${result.weight_of_carcasses?.toInt() ?? 0} کیلوگرم', + ), + buildRow( + 'کداحراز', + result.registration_code?.toString() ?? 'N/A', + ), + buildRow( + 'وضعیت کد احراز', + result.system_registration_code == true + ? "ارسال شده" + : "ارسال نشده" ?? 'N/A', + ), + buildRow( + 'افت وزن(کیلوگرم)', + result.weight_loss_of_carcasses + ?.toInt() + .toString() ?? + 'N/A', + ), + buildRow( + 'وضعیت', + result.receiver_state?.faItem ?? 'N/A', + ), + + Row( + spacing: 10, + children: [ + Expanded( + child: RElevated( + height: 40, + text: 'تایید', + onPressed: () { + ConformAllocation confromation = + ConformAllocation( + allocation_key: result.key, + number_of_carcasses: + result.number_of_carcasses, + weight_of_carcasses: result + .weight_of_carcasses + ?.toInt(), + amount: result.amount, + total_amount: result.total_amount, + ); + + controller.confirmAllocation( + confromation, + ); + }, + ), + ), + Expanded( + child: RElevated( + height: 40, + backgroundColor: AppColor.error, + text: 'رد', + onPressed: () { + controller.denyAllocation( + result.key ?? '', + ); + }, + ), + ), + ], + ), + ], + ), + ), + ); + }, + separatorBuilder: (BuildContext context, int index) => + SizedBox(height: 8), + ), + ); + } + }, controller.allocatedMadeModel), + ], + ), + ); + } + + void showAddBottomSheet() { + Get.bottomSheet( + SafeArea( + child: BaseBottomSheet( + height: 700, + child: Padding( + padding: EdgeInsets.only( + left: 16, + right: 16, + top: 16, + bottom: MediaQuery.of(Get.context!).viewInsets.bottom + 16, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'ثبت توزیع/ فروش', + style: AppFonts.yekan16Bold.copyWith( + color: AppColor.blueNormal, + ), + ), + const SizedBox(height: 12), + RTextField( + controller: TextEditingController(), + label: 'تاریخ', + enabled: false, + initText: Jalali.now().formatCompactDate(), + ), + const SizedBox(height: 12), + Material( + type: MaterialType.transparency, + child: productDropDown(), + ), + const SizedBox(height: 12), + SizedBox( + height: 40, + child: ObxValue((data) { + return Row( + children: [ + Radio( + value: 1, + groupValue: controller.saleType.value, + onChanged: (value) { + controller.saleType.value = value!; + }, + ), + Text('فروش اختصاصی', style: AppFonts.yekan14), + SizedBox(width: 12), + Radio( + value: 2, + groupValue: controller.saleType.value, + onChanged: (value) { + controller.saleType.value = value!; + }, + ), + Text('فروش آزاد', style: AppFonts.yekan14), + ], + ); + }, controller.saleType), + ), + const SizedBox(height: 12), + + Material( + type: MaterialType.transparency, + child: guildsDropDown(), + ), + + const SizedBox(height: 12), + RTextField( + controller: controller.weightController, + keyboardType: TextInputType.number, + onChanged: (p0) { + controller.weight.value = int.tryParse(p0) ?? 0; + }, + label: 'وزن لاشه', + ), + const SizedBox(height: 12), + RTextField( + controller: controller.pricePerKiloController, + onChanged: (p0) { + controller.pricePerKilo.value = int.tryParse(p0) ?? 0; + }, + keyboardType: TextInputType.number, + label: 'قیمت هر کیلو', + ), + const SizedBox(height: 12), + ObxValue( + (p0) => RTextField( + enabled: false, + keyboardType: TextInputType.number, + initText: controller.totalCost.value.toString(), + controller: controller.totalCostController, + label: 'هزینه کل', + ), + controller.totalCost, + ), + const SizedBox(height: 20), + ObxValue((data) { + return RElevated( + text: 'ثبت', + onPressed: data.value + ? () { + controller.submitAllocation(); + } + : null, + ); + }, controller.isValid), + const SizedBox(height: 20), + ], + ), + ), + ), + ), + isScrollControlled: true, + backgroundColor: Colors.transparent, + ); + } + + Widget guildsDropDown() { + return ObxValue((p0) { + return DropdownButtonFormField( + value: controller.selectedGuildModel.value, + decoration: const InputDecoration( + labelText: 'انتخاب مباشر/صنف', + border: OutlineInputBorder(), + ), + isExpanded: true, + items: controller.guildsModel.map((guild) { + return DropdownMenuItem( + value: guild, + child: Text( + '${guild.steward == true ? 'مباشر' : 'صنف'} ${guild.user?.fullname} (${guild.user?.mobile})', + ), + ); + }).toList(), + onChanged: (value) { + if (value != null) { + controller.setSelectedGuild(value); + controller.checkVerfication(); + } + }, + ); + }, controller.guildsModel); + /* return GetBuilder( + builder: (controller) { + return DropdownButtonFormField( + value: controller.selectedGuildModel.value, + decoration: const InputDecoration( + labelText: 'انتخاب مباشر/صنف', + border: OutlineInputBorder(), + ), + isExpanded: true, + items: controller.guildsModel.map((guild) { + return DropdownMenuItem( + value: guild, + child: Text( + '${guild.steward == true ? 'مباشر' : 'صنف'} ${guild.user + ?.fullname} (${guild.user?.mobile})', + ), + ); + }).toList(), + onChanged: (value) { + if (value != null) { + controller.setSelectedGuild(value); + } + }, + ); + }, + );*/ + } + + Widget productDropDown() { + return GetBuilder( + builder: (controller) { + return DropdownButtonFormField( + value: controller.selectedProductModel.value, + decoration: const InputDecoration( + labelText: 'انتخاب محصول', + border: OutlineInputBorder(), + ), + isExpanded: true, + items: controller.rolesProductsModel.map((guild) { + return DropdownMenuItem( + value: guild, + child: Text('${guild.name}'), + ); + }).toList(), + onChanged: (value) { + if (value != null) { + controller.setSelectedProduct(value); + controller.checkVerfication(); + } + }, + ); + }, + ); + } +} diff --git a/packages/chicken/lib/presentation/routes/pages.dart b/packages/chicken/lib/presentation/routes/pages.dart index ec0978b..1e794c0 100644 --- a/packages/chicken/lib/presentation/routes/pages.dart +++ b/packages/chicken/lib/presentation/routes/pages.dart @@ -3,6 +3,8 @@ import 'package:rasadyar_chicken/presentation/pages/entering_the_warehouse/logic import 'package:rasadyar_chicken/presentation/pages/entering_the_warehouse/view.dart'; import 'package:rasadyar_chicken/presentation/pages/root/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/root/view.dart'; +import 'package:rasadyar_chicken/presentation/pages/sales_with_out_province/logic.dart'; +import 'package:rasadyar_chicken/presentation/pages/sales_with_out_province/view.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_within_province/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_within_province/view.dart'; import 'package:rasadyar_chicken/presentation/routes/routes.dart'; @@ -29,7 +31,8 @@ sealed class ChickenPages { Get.put(EnteringTheWarehouseLogic()); Get.put(RootLogic()); }), - ), GetPage( + ), + GetPage( name: ChickenRoutes.salesWithinProvince, page: () => SalesWithinProvincePage(), middlewares: [AuthMiddleware()], @@ -38,5 +41,14 @@ sealed class ChickenPages { Get.put(RootLogic()); }), ), + GetPage( + name: ChickenRoutes.salesWithOutProvince, + page: () => SalesWithOutProvincePage(), + middlewares: [AuthMiddleware()], + binding: BindingsBuilder(() { + Get.put(SalesWithOutProvinceLogic()); + Get.put(RootLogic()); + }), + ), ]; } diff --git a/packages/chicken/lib/presentation/routes/routes.dart b/packages/chicken/lib/presentation/routes/routes.dart index ef1d2d2..7f47386 100644 --- a/packages/chicken/lib/presentation/routes/routes.dart +++ b/packages/chicken/lib/presentation/routes/routes.dart @@ -5,5 +5,6 @@ sealed class ChickenRoutes { static const enteringTheWarehouse = '$_base/enteringTheWarehouse'; static const salesWithinProvince = '$_base/SalesWithinProvincePage'; + static const salesWithOutProvince = '$_base/SalesWithOutProvincePage'; }