feat : new dashboard and inventory_widget

This commit is contained in:
2025-10-08 17:01:33 +03:30
parent 665ef9abf7
commit be6e16f54e
28 changed files with 1020 additions and 126 deletions

View File

@@ -11,7 +11,7 @@ class BuyInProvinceLogic extends GetxController {
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
StewardRootLogic get rootLogic => Get.find<StewardRootLogic>();
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
BuyLogic get buyLogic => Get.find<BuyLogic>();
RxInt selectedSegmentIndex = 0.obs;
@@ -84,6 +84,7 @@ class BuyInProvinceLogic extends GetxController {
Future<void> onRefresh() async {
final isWaiting = selectedSegmentIndex.value == 0;
await rootLogic.onRefresh();
await Future.wait([buyWaitingLogic.getWaitingArrivals(), buyAllLogic.getAllArrivals()]);
}
}

View File

@@ -32,7 +32,7 @@ class BuyOutOfProvinceLogic extends GetxController {
RxnString _base64Image = RxnString();
RxnString editImageUrl = RxnString();
StewardRootLogic get rootLogic => Get.find<StewardRootLogic>();
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
BuyLogic get buyLogic => Get.find<BuyLogic>();
@@ -51,6 +51,8 @@ class BuyOutOfProvinceLogic extends GetxController {
void onInit() {
super.onInit();
routesName = [...buyLogic.routesName, 'خارج استان'].toList();
fLog('BuyOutOfProvinceLogic ${rootLogic.stewardSalesInfoDashboard}');
}
@override
@@ -238,6 +240,7 @@ class BuyOutOfProvinceLogic extends GetxController {
Future<void> onRefresh() async {
currentPage.value = 1;
await rootLogic.onRefresh();
await getStewardPurchaseOutOfProvince();
}
}

View File

@@ -219,7 +219,9 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
buildDeleteDialog(
onConfirm: () => controller.deleteStewardPurchaseOutOfProvince(item.key!),
onRefresh: () => controller.getStewardPurchaseOutOfProvince(),
);
).then((value) {
controller.onRefresh();
});
},
borderColor: AppColor.redNormal,
),

View File

@@ -1,5 +1,6 @@
import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart';
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/presentation/pages/steward/root/logic.dart';
import 'package:rasadyar_core/core.dart';
@@ -9,16 +10,42 @@ class HomeLogic extends GetxController {
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
Rxn<BarInformation> barInformation = Rxn();
RxList<Map<String, String?>> inventoryItems = [
{'خریدهای دولتی داخل استان': null},
{'خریدهای آزاد داخل استان': null},
{'وزن خریدهای خارج استان': null},
{'کل ورودی به انبار': null},
{'کل فروش': null},
{'مانده انبار': null},
].obs;
RxList<Map<String, String>> broadcastItems = [
{'وزن دولتی': '2،225،256'},
{'وزن آزاد': '2،225،256'},
{'فروش دولتی': '2،225،256'},
{'فروش آزاد': '2،225،256'},
{'توزیع داخل استان': '2،225،256'},
{'توزیع خارج استان': '2،225،256'},
{'قطعه بندی': '2،225،256'},
].obs;
RxBool isExpanded = false.obs;
@override
void onReady() {
super.onReady();
refreshData();
}
Future<void> refreshData() async {
await Future.wait([getGeneralBarsInformation(), getTodayBars(), getDistributionInformation()]);
await Future.wait([
getGeneralBarsInformation(),
getTodayBars(),
getDistributionInformation(),
rootLogic.getRolesProducts(),
rootLogic.getInventory(),
]);
}
Future<void> getGeneralBarsInformation() async {

View File

@@ -17,14 +17,16 @@ class HomePage extends GetView<HomeLogic> {
scrollable: true,
isBase: true,
onRefresh: controller.refreshData,
child: Column(
children: [
SizedBox(height: 18.h),
mainInformation(),
SizedBox(height: 8.h),
WidelyUsedWidget(),
SizedBox(height: 20),
],
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 18.h),
mainInformation(),
SizedBox(height: 8.h),
WidelyUsedWidget(),
SizedBox(height: 20),
],
),
),
);
}
@@ -68,32 +70,13 @@ class HomePage extends GetView<HomeLogic> {
),
SizedBox(height: 8),
_todayShipmentWidget(),
//_todayShipmentWidget2(),
_todayShipmentWidget2(),
_inventoryWidget(),
Row(
children: [
Text(
'اطلاعات بارها',
textAlign: TextAlign.right,
style: AppFonts.yekan16,
),
],
),
_informationShipment(),
Row(
children: [
Text(
'اطلاعات توزیع',
textAlign: TextAlign.right,
style: AppFonts.yekan16,
),
],
),
distributionInformationWidget(),
_inventoryListWidget(),
SizedBox(height: 8),
broadCastList(),
SizedBox(height: 8),
commitmentsList(),
],
),
)
@@ -108,7 +91,7 @@ class HomePage extends GetView<HomeLogic> {
children: [Icon(CupertinoIcons.chevron_down, size: 18)],
),
_todayShipmentWidget(),
// _todayShipmentWidget2(),
_todayShipmentWidget2(),
_inventoryWidget(),
],
),
@@ -149,6 +132,93 @@ class HomePage extends GetView<HomeLogic> {
);
}
//todo
Widget broadCastList() {
return ObxValue((data) {
return Column(
children: [
Row(
children: [
SizedBox(width: 5.w),
Text('اطلاعات پخش', textAlign: TextAlign.right, style: AppFonts.yekan16),
],
),
SizedBox(height: 8.h),
Row(
spacing: 8,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: broadcastItem(
title: 'وزن دولتی',
titleBgColor: const Color(0xFFB8E7DC),
valueBgColor: const Color(0xFFE6FAF5),
value: data.value?.totalGovernmentalInputWeight.separatedByComma,
),
),
Expanded(
child: broadcastItem(
title: 'وزن آزاد',
value: data.value?.totalFreeInputWeight.separatedByComma,
titleBgColor: const Color(0xFFDDE2F0),
valueBgColor: const Color(0xFFEAEFFF),
),
),
Expanded(
child: broadcastItem(
title: 'فروش دولتی',
value: data.value?.totalGovernmentalOutputWeight.separatedByComma,
titleBgColor: const Color(0xFFEBC4CE),
valueBgColor: const Color(0xFFEDDCE0),
),
),
Expanded(
child: broadcastItem(
title: 'فروش آزاد',
value: data.value?.totalFreeOutputWeight.separatedByComma,
titleBgColor: const Color(0xFFC2D3F2),
valueBgColor: const Color(0xFFECF2FF),
),
),
],
),
SizedBox(height: 8.h),
Row(
spacing: 8,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: broadcastItem(
title: 'مانده دولتی',
value: data.value?.totalGovernmentalRemainWeight.separatedByComma,
titleBgColor: const Color(0xFFB8E7DC),
valueBgColor: const Color(0xFFE6FAF5),
),
),
Expanded(
child: broadcastItem(
title: 'مانده آزاد',
value: data.value?.totalFreeRemainWeight.separatedByComma,
titleBgColor: const Color(0xFFDDE2F0),
valueBgColor: const Color(0xFFEAEFFF),
),
),
Expanded(
child: broadcastItem(
title: 'فروش خارج استان',
value: data.value?.totalStewardFreeSaleBarCarcassesWeight.separatedByComma,
titleBgColor: const Color(0xFFEBC4CE),
valueBgColor: const Color(0xFFEDDCE0),
),
),
],
),
],
);
}, controller.rootLogic.stewardSalesInfoDashboard);
}
Widget distributionInformationWidget() {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
@@ -247,9 +317,9 @@ class HomePage extends GetView<HomeLogic> {
isLoading: data.value == null,
description: data.value?.totalRemainWeight.separatedByCommaFa ?? '0',
iconPath: Assets.vec.cubeSearchSvg.path,
iconColor: const Color(0xFF426060),
bgDescriptionColor: const Color(0xFFC7DFE0),
bgLabelColor: const Color(0xFFA5D1D2),
bgDescriptionColor: const Color(0xFFEAEFFF),
bgLabelColor: const Color(0xFFBDD4FF),
iconColor: AppColor.textColor,
),
),
Expanded(
@@ -279,16 +349,29 @@ class HomePage extends GetView<HomeLogic> {
child: ObxValue(
(data) => _informationLabelCard(
title: 'بارهای امروز',
titleColor: AppColor.blueNormal,
borderColor: Color(0xFF77A6FF),
titleColor: AppColor.textColor,
borderColor: Color(0xFFFFAE00),
isLoading: data.value == null,
description: data.value?.separatedByCommaFa ?? '0',
iconPath: Assets.vec.cubeScanWithLabelSvg.path,
icon: Container(
width: 24.w,
height: 24.h,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
color: const Color(0xFFFFAE00),
borderRadius: BorderRadius.circular(8),
),
child: Assets.vec.cubeScanSvg.svg(
width: 12.w,
height: 12.h,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
),
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [AppColor.blueLight, Colors.white],
colors: [const Color(0xFFFFD883), const Color(0xFFFFFBF1)],
),
),
controller.totalWeightTodayBars,
@@ -298,18 +381,31 @@ class HomePage extends GetView<HomeLogic> {
Expanded(
child: ObxValue((data) {
return _informationLabelCard(
title: 'درانتظار تایید',
borderColor: AppColor.greenNormal,
title: 'درانتظار',
borderColor: const Color(0xFF9758FF),
isLoading: data.value == null,
description: data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
unit:
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
iconPath: Assets.vec.cubeCardSvg.path,
icon: Container(
width: 24.w,
height: 24.h,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
color: const Color(0xFF9758FF),
borderRadius: BorderRadius.circular(8),
),
child: Assets.vec.cubeCardFreeSvg.svg(
width: 12.w,
height: 12.h,
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
),
),
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [const Color(0xFFD9F7F0), Colors.white],
colors: [const Color(0xFFD8C1FF), const Color(0xFFFBF9FF)],
),
);
}, controller.barInformation),
@@ -320,50 +416,103 @@ class HomePage extends GetView<HomeLogic> {
}
Widget _todayShipmentWidget2() {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
child: Row(
spacing: 8,
children: [
Expanded(
child: ObxValue(
(data) => _informationLabelCard(
return ObxValue((data) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
child: Row(
spacing: 8,
children: [
Expanded(
child: _informationLabelCard(
title: 'مانده دولتی',
titleColor: AppColor.blueNormal,
borderColor: Color(0xFFFFAE00),
isLoading: data.value == null,
description: data.value?.separatedByCommaFa ?? '0',
description: data.value?.totalGovernmentalRemainWeight?.separatedByCommaFa ?? '0',
iconPath: Assets.vec.cubeCardGovermentSvg.path,
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFD47A), Colors.white],
),
iconColor: AppColor.textColor,
bgDescriptionColor: const Color(0xFFF5ECEE),
bgLabelColor: const Color(0xFFDEC1C7),
),
controller.totalWeightTodayBars,
),
),
Expanded(
child: ObxValue((data) {
return _informationLabelCard(
Expanded(
child: _informationLabelCard(
title: 'مانده آزاد',
borderColor: const Color(0xFF9758FF),
isLoading: data.value == null,
description: data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
unit:
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
description: data.value?.totalFreeRemainWeight.separatedByCommaFa ?? '0',
unit: 'کیلوگرم',
iconPath: Assets.vec.cubeCardFreeSvg.path,
bgDescriptionColor: Colors.white,
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [const Color(0xFFD3B9FF), Colors.white],
),
);
}, controller.barInformation),
iconColor: AppColor.textColor,
bgDescriptionColor: const Color(0xFFD0ECED),
bgLabelColor: const Color(0xFFA5D1D2),
),
),
],
),
);
}, controller.rootLogic.stewardSalesInfoDashboard);
}
Widget _inventoryListWidget() {
return ObxValue((data) {
var model = data[0];
return Container(
padding: EdgeInsets.fromLTRB(16.w, 0, 11.w, 0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: const Color(0xB2EDF1FF),
),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
inventoryListItem(
title: 'خریدهای دولتی داخل استان',
value: model.receiveGovernmentalCarcassesWeight.separatedByComma,
),
Divider(),
inventoryListItem(
title: 'خریدهای آزاد داخل استان',
value: model.receiveFreeCarcassesWeight?.separatedByComma,
),
Divider(),
inventoryListItem(
title: 'وزن خریدهای خارج استان',
value: model.freeBuyingCarcassesWeight?.separatedByComma,
),
Divider(),
inventoryListItem(
title: 'کل ورودی به انبار',
value: model.totalCarcassesWeight?.separatedByComma,
),
Divider(),
inventoryListItem(title: 'کل فروش', value: model.realAllocatedWeight?.separatedByComma),
Divider(),
inventoryListItem(
title: 'مانده انبار',
value: model.totalRemainWeight?.separatedByComma,
),
],
),
);
}, controller.rootLogic.rolesProductsModel);
}
Widget inventoryListItem({required String title, required String? value}) {
return Container(
height: 45.h,
child: Row(
children: [
Text(
title,
style: AppFonts.yekan14.copyWith(color: const Color(0xFF353535), height: 1.2),
),
Spacer(),
value == null
? Center(child: CupertinoActivityIndicator())
: Text(value, style: AppFonts.yekan14.copyWith(color: const Color(0xFF353535))),
SizedBox(width: 20.w),
Text('کیلوگرم', style: AppFonts.yekan10.copyWith(color: const Color(0xFF353535))),
],
),
);
@@ -372,8 +521,9 @@ class HomePage extends GetView<HomeLogic> {
Container _informationLabelCard({
required String title,
required String description,
required String iconPath,
required Color bgDescriptionColor,
String? iconPath,
Widget? icon,
Color? borderColor,
String unit = 'کیلوگرم',
bool isLoading = false,
@@ -383,7 +533,7 @@ class HomePage extends GetView<HomeLogic> {
LinearGradient? gradient,
}) {
return Container(
height: 82,
height: 65.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: borderColor != null ? Border.all(width: 1, color: borderColor) : null,
@@ -405,15 +555,16 @@ class HomePage extends GetView<HomeLogic> {
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
spacing: 5,
children: [
SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: iconColor != null
? ColorFilter.mode(iconColor, BlendMode.srcIn)
: null,
),
icon ??
SvgGenImage.vec(iconPath!).svg(
width: 24.w,
height: 24.h,
colorFilter: iconColor != null
? ColorFilter.mode(iconColor, BlendMode.srcIn)
: null,
),
Text(
title,
textAlign: TextAlign.right,
@@ -639,6 +790,64 @@ class HomePage extends GetView<HomeLogic> {
);
}
Widget broadcastItem({
int? width,
int? height,
String? title,
String? value,
String? unit,
Color? titleBgColor,
Color? valueBgColor,
Color? unitBgColor,
TextStyle? titleStyle,
TextStyle? valueStyle,
TextStyle? unitStyle,
}) {
return Container(
height: height?.h ?? 73.h,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(color: valueBgColor, borderRadius: BorderRadius.circular(8)),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
padding: EdgeInsets.symmetric(vertical: 4.h),
decoration: BoxDecoration(color: titleBgColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title ?? 'بدون تیتر',
textAlign: TextAlign.center,
style: titleStyle ?? AppFonts.yekan12.copyWith(color: const Color(0xFF3E3E3E)),
),
],
),
),
SizedBox(height: 4),
(value != null)
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 11.0),
child: Text(
value,
textAlign: TextAlign.right,
style: valueStyle ?? AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
)
: Center(child: CupertinoActivityIndicator()),
Text(
unit ?? 'کیلوگرم',
textAlign: TextAlign.center,
style: unitStyle ?? AppFonts.yekan10.copyWith(color: Color(0xFF717171)),
),
SizedBox(height: 4.h),
],
),
);
}
Widget cardWidget({
required String title,
required String iconPath,
@@ -674,4 +883,114 @@ class HomePage extends GetView<HomeLogic> {
),
);
}
Widget commitmentsList() {
return ObxValue((data) {
return Column(
spacing: 2.h,
children: [
Row(
children: [
SizedBox(width: 5.w),
Text('تعهدات', textAlign: TextAlign.right, style: AppFonts.yekan16),
],
),
commitmentsItemList(
title: 'تعهد دولتی توزیع داخل استان',
value: data.value?.totalCommitmentSellingInProvinceGovernmentalWeight.separatedByComma,
labelColor: const Color(0xFFB9E8DC),
bgColor: const Color(0xFFF3F9F8),
),
commitmentsItemList(
title: 'توزیع دولتی داخل استان',
value: data.value?.totalSellingInProvinceGovernmentalWeight.separatedByComma,
labelColor: const Color(0xFFC3D4F3),
bgColor: const Color(0xFFECF3FF),
),
commitmentsItemList(
title: 'باقیمانده تعهد دولتی توزیع داخل استان',
value: data
.value
?.totalCommitmentSellingInProvinceGovernmentalRemainWeight
.separatedByComma,
labelColor: const Color(0xFFEBC5CE),
bgColor: const Color(0xFFFFF1F4),
),
commitmentsItemList(
title: 'تعهد آزاد توزیع داخل استان',
value: data.value?.totalCommitmentSellingInProvinceFreeWeight.separatedByComma,
labelColor: const Color(0xFFC7DADA),
bgColor: const Color(0xFFE5F7F7),
),
commitmentsItemList(
title: 'توزیع آزاد داخل استان',
value: data.value?.totalSellingInProvinceFreeWeight.separatedByComma,
labelColor: const Color(0xFFE0D6ED),
bgColor: const Color(0xFFF5EDFF),
),
commitmentsItemList(
title: 'باقیمانده تعهد آزاد توزیع داخل استان',
value: data.value?.totalCommitmentSellingInProvinceFreeRemainWeight.separatedByComma,
labelColor: const Color(0xFFEBC5CE),
bgColor: const Color(0xFFFFF1F4),
),
],
);
}, controller.rootLogic.stewardSalesInfoDashboard);
}
Container commitmentsItemList({
required String title,
required String? value,
required Color labelColor,
required Color bgColor,
}) {
return Container(
width: Get.width,
child: Row(
children: [
Container(height: 48.h, width: 4.w, color: labelColor),
Expanded(
child: Container(
height: 48.h,
padding: EdgeInsets.symmetric(horizontal: 14.w),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
),
child: Row(
children: [
Text(
title,
textAlign: TextAlign.right,
style: AppFonts.yekan12.copyWith(color: AppColor.textColor),
),
Spacer(),
value == null
? Center(child: CupertinoActivityIndicator())
: Text(
value,
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(color: AppColor.textColor),
),
SizedBox(width: 8.w),
Text(
'کیلوگرم',
textAlign: TextAlign.right,
style: AppFonts.yekan10.copyWith(color: AppColor.textColor),
),
],
),
),
),
],
),
);
}
}

View File

@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:rasadyar_chicken/data/data_source/local/chicken_local.dart';
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
@@ -8,6 +7,7 @@ import 'package:rasadyar_chicken/data/models/local/widely_used_local_model.dart'
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/data/repositories/chicken/chicken_repository.dart';
import 'package:rasadyar_chicken/presentation/pages/common/profile/view.dart';
import 'package:rasadyar_chicken/presentation/pages/steward/buy/view.dart';
@@ -29,6 +29,7 @@ class StewardRootLogic extends GetxController {
final defaultRoutes = <int, String>{0: ChickenRoutes.buySteward, 1: ChickenRoutes.saleSteward};
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
Rxn<WidelyUsedLocalModel> widelyUsedList = Rxn<WidelyUsedLocalModel>();
Rxn<StewardSalesInfoDashboard> stewardSalesInfoDashboard = Rxn<StewardSalesInfoDashboard>();
late DioRemote dioRemote;
var tokenService = Get.find<TokenStorageService>();
@@ -68,6 +69,7 @@ class StewardRootLogic extends GetxController {
if (rolesProductsModel.isEmpty) {
getRolesProducts();
}
getStewardSaleDashboard();
if (widelyUsedList.value?.hasInit != true) {
//TODO
@@ -83,6 +85,15 @@ class StewardRootLogic extends GetxController {
super.onClose();
}
Future<void> onRefresh() async {
await Future.wait([
getInventory(),
getRolesProducts(),
getStewardSaleDashboard(),
getProvinces(),
]);
}
void toggleExpanded(int index) {
if (inventoryExpandedList.keys.contains(index)) {
inventoryExpandedList.remove(index);
@@ -158,6 +169,21 @@ class StewardRootLogic extends GetxController {
);
}
Future<void> getStewardSaleDashboard() async {
safeCall(
call: () async => await chickenRepository.getStewardSalesInfoDashboard(
token: tokenService.accessToken.value!,
queryParameters: buildRawQueryParams(role: 'Steward'),
),
onSuccess: (result) {
if (result != null) {
stewardSalesInfoDashboard.value = result;
}
},
onError: (error, stacktrace) {},
);
}
int getNestedKey() {
switch (currentPage.value) {
case 0:
@@ -184,10 +210,9 @@ class StewardRootLogic extends GetxController {
final currentRoute = currentNestedKey?.currentState;
fLog(Get.currentRoute);
/*
/*
fLog("onPopScopTaped ==> ${currentNestedKey?.currentState?.canPop()}");
if (currentNestedKey?.currentState?.canPop() == true) {
iLog(currentNestedKey?.currentState?.canPop());

View File

@@ -454,7 +454,7 @@ class SalesInProvinceLogic extends GetxController {
Future<void> onRefresh() async {
currentPage.value = 1;
hasMoreDataAllocationsMade.value = true;
await rootLogic.onRefresh();
await Future.wait([getAllocatedMade()]);
}
}

View File

@@ -354,10 +354,10 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
buildDeleteDialog(
onConfirm: () async {
controller.isExpandedList.remove(index);
// controller.denyAllocation(item.key ?? '');
//await controller.deleteAllocation(item);
await controller.deleteAllocation(item);
},
onRefresh: () => controller.getAllocatedMade(),
onRefresh: controller.onRefresh,
);
},
borderColor: AppColor.redNormal,
@@ -401,7 +401,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
SizedBox(
height: 40,
child: ObxValue((data) {
return RadioGroup(
return RadioGroup(
groupValue: controller.saleType.value,
onChanged: (value) {
controller.saleType.value = value!;

View File

@@ -13,7 +13,7 @@ import 'package:rasadyar_chicken/presentation/utils/utils.dart';
import 'package:rasadyar_core/core.dart';
class SalesOutOfProvinceLogic extends GetxController {
StewardRootLogic get rootLogic => Get.find<StewardRootLogic>();
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
SaleLogic get saleLogic => Get.find<SaleLogic>();
@@ -215,6 +215,7 @@ class SalesOutOfProvinceLogic extends GetxController {
Future<void> onRefresh() async {
currentPage.value = 1;
await rootLogic.onRefresh();
await getOutProvinceSales();

View File

@@ -318,7 +318,7 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
controller.isExpandedList.remove(index);
controller.deleteStewardPurchaseOutOfProvince(item.key!);
},
onRefresh: () => controller.getOutProvinceSales(),
onRefresh: () => controller.onRefresh(),
);
},
borderColor: AppColor.redNormal,

View File

@@ -9,7 +9,7 @@ import 'package:rasadyar_chicken/presentation/utils/utils.dart';
import 'package:rasadyar_core/core.dart';
class SalesOutOfProvinceBuyersLogic extends GetxController {
StewardRootLogic get rootLogic => Get.find<StewardRootLogic>();
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
SaleLogic get saleLogic => Get.find<SaleLogic>();
@@ -212,6 +212,7 @@ class SalesOutOfProvinceBuyersLogic extends GetxController {
Future<void> onRefresh() async {
currentPage.value = 1;
await rootLogic.onRefresh();
await getOutProvinceCarcassesBuyer();
}
}

View File

@@ -12,7 +12,7 @@ import 'package:rasadyar_chicken/presentation/utils/utils.dart';
import 'package:rasadyar_core/core.dart';
class SalesOutOfProvinceSalesListLogic extends GetxController {
StewardRootLogic get rootLogic => Get.find<StewardRootLogic>();
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
SaleLogic get saleLogic => Get.find<SaleLogic>();

View File

@@ -196,7 +196,6 @@ class SegmentationLogic extends GetxController {
onSuccess: (result) {
res = true;
isSubmitButtonEnabled.value = true;
},
onError: (error, stacktrace) {
res = false;
@@ -221,9 +220,9 @@ class SegmentationLogic extends GetxController {
);
}
Future<void> onRefresh() async {
currentPage.value = 1;
await rootLogic.onRefresh();
await getAllSegmentation();
}
}

View File

@@ -242,7 +242,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
controller.isExpandedList.remove(index);
controller.deleteSegmentation(item.key!);
},
onRefresh: () => controller.getAllSegmentation(),
onRefresh: () => controller.onRefresh(),
);
},
borderColor: AppColor.redNormal,

View File

@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/pages/steward/root/logic.dart';
import 'package:rasadyar_core/core.dart';
@@ -5,19 +6,74 @@ import 'package:rasadyar_core/core.dart';
Widget inventoryWidget(StewardRootLogic rootLogic) {
return Container(
width: Get.width,
height: 39,
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: AppColor.greenLight,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.textColor, width: 0.5),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Row(
spacing: 8.w,
children: [
ObxValue((data) {
// بررسی مقدار null بودن و نشان دادن ActivityIndicator
final value = data.value?.totalRemainWeight?.separatedByCommaFa;
return _itemList(
title: 'موجودی انبار',
value: value ?? '', // در صورت نال بودن، رشته خالی نمایش داده شود
);
}, rootLogic.inventoryModel),
ObxValue((data) {
final value = data.value?.totalGovernmentalRemainWeight?.separatedByCommaFa;
return _itemList(title: 'مانده دولتی', value: value ?? '');
}, rootLogic.stewardSalesInfoDashboard),
ObxValue((data) {
final value = data.value?.totalFreeRemainWeight?.separatedByCommaFa;
return _itemList(title: 'مانده آزاد', value: value ?? '');
}, rootLogic.stewardSalesInfoDashboard),
],
),
),
);
}
Widget _itemList({required String title, required String? value, String? unit}) {
return Container(
width: 125.w,
height: 50.h,
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: Colors.white.withValues(alpha: 0.40),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: Column(
children: [
SizedBox(height: 4),
Text(
title,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: const Color(0xFF5B5B5B)),
),
SizedBox(height: 4),
value == null
? Center(child: CupertinoActivityIndicator())
: Padding(
padding: EdgeInsets.symmetric(horizontal: 4.w),
child: Row(
spacing: 8,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
value!,
textAlign: TextAlign.right,
style: AppFonts.yekan16.copyWith(color: const Color(0xFF5B5B5B)),
),
Text(
unit ?? 'کیلوگرم',
textAlign: TextAlign.center,
style: AppFonts.yekan10.copyWith(color: const Color(0xFF5B5B5B)),
),
],
),
),
],
),
alignment: Alignment.center,
child: ObxValue((data) {
return Text(
' موجودی انبار: ${data.value?.totalRemainWeight?.toInt().separatedByCommaFa ?? '0'} کیلوگرم',
style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkHover),
);
}, rootLogic.inventoryModel),
);
}