feat : wearhouse home page
This commit is contained in:
@@ -26,7 +26,7 @@ import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_ar
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
abstract class ChickenRemoteDatasource {
|
||||
Future<List<ProductModel>?> getInventory({
|
||||
Future<List<ProductModel>?> getRolesProduct({
|
||||
required String token,
|
||||
required String role,
|
||||
CancelToken? cancelToken,
|
||||
@@ -75,7 +75,10 @@ abstract class ChickenRemoteDatasource {
|
||||
required List<String> allocationTokens,
|
||||
});
|
||||
|
||||
Future<List<ProductModel>?> getRolesProducts({required String token});
|
||||
Future<List<ProductModel>?> getRolesProducts({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<List<GuildModel>?> getGuilds({
|
||||
required String token,
|
||||
|
||||
@@ -33,7 +33,7 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource {
|
||||
ChickenRemoteDatasourceImp(this._httpClient);
|
||||
|
||||
@override
|
||||
Future<List<ProductModel>?> getInventory({
|
||||
Future<List<ProductModel>?> getRolesProduct({
|
||||
required String token,
|
||||
required String role,
|
||||
CancelToken? cancelToken,
|
||||
@@ -41,7 +41,7 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource {
|
||||
var res = await _httpClient.get(
|
||||
'/roles-products/?role=$role',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
|
||||
queryParameters: {'role': role},
|
||||
fromJsonList: (json) => (json)
|
||||
.map((item) => ProductModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
@@ -176,10 +176,14 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductModel>?> getRolesProducts({required String token}) async {
|
||||
Future<List<ProductModel>?> getRolesProducts({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
var res = await _httpClient.get(
|
||||
'/roles-products/?role=Steward',
|
||||
'/roles-products/',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
queryParameters: queryParameters,
|
||||
fromJsonList: (json) => json
|
||||
.map((item) => ProductModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
|
||||
@@ -6,6 +6,10 @@ import 'package:rasadyar_chicken/data/models/kill_house_module/warehouse_and_dis
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
abstract class KillHouseRemoteDataSource {
|
||||
|
||||
|
||||
|
||||
|
||||
//region requestKill
|
||||
Future<List<KillHouseResponse>?> getKillHouseList({
|
||||
required String token,
|
||||
@@ -35,11 +39,15 @@ abstract class KillHouseRemoteDataSource {
|
||||
|
||||
//region warehouseAndDistribution
|
||||
|
||||
Future<KillHouseSalesInfoDashboard?> getKillHouseSalesInfoDashboard({
|
||||
Future<KillHouseSalesInfoDashboard?> getInfoDashboard({
|
||||
required String token,
|
||||
CancelToken? cancelToken,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class KillHouseRemoteDataSourceImpl extends KillHouseRemoteDataSource {
|
||||
//endregion
|
||||
//region warehouseAndDistribution
|
||||
@override
|
||||
Future<KillHouseSalesInfoDashboard?> getKillHouseSalesInfoDashboard({
|
||||
Future<KillHouseSalesInfoDashboard?> getInfoDashboard({
|
||||
required String token,
|
||||
CancelToken? cancelToken,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class ChickenRepository {
|
||||
//region Remote
|
||||
|
||||
//region Steward
|
||||
Future<List<ProductModel>?> getInventory({
|
||||
Future<List<ProductModel>?> getRolesProduct({
|
||||
required String token,
|
||||
required String role,
|
||||
CancelToken? cancelToken,
|
||||
@@ -81,7 +81,10 @@ abstract class ChickenRepository {
|
||||
required List<String> allocationTokens,
|
||||
});
|
||||
|
||||
Future<List<ProductModel>?> getRolesProducts({required String token});
|
||||
Future<List<ProductModel>?> getRolesProducts({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<List<GuildModel>?> getGuilds({
|
||||
required String token,
|
||||
|
||||
@@ -38,12 +38,12 @@ class ChickenRepositoryImp implements ChickenRepository {
|
||||
|
||||
//region Remote
|
||||
@override
|
||||
Future<List<ProductModel>?> getInventory({
|
||||
Future<List<ProductModel>?> getRolesProduct({
|
||||
required String token,
|
||||
required String role,
|
||||
CancelToken? cancelToken,
|
||||
}) async {
|
||||
var res = await remote.getInventory(
|
||||
var res = await remote.getRolesProduct(
|
||||
token: token,
|
||||
role: role,
|
||||
cancelToken: cancelToken,
|
||||
@@ -143,8 +143,14 @@ class ChickenRepositoryImp implements ChickenRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductModel>?> getRolesProducts({required String token}) async {
|
||||
var res = await remote.getRolesProducts(token: token);
|
||||
Future<List<ProductModel>?> getRolesProducts({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
var res = await remote.getRolesProducts(
|
||||
token: token,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,13 @@ import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/
|
||||
show KillRequestList;
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/warehouse_and_distribution/response/kill_house_sales_info_dashboard.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.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_core/core.dart';
|
||||
|
||||
abstract class KillHouseRepository {
|
||||
|
||||
|
||||
//region requestKill
|
||||
Future<List<KillHouseResponse>?> getKillHouseList({
|
||||
required String token,
|
||||
@@ -38,13 +42,18 @@ abstract class KillHouseRepository {
|
||||
//endregion
|
||||
|
||||
//region warehouseAndDistribution
|
||||
Future<KillHouseSalesInfoDashboard?> getKillHouseSalesInfoDashboard({
|
||||
|
||||
Future<KillHouseSalesInfoDashboard?> getInfoDashboard({
|
||||
required String token,
|
||||
CancelToken? cancelToken,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<BroadcastPrice?> getBroadcastPrice({required String token});
|
||||
|
||||
Future<List<ProductModel>?> getRolesProducts({required String token});
|
||||
|
||||
|
||||
Future<List<IranProvinceCityModel>?> getProvince({CancelToken? cancelToken});
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/
|
||||
as listModel;
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/warehouse_and_distribution/response/kill_house_sales_info_dashboard.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.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_core/core.dart';
|
||||
|
||||
import '../chicken/chicken_repository.dart';
|
||||
@@ -76,13 +78,14 @@ class KillHouseRepositoryImpl extends KillHouseRepository {
|
||||
//endregion
|
||||
|
||||
//region warehouseAndDistribution
|
||||
|
||||
@override
|
||||
Future<KillHouseSalesInfoDashboard?> getKillHouseSalesInfoDashboard({
|
||||
Future<KillHouseSalesInfoDashboard?> getInfoDashboard({
|
||||
required String token,
|
||||
CancelToken? cancelToken,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
return await remoteDataSource.getKillHouseSalesInfoDashboard(
|
||||
return await remoteDataSource.getInfoDashboard(
|
||||
token: token,
|
||||
cancelToken: cancelToken,
|
||||
queryParameters: queryParameters,
|
||||
@@ -94,5 +97,21 @@ class KillHouseRepositoryImpl extends KillHouseRepository {
|
||||
return await chickenRepository.getBroadcastPrice(token: token);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductModel>?> getRolesProducts({required String token}) async {
|
||||
var res = await chickenRepository.getRolesProducts(
|
||||
token: token,
|
||||
queryParameters: buildQueryParams(role: 'KillHouse'),
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<IranProvinceCityModel>?> getProvince({
|
||||
CancelToken? cancelToken,
|
||||
}) async {
|
||||
return await chickenRepository.getProvince(cancelToken: cancelToken);
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/kill_house/kill_house_repository.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/profile/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/pages.dart';
|
||||
@@ -14,7 +15,6 @@ class KillHouseRootLogic extends GetxController {
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
late KillHouseRepository killHouseRepository;
|
||||
Rxn<BroadcastPrice> broadcastPrice = Rxn<BroadcastPrice>();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -56,15 +56,5 @@ class KillHouseRootLogic extends GetxController {
|
||||
currentPage.value = i;
|
||||
}
|
||||
|
||||
Future<void> getBroadcastPrice() async {
|
||||
safeCall(
|
||||
call: () async => await killHouseRepository.getBroadcastPrice(
|
||||
token: tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
broadcastPrice.value = result;
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ class WarehouseAndDistributionBuyInProvinceAllLogic extends GetxController {
|
||||
final RxBool isLoadingMoreAllocationsMade = false.obs;
|
||||
RxInt currentPage = 1.obs;
|
||||
|
||||
WarehouseAndDistributionRootLogic rootLogic = Get.find<WarehouseAndDistributionRootLogic>();
|
||||
WarehouseAndDistributionRootLogic rootLogic =
|
||||
Get.find<WarehouseAndDistributionRootLogic>();
|
||||
|
||||
Rx<Resource<PaginationModel<WaitingArrivalModel>>> allProduct =
|
||||
Resource<PaginationModel<WaitingArrivalModel>>.loading().obs;
|
||||
@@ -33,7 +34,11 @@ class WarehouseAndDistributionBuyInProvinceAllLogic extends GetxController {
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
debounce(searchedValue, (callback) => getAllArrivals(), time: Duration(milliseconds: 2000));
|
||||
debounce(
|
||||
searchedValue,
|
||||
(callback) => getAllArrivals(),
|
||||
time: Duration(milliseconds: 2000),
|
||||
);
|
||||
super.onReady();
|
||||
ever(approvedWithOtpCode, (callback) {
|
||||
if (callback == false) {
|
||||
@@ -42,13 +47,12 @@ class WarehouseAndDistributionBuyInProvinceAllLogic extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> getAllArrivals([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
allProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.loading();
|
||||
allProduct.value =
|
||||
Resource<PaginationModel<WaitingArrivalModel>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
@@ -57,34 +61,39 @@ class WarehouseAndDistributionBuyInProvinceAllLogic extends GetxController {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'all'},
|
||||
pageSize: 20,
|
||||
page: currentPage.value,
|
||||
search: 'filter',
|
||||
role: 'Steward',
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
),
|
||||
),
|
||||
// call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// queryParameters: buildQueryParams(
|
||||
// queryParams: {'type': 'all'},
|
||||
// pageSize: 20,
|
||||
// page: currentPage.value,
|
||||
// search: 'filter',
|
||||
// role: 'Steward',
|
||||
// value: searchedValue.value,
|
||||
// fromDate: fromDateFilter.value.toDateTime(),
|
||||
// toDate: toDateFilter.value.toDateTime(),
|
||||
// ),
|
||||
// ),
|
||||
call: () async => null as PaginationModel<WaitingArrivalModel>?,
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 200));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
allProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.empty();
|
||||
} else {
|
||||
allProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.success(
|
||||
PaginationModel<WaitingArrivalModel>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [...(allProduct.value.data?.results ?? []), ...(res?.results ?? [])],
|
||||
),
|
||||
);
|
||||
}
|
||||
// TODO: Fix - res type issues
|
||||
// if ((res?.count ?? 0) == 0) {
|
||||
// allProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.empty();
|
||||
// } else {
|
||||
// allProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.success(
|
||||
// PaginationModel<WaitingArrivalModel>(
|
||||
// count: res?.count ?? 0,
|
||||
// next: res?.next,
|
||||
// previous: res?.previous,
|
||||
// results: [...(allProduct.value.data?.results ?? []), ...(res?.results ?? [])],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
allProduct.value =
|
||||
Resource<PaginationModel<WaitingArrivalModel>>.empty();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -105,10 +114,12 @@ class WarehouseAndDistributionBuyInProvinceAllLogic extends GetxController {
|
||||
|
||||
safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: request,
|
||||
),
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
// call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// request: request,
|
||||
// ),
|
||||
call: () async {},
|
||||
onSuccess: (result) {
|
||||
getAllArrivals();
|
||||
rootLogic.onRefresh();
|
||||
@@ -128,10 +139,12 @@ class WarehouseAndDistributionBuyInProvinceAllLogic extends GetxController {
|
||||
request.removeWhere((key, value) => value == null);
|
||||
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: request,
|
||||
),
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
// call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// request: request,
|
||||
// ),
|
||||
call: () async {},
|
||||
onError: (error, stackTrace) {
|
||||
eLog(error);
|
||||
},
|
||||
|
||||
@@ -16,7 +16,8 @@ class WarehouseAndDistributionBuyInProvinceWaitingLogic extends GetxController {
|
||||
Rx<Color> bgConfirmAllColor = AppColor.blueNormal.obs;
|
||||
RxInt currentPage = 1.obs;
|
||||
final RxBool isLoadingMoreAllocationsMade = false.obs;
|
||||
WarehouseAndDistributionRootLogic rootLogic = Get.find<WarehouseAndDistributionRootLogic>();
|
||||
WarehouseAndDistributionRootLogic rootLogic =
|
||||
Get.find<WarehouseAndDistributionRootLogic>();
|
||||
RxBool isButtonConfirm = false.obs;
|
||||
|
||||
Rx<Resource<PaginationModel<WaitingArrivalModel>>> waitingProduct =
|
||||
@@ -48,8 +49,6 @@ class WarehouseAndDistributionBuyInProvinceWaitingLogic extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setSearchValue(String? data) {
|
||||
searchedValue.value = data?.trim();
|
||||
}
|
||||
@@ -58,7 +57,8 @@ class WarehouseAndDistributionBuyInProvinceWaitingLogic extends GetxController {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
waitingProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.loading();
|
||||
waitingProduct.value =
|
||||
Resource<PaginationModel<WaitingArrivalModel>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
@@ -67,35 +67,40 @@ class WarehouseAndDistributionBuyInProvinceWaitingLogic extends GetxController {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'type': 'not_entered'},
|
||||
pageSize: 20,
|
||||
page: currentPage.value,
|
||||
search: 'filter',
|
||||
role: 'Steward',
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
),
|
||||
),
|
||||
// call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// queryParameters: buildQueryParams(
|
||||
// queryParams: {'type': 'not_entered'},
|
||||
// pageSize: 20,
|
||||
// page: currentPage.value,
|
||||
// search: 'filter',
|
||||
// role: 'Steward',
|
||||
// value: searchedValue.value,
|
||||
// fromDate: fromDateFilter.value.toDateTime(),
|
||||
// toDate: toDateFilter.value.toDateTime(),
|
||||
// ),
|
||||
// ),
|
||||
call: () async => null as PaginationModel<WaitingArrivalModel>?,
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 200));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
waitingProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.empty();
|
||||
} else {
|
||||
waitingProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.success(
|
||||
PaginationModel<WaitingArrivalModel>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [...(waitingProduct.value.data?.results ?? []), ...(res?.results ?? [])],
|
||||
),
|
||||
);
|
||||
flashingFabBgColor();
|
||||
}
|
||||
// TODO: Fix - res type issues
|
||||
// if ((res?.count ?? 0) == 0) {
|
||||
// waitingProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.empty();
|
||||
// } else {
|
||||
// waitingProduct.value = Resource<PaginationModel<WaitingArrivalModel>>.success(
|
||||
// PaginationModel<WaitingArrivalModel>(
|
||||
// count: res?.count ?? 0,
|
||||
// next: res?.next,
|
||||
// previous: res?.previous,
|
||||
// results: [...(waitingProduct.value.data?.results ?? []), ...(res?.results ?? [])],
|
||||
// ),
|
||||
// );
|
||||
// flashingFabBgColor();
|
||||
// }
|
||||
waitingProduct.value =
|
||||
Resource<PaginationModel<WaitingArrivalModel>>.empty();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -115,13 +120,15 @@ class WarehouseAndDistributionBuyInProvinceWaitingLogic extends GetxController {
|
||||
).toJson();
|
||||
request.removeWhere((key, value) => value == null);
|
||||
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
safeCall(
|
||||
showError: true,
|
||||
showSuccess: true,
|
||||
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: request,
|
||||
),
|
||||
// call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// request: request,
|
||||
// ),
|
||||
call: () async {},
|
||||
onError: (error, stackTrace) {
|
||||
eLog(error);
|
||||
},
|
||||
@@ -146,11 +153,13 @@ class WarehouseAndDistributionBuyInProvinceWaitingLogic extends GetxController {
|
||||
).toJson();
|
||||
request.removeWhere((key, value) => value == null);
|
||||
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: request,
|
||||
),
|
||||
// call: () async => await rootLogic.chickenRepository.setSateForArrivals(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// request: request,
|
||||
// ),
|
||||
call: () async {},
|
||||
onError: (error, stackTrace) {
|
||||
eLog(error);
|
||||
},
|
||||
|
||||
@@ -33,11 +33,14 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
RxnString editImageUrl = RxnString();
|
||||
RxnString editFreeBarKey = RxnString();
|
||||
|
||||
WarehouseAndDistributionRootLogic rootLogic = Get.find<WarehouseAndDistributionRootLogic>();
|
||||
WarehouseAndDistributionRootLogic rootLogic =
|
||||
Get.find<WarehouseAndDistributionRootLogic>();
|
||||
|
||||
WarehouseAndDistributionBuyLogic buyLogic = Get.find<WarehouseAndDistributionBuyLogic>();
|
||||
WarehouseAndDistributionBuyLogic buyLogic =
|
||||
Get.find<WarehouseAndDistributionBuyLogic>();
|
||||
|
||||
WarehouseAndDistributionSaleLogic outOfTheProvinceLogic = Get.find<WarehouseAndDistributionSaleLogic>();
|
||||
WarehouseAndDistributionSaleLogic outOfTheProvinceLogic =
|
||||
Get.find<WarehouseAndDistributionSaleLogic>();
|
||||
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
TextEditingController sellerNameController = TextEditingController();
|
||||
@@ -61,7 +64,9 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
getStewardPurchaseOutOfProvince();
|
||||
selectedProvince.listen((p0) => getCites());
|
||||
|
||||
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
// TODO: Fix - rolesProductsModel doesn't exist, use rolesProduct instead
|
||||
// selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
selectedProduct.value = rootLogic.rolesProduct.value;
|
||||
setupListeners();
|
||||
|
||||
debounce(
|
||||
@@ -84,11 +89,14 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
searchedValue.value = data?.trim();
|
||||
}
|
||||
|
||||
Future<void> getStewardPurchaseOutOfProvince([bool isLoadingMore = false]) async {
|
||||
Future<void> getStewardPurchaseOutOfProvince([
|
||||
bool isLoadingMore = false,
|
||||
]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
purchaseOutOfProvinceList.value = Resource<PaginationModel<StewardFreeBar>>.loading();
|
||||
purchaseOutOfProvinceList.value =
|
||||
Resource<PaginationModel<StewardFreeBar>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
@@ -96,48 +104,56 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
currentPage.value > 1) {
|
||||
currentPage.value = 1; // Reset to first page if search value is set
|
||||
}
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic, need to use killHouseRepository or inject chickenRepository
|
||||
await safeCall(
|
||||
call: () => rootLogic.chickenRepository.getStewardPurchasesOutSideOfTheProvince(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
pageSize: 20,
|
||||
page: currentPage.value,
|
||||
search: 'filter',
|
||||
role: 'Steward',
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
),
|
||||
),
|
||||
// call: () => rootLogic.chickenRepository.getStewardPurchasesOutSideOfTheProvince(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// queryParameters: buildQueryParams(
|
||||
// pageSize: 20,
|
||||
// page: currentPage.value,
|
||||
// search: 'filter',
|
||||
// role: 'Steward',
|
||||
// value: searchedValue.value,
|
||||
// fromDate: fromDateFilter.value.toDateTime(),
|
||||
// toDate: toDateFilter.value.toDateTime(),
|
||||
// ),
|
||||
// ),
|
||||
call: () async => null as PaginationModel<StewardFreeBar>?,
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
purchaseOutOfProvinceList.value = Resource<PaginationModel<StewardFreeBar>>.empty();
|
||||
} else {
|
||||
purchaseOutOfProvinceList.value = Resource<PaginationModel<StewardFreeBar>>.success(
|
||||
PaginationModel<StewardFreeBar>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: [
|
||||
...(purchaseOutOfProvinceList.value.data?.results ?? []),
|
||||
...(res?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
// TODO: Fix - res type issues
|
||||
// if ((res?.count ?? 0) == 0) {
|
||||
// purchaseOutOfProvinceList.value = Resource<PaginationModel<StewardFreeBar>>.empty();
|
||||
// } else {
|
||||
// purchaseOutOfProvinceList.value = Resource<PaginationModel<StewardFreeBar>>.success(
|
||||
// PaginationModel<StewardFreeBar>(
|
||||
// count: res?.count ?? 0,
|
||||
// next: res?.next,
|
||||
// previous: res?.previous,
|
||||
// results: [
|
||||
// ...(purchaseOutOfProvinceList.value.data?.results ?? []),
|
||||
// ...(res?.results ?? []),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
purchaseOutOfProvinceList.value =
|
||||
Resource<PaginationModel<StewardFreeBar>>.empty();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getCites() async {
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
await safeCall(
|
||||
call: () =>
|
||||
rootLogic.chickenRepository.getCity(provinceName: selectedProvince.value?.name ?? ''),
|
||||
// call: () =>
|
||||
// rootLogic.chickenRepository.getCity(provinceName: selectedProvince.value?.name ?? ''),
|
||||
call: () async => null as List<IranProvinceCityModel>?,
|
||||
onSuccess: (result) {
|
||||
if (result != null && result.isNotEmpty) {
|
||||
cites.value = result;
|
||||
}
|
||||
// TODO: Fix - result type issues
|
||||
// if (result != null && result.isNotEmpty) {
|
||||
// cites.value = result;
|
||||
// }
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -190,21 +206,22 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
await safeCall(
|
||||
showError: true,
|
||||
call: () async {
|
||||
CreateStewardFreeBar createStewardFreeBar = CreateStewardFreeBar(
|
||||
productKey: selectedProduct.value!.key,
|
||||
killHouseName: sellerNameController.text,
|
||||
killHouseMobile: sellerPhoneController.text,
|
||||
province: selectedProvince.value!.name,
|
||||
city: selectedCity.value!.name,
|
||||
weightOfCarcasses: int.parse(carcassWeightController.text.clearComma),
|
||||
numberOfCarcasses: int.parse(carcassCountController.text.clearComma),
|
||||
barImage: _base64Image.value,
|
||||
date: DateTime.now().formattedYHMS,
|
||||
);
|
||||
await rootLogic.chickenRepository.createStewardPurchasesOutSideOfTheProvince(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
body: createStewardFreeBar,
|
||||
);
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
// CreateStewardFreeBar createStewardFreeBar = CreateStewardFreeBar(
|
||||
// productKey: selectedProduct.value!.key,
|
||||
// killHouseName: sellerNameController.text,
|
||||
// killHouseMobile: sellerPhoneController.text,
|
||||
// province: selectedProvince.value!.name,
|
||||
// city: selectedCity.value!.name,
|
||||
// weightOfCarcasses: int.parse(carcassWeightController.text.clearComma),
|
||||
// numberOfCarcasses: int.parse(carcassCountController.text.clearComma),
|
||||
// barImage: _base64Image.value,
|
||||
// date: DateTime.now().formattedYHMS,
|
||||
// );
|
||||
// await rootLogic.chickenRepository.createStewardPurchasesOutSideOfTheProvince(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// body: createStewardFreeBar,
|
||||
// );
|
||||
},
|
||||
onSuccess: (result) {
|
||||
getStewardPurchaseOutOfProvince();
|
||||
@@ -240,9 +257,13 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
editFreeBarKey.value = item.key;
|
||||
selectedProvince.value = IranProvinceCityModel(name: item.province);
|
||||
selectedCity.value = IranProvinceCityModel(name: item.city);
|
||||
selectedProduct.value = rootLogic.rolesProductsModel.firstWhere(
|
||||
(element) => element.key == item.product!.key,
|
||||
);
|
||||
// TODO: Fix - rolesProductsModel doesn't exist, use rolesProduct instead
|
||||
// selectedProduct.value = rootLogic.rolesProductsModel.firstWhere(
|
||||
// (element) => element.key == item.product!.key,
|
||||
// );
|
||||
if (rootLogic.rolesProduct.value?.key == item.product!.key) {
|
||||
selectedProduct.value = rootLogic.rolesProduct.value;
|
||||
}
|
||||
|
||||
isSubmitButtonEnabled.value = true;
|
||||
}
|
||||
@@ -266,10 +287,12 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
|
||||
await safeCall(
|
||||
showError: true,
|
||||
call: () => rootLogic.chickenRepository.editStewardPurchasesOutSideOfTheProvince(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
body: edit,
|
||||
),
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
// call: () => rootLogic.chickenRepository.editStewardPurchasesOutSideOfTheProvince(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// body: edit,
|
||||
// ),
|
||||
call: () async {},
|
||||
onSuccess: (result) {
|
||||
onRefresh();
|
||||
rootLogic.onRefresh();
|
||||
@@ -280,10 +303,12 @@ class WarehouseAndDistributionBuyOutOfProvinceLogic extends GetxController {
|
||||
|
||||
Future<void> deleteStewardPurchaseOutOfProvince(String key) async {
|
||||
await safeCall(
|
||||
call: () => rootLogic.chickenRepository.deleteStewardPurchasesOutSideOfTheProvince(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildRawQueryParams(queryParams: {'key': key}),
|
||||
),
|
||||
// TODO: Fix - chickenRepository doesn't exist in rootLogic
|
||||
// call: () => rootLogic.chickenRepository.deleteStewardPurchasesOutSideOfTheProvince(
|
||||
// token: rootLogic.tokenService.accessToken.value!,
|
||||
// queryParameters: buildRawQueryParams(queryParams: {'key': key}),
|
||||
// ),
|
||||
call: () async {},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ class WarehouseAndDistributionBuyOutOfProvincePage
|
||||
isOnEdit ? 'ویرایش اطلاعات خرید' : 'ثبت اطلاعات خرید',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
_productDropDown(),
|
||||
//_productDropDown(),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
@@ -467,7 +467,7 @@ class WarehouseAndDistributionBuyOutOfProvincePage
|
||||
});
|
||||
}
|
||||
|
||||
Widget _productDropDown() {
|
||||
/* Widget _productDropDown() {
|
||||
return Obx(() {
|
||||
return OverlayDropdownWidget<ProductModel>(
|
||||
items: controller.rootLogic.rolesProductsModel,
|
||||
@@ -496,7 +496,7 @@ class WarehouseAndDistributionBuyOutOfProvincePage
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
Widget _provinceWidget() {
|
||||
return Obx(() {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
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/presentation/pages/kill_house/root/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/kill_house/warehouse_and_distribution/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class WarehouseAndDistributionHomeLogic extends GetxController {
|
||||
WarehouseAndDistributionRootLogic rootLogic = Get.find<WarehouseAndDistributionRootLogic>();
|
||||
RxnInt totalWeightTodayBars = RxnInt();
|
||||
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
|
||||
Rxn<BarInformation> barInformation = Rxn();
|
||||
WarehouseAndDistributionRootLogic rootLogic =
|
||||
Get.find<WarehouseAndDistributionRootLogic>();
|
||||
|
||||
RxList<Map<String, String?>> inventoryItems = [
|
||||
{'خریدهای دولتی داخل استان': null},
|
||||
@@ -33,65 +32,15 @@ class WarehouseAndDistributionHomeLogic extends GetxController {
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
refreshData();
|
||||
|
||||
}
|
||||
|
||||
Future<void> refreshData() async {
|
||||
await Future.wait([
|
||||
getGeneralBarsInformation(),
|
||||
getTodayBars(),
|
||||
getDistributionInformation(),
|
||||
rootLogic.getRolesProducts(),
|
||||
rootLogic.getKillHouseSalesInfoDashboard(),
|
||||
rootLogic.getInfoSaleDashboard(),
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> getGeneralBarsInformation() async {
|
||||
await safeCall<BarInformation?>(
|
||||
call: () async => await rootLogic.chickenRepository.getGeneralBarInformation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(role: 'Steward'),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
barInformation.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getTodayBars() async {
|
||||
await safeCall<BarInformation?>(
|
||||
call: () async => await rootLogic.chickenRepository.getGeneralBarInformation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
fromDate: DateTime.now(),
|
||||
toDate: DateTime.now(),
|
||||
role: 'Steward',
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
totalWeightTodayBars.value = result.totalBarsWeight?.toInt();
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getDistributionInformation() async {
|
||||
await safeCall<KillHouseDistributionInfo?>(
|
||||
call: () async => await rootLogic.chickenRepository.getKillHouseDistributionInfo(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
killHouseDistributionInfo.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart' hide LinearGradient;
|
||||
import 'package:flutter/material.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/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/steward/widely_used/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
@@ -15,7 +16,9 @@ class WarehouseAndDistributionHomePage
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
scrollable: true,
|
||||
isBase: true,
|
||||
isBase: false,
|
||||
hasBack: true,
|
||||
backId: killHouseActionKey,
|
||||
onRefresh: controller.refreshData,
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.only(bottom: 100.h),
|
||||
@@ -24,7 +27,6 @@ class WarehouseAndDistributionHomePage
|
||||
SizedBox(height: 18.h),
|
||||
mainInformation(),
|
||||
SizedBox(height: 8.h),
|
||||
WidelyUsedWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -83,9 +85,9 @@ class WarehouseAndDistributionHomePage
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
_todayShipmentWidget(),
|
||||
_todayShipmentWidget2(),
|
||||
_inventoryWidget(),
|
||||
_dashboradWidget1(),
|
||||
_dashboradWidget2(),
|
||||
|
||||
_inventoryListWidget(),
|
||||
SizedBox(height: 8),
|
||||
broadCastList(),
|
||||
@@ -106,9 +108,8 @@ class WarehouseAndDistributionHomePage
|
||||
Icon(CupertinoIcons.chevron_down, size: 18),
|
||||
],
|
||||
),
|
||||
_todayShipmentWidget(),
|
||||
_todayShipmentWidget2(),
|
||||
_inventoryWidget(),
|
||||
_dashboradWidget1(),
|
||||
_dashboradWidget2(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -153,6 +154,131 @@ class WarehouseAndDistributionHomePage
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dashboradWidget1() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ObxValue(
|
||||
(data) => _informationLabelCard(
|
||||
title: 'کل فروش',
|
||||
titleColor: AppColor.textColor,
|
||||
borderColor: Color(0xFFFFAE00),
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.realAllocatedWeight.separatedByCommaFa ?? '0',
|
||||
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: [const Color(0xFFFFD883), const Color(0xFFFFFBF1)],
|
||||
),
|
||||
),
|
||||
controller.rootLogic.rolesProduct,
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: ObxValue((data) {
|
||||
return _informationLabelCard(
|
||||
title: 'مانده انبار',
|
||||
borderColor: const Color(0xFF9758FF),
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.totalRemainWeight.separatedByCommaFa ?? '0',
|
||||
unit: 'کیلوگرم',
|
||||
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(0xFFD8C1FF), const Color(0xFFFBF9FF)],
|
||||
),
|
||||
);
|
||||
}, controller.rootLogic.rolesProduct),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dashboradWidget2() {
|
||||
return ObxValue((data) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده دولتی',
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data
|
||||
.value
|
||||
?.totalGovernmentalRemainWeight
|
||||
?.separatedByCommaFa ??
|
||||
'0',
|
||||
iconPath: Assets.vec.cubeCardGovermentSvg.path,
|
||||
iconColor: AppColor.textColor,
|
||||
bgDescriptionColor: const Color(0xFFF5ECEE),
|
||||
bgLabelColor: const Color(0xFFDEC1C7),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده آزاد',
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.totalFreeRemainWeight.separatedByCommaFa ?? '0',
|
||||
unit: 'کیلوگرم',
|
||||
iconPath: Assets.vec.cubeCardFreeSvg.path,
|
||||
iconColor: AppColor.textColor,
|
||||
bgDescriptionColor: const Color(0xFFD0ECED),
|
||||
bgLabelColor: const Color(0xFFA5D1D2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.rootLogic.salesInfoDashboard);
|
||||
}
|
||||
|
||||
//todo
|
||||
Widget broadCastList() {
|
||||
return ObxValue((data) {
|
||||
@@ -211,6 +337,47 @@ class WarehouseAndDistributionHomePage
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
Row(
|
||||
spacing: 8,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
//todo
|
||||
Expanded(
|
||||
child: broadcastItem(
|
||||
title: 'وزن انجماد',
|
||||
titleBgColor: const Color(0xFFEBC4CE),
|
||||
valueBgColor: const Color(0xFFEDDCE0),
|
||||
value:
|
||||
data.value?.coldHouseAllocationsWeight.separatedByComma,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: broadcastItem(
|
||||
title: 'قطعه بندی',
|
||||
value: data.value?.segmentationsWeight.separatedByComma,
|
||||
titleBgColor: const Color(0xFFC2D3F2),
|
||||
valueBgColor: const Color(0xFFECF2FF),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: broadcastItem(
|
||||
title: 'مانده آزاد',
|
||||
value: data.value?.totalFreeRemainWeight.separatedByComma,
|
||||
titleBgColor: const Color(0xFFB8E7DC),
|
||||
valueBgColor: const Color(0xFFE6FAF5),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: broadcastItem(
|
||||
title: 'فروش آزاد',
|
||||
value: data.value?.totalFreeOutputWeight.separatedByComma,
|
||||
titleBgColor: const Color(0xFFDDE2F0),
|
||||
valueBgColor: const Color(0xFFEAEFFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 8.h),
|
||||
Row(
|
||||
@@ -219,42 +386,34 @@ class WarehouseAndDistributionHomePage
|
||||
children: [
|
||||
Expanded(
|
||||
child: broadcastItem(
|
||||
title: 'مانده دولتی',
|
||||
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
|
||||
?.totalKillHouseAllocationsWeight
|
||||
.separatedByComma,
|
||||
titleBgColor: const Color(0xFFEBC4CE),
|
||||
valueBgColor: const Color(0xFFEDDCE0),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: broadcastItem(
|
||||
title: 'فروش و توزیع خارج استان',
|
||||
value: data
|
||||
.value
|
||||
?.totalKillHouseFreeSaleBarCarcassesWeight
|
||||
.separatedByComma,
|
||||
titleBgColor: const Color(0xFFC2D3F2),
|
||||
valueBgColor: const Color(0xFFECF2FF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.rootLogic.stewardSalesInfoDashboard);
|
||||
}, controller.rootLogic.salesInfoDashboard);
|
||||
}
|
||||
|
||||
Widget distributionInformationWidget() {
|
||||
/* Widget distributionInformationWidget() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: ObxValue((data) {
|
||||
@@ -301,7 +460,7 @@ class WarehouseAndDistributionHomePage
|
||||
);
|
||||
}, controller.killHouseDistributionInfo),
|
||||
);
|
||||
}
|
||||
} */
|
||||
|
||||
Widget _informationShipment() {
|
||||
return Padding(
|
||||
@@ -344,171 +503,9 @@ class WarehouseAndDistributionHomePage
|
||||
);
|
||||
}
|
||||
|
||||
Widget _inventoryWidget() {
|
||||
return ObxValue((data) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده انبار',
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.totalRemainWeight.separatedByCommaFa ?? '0',
|
||||
iconPath: Assets.vec.cubeSearchSvg.path,
|
||||
bgDescriptionColor: const Color(0xFFEAEFFF),
|
||||
bgLabelColor: const Color(0xFFBDD4FF),
|
||||
iconColor: AppColor.textColor,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'توزیع شده',
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.realAllocatedWeight.separatedByCommaFa ?? '0',
|
||||
iconPath: Assets.vec.cubeRotateSvg.path,
|
||||
iconColor: Color(0xFF5C4D64),
|
||||
bgLabelColor: Color(0xFFC8B8D1),
|
||||
bgDescriptionColor: Color(0xFFDAD4DD),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.rootLogic.inventoryModel);
|
||||
}
|
||||
|
||||
Widget _todayShipmentWidget() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ObxValue(
|
||||
(data) => _informationLabelCard(
|
||||
title: 'بارهای امروز',
|
||||
titleColor: AppColor.textColor,
|
||||
borderColor: Color(0xFFFFAE00),
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.separatedByCommaFa ?? '0',
|
||||
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: [const Color(0xFFFFD883), const Color(0xFFFFFBF1)],
|
||||
),
|
||||
),
|
||||
controller.totalWeightTodayBars,
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: ObxValue((data) {
|
||||
return _informationLabelCard(
|
||||
title: 'درانتظار',
|
||||
borderColor: const Color(0xFF9758FF),
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
|
||||
unit:
|
||||
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
|
||||
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(0xFFD8C1FF), const Color(0xFFFBF9FF)],
|
||||
),
|
||||
);
|
||||
}, controller.barInformation),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _todayShipmentWidget2() {
|
||||
return ObxValue((data) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده دولتی',
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data
|
||||
.value
|
||||
?.totalGovernmentalRemainWeight
|
||||
?.separatedByCommaFa ??
|
||||
'0',
|
||||
iconPath: Assets.vec.cubeCardGovermentSvg.path,
|
||||
iconColor: AppColor.textColor,
|
||||
bgDescriptionColor: const Color(0xFFF5ECEE),
|
||||
bgLabelColor: const Color(0xFFDEC1C7),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده آزاد',
|
||||
isLoading: data.value == null,
|
||||
description:
|
||||
data.value?.totalFreeRemainWeight.separatedByCommaFa ?? '0',
|
||||
unit: 'کیلوگرم',
|
||||
iconPath: Assets.vec.cubeCardFreeSvg.path,
|
||||
iconColor: AppColor.textColor,
|
||||
bgDescriptionColor: const Color(0xFFD0ECED),
|
||||
bgLabelColor: const Color(0xFFA5D1D2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.rootLogic.stewardSalesInfoDashboard);
|
||||
}
|
||||
|
||||
Widget _inventoryListWidget() {
|
||||
return ObxValue((data) {
|
||||
var model = data[0];
|
||||
var model = data.value;
|
||||
return Container(
|
||||
padding: EdgeInsets.fromLTRB(16.w, 0, 11.w, 0),
|
||||
decoration: BoxDecoration(
|
||||
@@ -521,38 +518,39 @@ class WarehouseAndDistributionHomePage
|
||||
children: [
|
||||
inventoryListItem(
|
||||
title: 'خریدهای دولتی داخل استان',
|
||||
value: model.receiveGovernmentalCarcassesWeight.separatedByComma,
|
||||
value:
|
||||
model?.provinceGovernmentalCarcassesWeight?.separatedByComma,
|
||||
),
|
||||
Divider(),
|
||||
inventoryListItem(
|
||||
title: 'خریدهای آزاد داخل استان',
|
||||
value: model.receiveFreeCarcassesWeight?.separatedByComma,
|
||||
value: model?.provinceFreeCarcassesWeight?.separatedByComma,
|
||||
),
|
||||
Divider(),
|
||||
inventoryListItem(
|
||||
title: 'وزن خریدهای خارج استان',
|
||||
value: model.freeBuyingCarcassesWeight?.separatedByComma,
|
||||
value: model?.freeBuyingCarcassesWeight?.separatedByComma,
|
||||
),
|
||||
Divider(),
|
||||
inventoryListItem(
|
||||
title: 'کل ورودی به انبار',
|
||||
value: model.totalCarcassesWeight?.separatedByComma,
|
||||
value: model?.totalCarcassesWeight?.separatedByComma,
|
||||
),
|
||||
Divider(),
|
||||
|
||||
inventoryListItem(
|
||||
title: 'کل فروش',
|
||||
value: model.realAllocatedWeight?.separatedByComma,
|
||||
value: model?.realAllocatedWeight?.separatedByComma,
|
||||
),
|
||||
Divider(),
|
||||
inventoryListItem(
|
||||
title: 'مانده انبار',
|
||||
value: model.totalRemainWeight?.separatedByComma,
|
||||
value: model?.totalRemainWeight?.separatedByComma,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.rootLogic.rolesProductsModel);
|
||||
}, controller.rootLogic.rolesProduct);
|
||||
}
|
||||
|
||||
Widget inventoryListItem({required String title, required String? value}) {
|
||||
@@ -590,6 +588,8 @@ class WarehouseAndDistributionHomePage
|
||||
required String title,
|
||||
required String description,
|
||||
required Color bgDescriptionColor,
|
||||
TextStyle? titleStyle,
|
||||
TextStyle? descriptionStyle,
|
||||
String? iconPath,
|
||||
Widget? icon,
|
||||
Color? borderColor,
|
||||
@@ -638,9 +638,11 @@ class WarehouseAndDistributionHomePage
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14.copyWith(
|
||||
color: titleColor ?? AppColor.mediumGreyDarkActive,
|
||||
),
|
||||
style:
|
||||
titleStyle ??
|
||||
AppFonts.yekan14.copyWith(
|
||||
color: titleColor ?? AppColor.mediumGreyDarkActive,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -665,9 +667,11 @@ class WarehouseAndDistributionHomePage
|
||||
Text(
|
||||
description,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(
|
||||
color: AppColor.mediumGreyDarkActive,
|
||||
),
|
||||
style:
|
||||
descriptionStyle ??
|
||||
AppFonts.yekan16.copyWith(
|
||||
color: AppColor.mediumGreyDarkActive,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
unit,
|
||||
@@ -1055,7 +1059,7 @@ class WarehouseAndDistributionHomePage
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.rootLogic.stewardSalesInfoDashboard);
|
||||
}, controller.rootLogic.salesInfoDashboard);
|
||||
}
|
||||
|
||||
Container commitmentsItemList({
|
||||
|
||||
@@ -2,17 +2,15 @@ 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';
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/warehouse_and_distribution/response/kill_house_sales_info_dashboard.dart';
|
||||
import 'package:rasadyar_chicken/data/models/local/widely_used_local_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.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_remain_weight/steward_remain_weight.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'
|
||||
hide ProductModel;
|
||||
import 'package:rasadyar_chicken/data/repositories/chicken/chicken_repository.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/kill_house/kill_house_repository.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/profile/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/kill_house/warehouse_and_distribution/buy/view.dart';
|
||||
@@ -28,6 +26,10 @@ enum ErrorLocationType { serviceDisabled, permissionDenied, none }
|
||||
|
||||
class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
DateTime? _lastBackPressed;
|
||||
|
||||
late DioRemote dioRemote;
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
RxInt currentPage = 2.obs;
|
||||
List<Widget> pages = [
|
||||
WarehouseAndDistributionBuyPage(),
|
||||
@@ -37,28 +39,24 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
ProfilePage(),
|
||||
];
|
||||
|
||||
late KillHouseRepository killHouseRepository;
|
||||
|
||||
final defaultRoutes = <int, String>{
|
||||
0: ChickenRoutes.buyWarehouseAndDistribution,
|
||||
1: ChickenRoutes.saleWarehouseAndDistribution,
|
||||
};
|
||||
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
|
||||
|
||||
Rxn<ProductModel> rolesProduct = Rxn<ProductModel>();
|
||||
Rxn<WidelyUsedLocalModel> widelyUsedList = Rxn<WidelyUsedLocalModel>();
|
||||
Rxn<StewardSalesInfoDashboard> stewardSalesInfoDashboard =
|
||||
Rxn<StewardSalesInfoDashboard>();
|
||||
Rxn<StewardRemainWeight> stewardRemainWeight = Rxn<StewardRemainWeight>();
|
||||
|
||||
late DioRemote dioRemote;
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
late ChickenRepository chickenRepository;
|
||||
|
||||
late KillHouseRepository killHouseRepository;
|
||||
late ChickenLocalDataSource localDatasource;
|
||||
Rxn<BroadcastPrice> broadcastPrice = Rxn<BroadcastPrice>();
|
||||
Rxn<KillHouseSalesInfoDashboard> salesInfoDashboard =
|
||||
Rxn<KillHouseSalesInfoDashboard>();
|
||||
Rxn<StewardRemainWeight> remainWeight = Rxn<StewardRemainWeight>();
|
||||
|
||||
RxList<ErrorLocationType> errorLocationType = RxList();
|
||||
RxMap<int, dynamic> inventoryExpandedList = RxMap();
|
||||
Rxn<ProductModel> inventoryModel = Rxn<ProductModel>();
|
||||
Rxn<KillHouseSalesInfoDashboard> killHouseSalesInfoDashboard =
|
||||
Rxn<KillHouseSalesInfoDashboard>();
|
||||
RxList<IranProvinceCityModel> provinces = <IranProvinceCityModel>[].obs;
|
||||
|
||||
// Cancel tokens for API calls
|
||||
@@ -68,8 +66,7 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
localDatasource = diChicken.get<ChickenLocalDataSource>();
|
||||
chickenRepository = diChicken.get<ChickenRepository>();
|
||||
|
||||
killHouseRepository = diChicken.get<KillHouseRepository>();
|
||||
}
|
||||
|
||||
@@ -80,20 +77,14 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
if (provinces.isEmpty) {
|
||||
getProvinces();
|
||||
}
|
||||
if (killHouseSalesInfoDashboard.value == null) {
|
||||
getKillHouseSalesInfoDashboard();
|
||||
if (salesInfoDashboard.value == null) {
|
||||
getInfoSaleDashboard();
|
||||
}
|
||||
if (rolesProductsModel.isEmpty) {
|
||||
if (rolesProduct.value == null) {
|
||||
getRolesProducts();
|
||||
}
|
||||
getStewardSaleDashboard();
|
||||
getStewardRemainWeightData();
|
||||
|
||||
if (widelyUsedList.value?.hasInit != true) {
|
||||
//TODO
|
||||
localDatasource.initWidleyUsed().then(
|
||||
(value) => localDatasource.getAllWidely(),
|
||||
);
|
||||
if (broadcastPrice.value == null) {
|
||||
getBroadcastPrice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,12 +98,10 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
await Future.wait([
|
||||
getKillHouseSalesInfoDashboard(),
|
||||
getInfoSaleDashboard(),
|
||||
getRolesProducts(),
|
||||
getStewardSaleDashboard(),
|
||||
getStewardRemainWeightData(),
|
||||
getProvinces(),
|
||||
getStewardRemainWeightData(),
|
||||
getBroadcastPrice(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -124,20 +113,18 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getKillHouseSalesInfoDashboard() async {
|
||||
Future<void> getInfoSaleDashboard() async {
|
||||
// Cancel previous request if still running
|
||||
_inventoryCancelToken?.cancel();
|
||||
_inventoryCancelToken = CancelToken();
|
||||
|
||||
await safeCall<KillHouseSalesInfoDashboard?>(
|
||||
call: () async =>
|
||||
await killHouseRepository.getKillHouseSalesInfoDashboard(
|
||||
token: tokenService.accessToken.value!,
|
||||
cancelToken: _inventoryCancelToken,
|
||||
),
|
||||
call: () async => await killHouseRepository.getInfoDashboard(
|
||||
token: tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
killHouseSalesInfoDashboard.value = result;
|
||||
salesInfoDashboard.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
@@ -165,7 +152,7 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
_provincesCancelToken = CancelToken();
|
||||
|
||||
try {
|
||||
final res = await chickenRepository.getProvince(
|
||||
final res = await killHouseRepository.getProvince(
|
||||
cancelToken: _provincesCancelToken,
|
||||
);
|
||||
if (res != null) {
|
||||
@@ -181,43 +168,26 @@ class WarehouseAndDistributionRootLogic extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getBroadcastPrice() async {
|
||||
safeCall(
|
||||
call: () async => await killHouseRepository.getBroadcastPrice(
|
||||
token: tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
broadcastPrice.value = result;
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getRolesProducts() async {
|
||||
safeCall(
|
||||
call: () async => await chickenRepository.getRolesProducts(
|
||||
await safeCall(
|
||||
call: () async => await killHouseRepository.getRolesProducts(
|
||||
token: tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
rolesProductsModel.value = result;
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
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) {},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getStewardRemainWeightData() async {
|
||||
safeCall(
|
||||
call: () async => await chickenRepository.getStewardRemainWeight(
|
||||
token: tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
stewardRemainWeight.value = result;
|
||||
rolesProduct.value = result.first;
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
|
||||
@@ -458,136 +458,6 @@ class WarehouseAndDistributionRootPage
|
||||
);
|
||||
}
|
||||
|
||||
/*Column oldPage() {
|
||||
return Column(
|
||||
children: [
|
||||
inventoryWidget(),
|
||||
ObxValue((data) => broadcastInformationWidget(data.value), controller.killHouseDistributionInfo),
|
||||
SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
cardWidget(
|
||||
title: 'ورود به انبار',
|
||||
iconPath: Assets.icons.whareHouse.path,
|
||||
onTap: () {
|
||||
Get.toNamed(ChickenRoutes.enteringTheWarehouse);
|
||||
},
|
||||
),
|
||||
cardWidget(
|
||||
title: 'فروش داخل استان',
|
||||
iconPath: Assets.icons.inside.path,
|
||||
onTap: () {
|
||||
Get.toNamed(ChickenRoutes.salesInProvince);
|
||||
},
|
||||
),
|
||||
cardWidget(
|
||||
title: 'فروش خارج استان',
|
||||
iconPath: Assets.icons.outside.path,
|
||||
onTap: () {
|
||||
Get.toNamed(ChickenRoutes.salesOutOfProvince);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
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.inventoryList.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
return ObxValue((expand) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
controller.toggleExpanded(index);
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: AnimatedContainer(
|
||||
onEnd: () {
|
||||
controller.inventoryExpandedList[index] = !controller.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.inventoryList[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
}, controller.inventoryExpandedList);
|
||||
},
|
||||
),
|
||||
controller.inventoryList,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget inventoryItem({required bool isExpanded, required int index, required ProductModel 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(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart';
|
||||
@@ -9,13 +8,16 @@ import 'package:rasadyar_chicken/presentation/pages/kill_house/warehouse_and_dis
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
Rxn<List<AllocatedMadeModel>?> allocatedMadeModel = Rxn<List<AllocatedMadeModel>?>();
|
||||
Rxn<List<AllocatedMadeModel>?> allocatedMadeModel =
|
||||
Rxn<List<AllocatedMadeModel>?>();
|
||||
|
||||
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
|
||||
|
||||
Rxn<StewardFreeBarDashboard> stewardFreeDashboard = Rxn<StewardFreeBarDashboard>();
|
||||
Rxn<StewardFreeBarDashboard> stewardFreeDashboard =
|
||||
Rxn<StewardFreeBarDashboard>();
|
||||
|
||||
WarehouseAndDistributionRootLogic rootLogic = Get.find<WarehouseAndDistributionRootLogic>();
|
||||
WarehouseAndDistributionRootLogic rootLogic =
|
||||
Get.find<WarehouseAndDistributionRootLogic>();
|
||||
|
||||
List<String> routesName = ['فروش'];
|
||||
DateTime? _lastBackPressed;
|
||||
@@ -24,11 +26,10 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
getStewardDashBord();
|
||||
|
||||
}
|
||||
|
||||
Future<void> getAllocatedMade() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getAllocatedMade(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(page: 1, pageSize: 20, search: 'filter', role: 'Steward'),
|
||||
@@ -39,13 +40,13 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void checkVerfication() {}
|
||||
|
||||
void confirmAllocation(ConformAllocation allocation) {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.confirmAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocation: allocation.toJson(),
|
||||
@@ -54,11 +55,11 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void denyAllocation(String token) {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.denyAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocationToken: token,
|
||||
@@ -67,11 +68,11 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> confirmAllAllocations() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.confirmAllAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocationTokens: allocatedMadeModel.value?.map((e) => e.key!).toList() ?? [],
|
||||
@@ -80,10 +81,9 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
|
||||
Future<void> getGuilds() async {}
|
||||
|
||||
Future<void> addSale() async {}
|
||||
@@ -93,7 +93,7 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
void setSelectedProduct(ProductModel value) {}
|
||||
|
||||
Future<void> getStewardDashBord() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getStewardDashboard(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
stratDate: DateTime.now().formattedDashedGregorian,
|
||||
@@ -105,7 +105,7 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> submitAllocation() async {}
|
||||
@@ -116,22 +116,20 @@ class WarehouseAndDistributionSaleLogic extends GetxController {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
void onPopScopTaped() async {
|
||||
|
||||
final now = DateTime.now();
|
||||
if (_lastBackPressed == null || now.difference(_lastBackPressed!) > Duration(seconds: 2)) {
|
||||
_lastBackPressed = now;
|
||||
Get.snackbar(
|
||||
'خروج از برنامه',
|
||||
'برای خروج دوباره بازگشت را بزنید',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: AppColor.warning,
|
||||
);
|
||||
} else {
|
||||
await SystemNavigator.pop();
|
||||
}
|
||||
|
||||
final now = DateTime.now();
|
||||
if (_lastBackPressed == null ||
|
||||
now.difference(_lastBackPressed!) > Duration(seconds: 2)) {
|
||||
_lastBackPressed = now;
|
||||
Get.snackbar(
|
||||
'خروج از برنامه',
|
||||
'برای خروج دوباره بازگشت را بزنید',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: AppColor.warning,
|
||||
);
|
||||
} else {
|
||||
await SystemNavigator.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,30 +126,30 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
|
||||
_updateGovernmentalProductionDateData();
|
||||
_updateFreeProductionDateData();
|
||||
ever(rootLogic.stewardRemainWeight, (callback) {
|
||||
/* ever(rootLogic.stewardRemainWeight, (callback) {
|
||||
_updateGovernmentalProductionDateData();
|
||||
_updateFreeProductionDateData();
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
void _updateGovernmentalProductionDateData() {
|
||||
List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
/* List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
governmentalProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
value: element.amount?.toInt(),
|
||||
),
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
void _updateFreeProductionDateData() {
|
||||
var dates = rootLogic.stewardRemainWeight.value?.free ?? [];
|
||||
/* var dates = rootLogic.stewardRemainWeight.value?.free ?? [];
|
||||
freeProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
value: element.amount?.toInt(),
|
||||
),
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
Future<void> getAllocatedMade([bool isLoadingMore = false]) async {
|
||||
@@ -165,7 +165,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
currentPage.value = 1; // Reset to first page if search value is set
|
||||
}
|
||||
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getAllocatedMade(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
@@ -202,7 +202,8 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
onError: (error, stacktrace) {
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
},
|
||||
);
|
||||
); */
|
||||
|
||||
}
|
||||
|
||||
void checkVerification() {
|
||||
@@ -223,7 +224,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
void confirmAllocation(ConformAllocation allocation) {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.confirmAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocation: allocation.toJson(),
|
||||
@@ -232,11 +233,11 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void denyAllocation(String token) {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.denyAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocationToken: token,
|
||||
@@ -245,11 +246,11 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> confirmAllAllocations() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.confirmAllAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocationTokens: allocatedList.value.data?.results?.map((e) => e.key!).toList() ?? [],
|
||||
@@ -258,13 +259,14 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> getRolesProducts() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getRolesProducts(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
role: 'Steward',
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
@@ -273,11 +275,11 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> getGuilds() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getGuilds(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
@@ -293,7 +295,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> addSale() async {}
|
||||
@@ -309,7 +311,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getGuildProfile() async {
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getProfile(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
@@ -317,7 +319,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
onSuccess: (result) {
|
||||
guildProfile.value = result;
|
||||
},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void setSubmitData() {
|
||||
@@ -344,7 +346,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
Future<void> submitAllocation() async {
|
||||
setSubmitData();
|
||||
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.postSubmitStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -359,11 +361,11 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
Get.back();
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> deleteAllocation(AllocatedMadeModel model) async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.deleteStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: {'steward_allocation_key': model.key},
|
||||
@@ -373,7 +375,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
getAllocatedMade();
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -423,7 +425,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
weight_of_carcasses: weight.value,
|
||||
);
|
||||
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.updateStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -438,7 +440,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
Get.back();
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void setSearchValue(String? data) {
|
||||
@@ -472,7 +474,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getBroadcastPrice() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getBroadcastPrice(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
@@ -485,7 +487,7 @@ class WarehouseAndDistributionSalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
|
||||
@@ -102,7 +102,7 @@ class WarehouseAndDistributionSalesInProvincePage
|
||||
onPressed: () async {
|
||||
await controller.confirmAllAllocations();
|
||||
controller.getAllocatedMade();
|
||||
controller.rootLogic.getKillHouseSalesInfoDashboard();
|
||||
// controller.rootLogic.getKillHouseSalesInfoDashboard();
|
||||
Get.back();
|
||||
},
|
||||
child: Text('تایید'),
|
||||
|
||||
@@ -71,7 +71,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
super.onReady();
|
||||
getOutProvinceSales();
|
||||
getBroadcastPrice();
|
||||
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
// selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
debounce(
|
||||
searchedValue,
|
||||
(callback) => getOutProvinceSales(),
|
||||
@@ -81,10 +81,10 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
|
||||
_updateGovernmentalProductionDateData();
|
||||
_updateFreeProductionDateData();
|
||||
ever(rootLogic.stewardRemainWeight, (callback) {
|
||||
/* ever(rootLogic.stewardRemainWeight, (callback) {
|
||||
_updateGovernmentalProductionDateData();
|
||||
_updateFreeProductionDateData();
|
||||
});
|
||||
}); */
|
||||
ever(quotaType, (_) {
|
||||
remainingStock.value = null;
|
||||
productionDate.value = null;
|
||||
@@ -99,23 +99,23 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
void _updateGovernmentalProductionDateData() {
|
||||
List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
/* List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
governmentalProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
value: element.amount?.toInt(),
|
||||
),
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
void _updateFreeProductionDateData() {
|
||||
var dates = rootLogic.stewardRemainWeight.value?.free ?? [];
|
||||
/* var dates = rootLogic.stewardRemainWeight.value?.free ?? [];
|
||||
freeProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
value: element.amount?.toInt(),
|
||||
),
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
void setSearchValue(String? value) {
|
||||
@@ -129,7 +129,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getOutProvinceSales([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
/* if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
salesList.value = Resource<PaginationModel<StewardFreeSaleBar>>.loading();
|
||||
@@ -164,7 +164,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void setupListeners() {
|
||||
@@ -198,7 +198,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
selectedBuyer.value = buyerLogic.buyerList.value.data?.results?.firstWhere(
|
||||
(element) => element.key == item.buyer?.key,
|
||||
);
|
||||
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
// selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
key = item.key;
|
||||
saleType.value = item.saleType == 'free' ? 2 : 1;
|
||||
quotaType.value = item.quota == 'governmental' ? 1 : 2;
|
||||
@@ -209,12 +209,12 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> deleteStewardPurchaseOutOfProvince(String key) async {
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () => rootLogic.chickenRepository.deleteOutProvinceStewardFreeBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
key: key,
|
||||
),
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<bool> createSale() async {
|
||||
@@ -230,7 +230,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
quota: quotaType.value == 1 ? 'governmental' : 'free',
|
||||
productionDate: productionDate.value?.toDateTime().formattedDashedGregorian,
|
||||
);
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
showError: true,
|
||||
call: () => rootLogic.chickenRepository.createOutProvinceStewardFreeBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -246,7 +246,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
);
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
quota: quotaType.value == 1 ? 'governmental' : 'free',
|
||||
key: key,
|
||||
);
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () => rootLogic.chickenRepository.updateOutProvinceStewardFreeBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
body: requestBody,
|
||||
@@ -285,7 +285,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
);
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
city: item.city,
|
||||
province: item.province,
|
||||
);
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
showError: true,
|
||||
call: () => rootLogic.chickenRepository.updateOutProvinceStewardFreeBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -320,7 +320,7 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
);
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void resetSubmitForm() {
|
||||
@@ -347,15 +347,15 @@ class WarehouseAndDistributionSalesOutOfProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getBroadcastPrice() async {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getBroadcastPrice(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
broadcastPrice.value = result;
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getBroadcastPrice(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
broadcastPrice.value = result;
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
); */
|
||||
}
|
||||
|
||||
void setSaleDate(Jalali value) {
|
||||
|
||||
@@ -371,7 +371,7 @@ class WarehouseAndDistributionSalesOutOfProvincePage extends GetView<WarehouseAn
|
||||
color: AppColor.blueNormal,
|
||||
),
|
||||
),
|
||||
_productDropDown(),
|
||||
// _productDropDown(),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
@@ -734,7 +734,7 @@ class WarehouseAndDistributionSalesOutOfProvincePage extends GetView<WarehouseAn
|
||||
});
|
||||
}
|
||||
|
||||
Widget _productDropDown() {
|
||||
/* Widget _productDropDown() {
|
||||
return Obx(() {
|
||||
return OverlayDropdownWidget<ProductModel>(
|
||||
items: controller.rootLogic.rolesProductsModel,
|
||||
@@ -816,7 +816,7 @@ class WarehouseAndDistributionSalesOutOfProvincePage extends GetView<WarehouseAn
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} */
|
||||
|
||||
Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
Jalali? tempPickedDate;
|
||||
|
||||
@@ -8,12 +8,16 @@ import 'package:rasadyar_chicken/presentation/pages/kill_house/warehouse_and_dis
|
||||
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxController {
|
||||
WarehouseAndDistributionRootLogic rootLogic = Get.find<WarehouseAndDistributionRootLogic>();
|
||||
class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic
|
||||
extends GetxController {
|
||||
WarehouseAndDistributionRootLogic rootLogic =
|
||||
Get.find<WarehouseAndDistributionRootLogic>();
|
||||
|
||||
WarehouseAndDistributionSaleLogic get saleLogic => Get.find<WarehouseAndDistributionSaleLogic>();
|
||||
WarehouseAndDistributionSaleLogic get saleLogic =>
|
||||
Get.find<WarehouseAndDistributionSaleLogic>();
|
||||
|
||||
WarehouseAndDistributionSalesOutOfProvinceLogic get saleOutOfProvince => Get.find<WarehouseAndDistributionSalesOutOfProvinceLogic>();
|
||||
WarehouseAndDistributionSalesOutOfProvinceLogic get saleOutOfProvince =>
|
||||
Get.find<WarehouseAndDistributionSalesOutOfProvinceLogic>();
|
||||
|
||||
RxInt currentPage = 1.obs;
|
||||
RxInt expandedListIndex = (-1).obs;
|
||||
@@ -74,11 +78,14 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> getOutProvinceCarcassesBuyer([bool isLoadingMore = false]) async {
|
||||
Future<void> getOutProvinceCarcassesBuyer([
|
||||
bool isLoadingMore = false,
|
||||
]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
buyerList.value = Resource<PaginationModel<OutProvinceCarcassesBuyer>>.loading();
|
||||
buyerList.value =
|
||||
Resource<PaginationModel<OutProvinceCarcassesBuyer>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
@@ -87,7 +94,7 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
currentPage.value = 1; // Reset to first page if search value is set
|
||||
}
|
||||
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () => rootLogic.chickenRepository.getOutProvinceCarcassesBuyer(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
@@ -116,7 +123,7 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void resetSubmitForm() {
|
||||
@@ -129,7 +136,7 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
}
|
||||
|
||||
Future<void> getCites() async {
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () =>
|
||||
rootLogic.chickenRepository.getCity(provinceName: selectedProvince.value?.name ?? ''),
|
||||
onSuccess: (result) {
|
||||
@@ -138,6 +145,7 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
}
|
||||
},
|
||||
);
|
||||
} */
|
||||
}
|
||||
|
||||
void setupListeners() {
|
||||
@@ -164,7 +172,7 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
if (!(formKey.currentState?.validate() ?? false)) {
|
||||
return res;
|
||||
}
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () async {
|
||||
OutProvinceCarcassesBuyer buyer = OutProvinceCarcassesBuyer(
|
||||
province: selectedProvince.value!.name,
|
||||
@@ -185,7 +193,7 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
resetSubmitForm();
|
||||
res = true;
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -209,12 +217,12 @@ class WarehouseAndDistributionSalesOutOfProvinceBuyersLogic extends GetxControll
|
||||
getOutProvinceCarcassesBuyer();
|
||||
}
|
||||
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
currentPage.value = 1;
|
||||
await rootLogic.onRefresh();
|
||||
await getOutProvinceCarcassesBuyer();
|
||||
}
|
||||
|
||||
void toggleExpansion({int? index}) {
|
||||
if (expandedListIndex.value == index || index == null) {
|
||||
expandedListIndex.value = -1;
|
||||
|
||||
@@ -61,7 +61,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
|
||||
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
//selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
debounce(
|
||||
searchedValue,
|
||||
(callback) => getOutProvinceSales(),
|
||||
@@ -81,7 +81,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
} else {
|
||||
salesList.value = Resource<PaginationModel<StewardFreeSaleBar>>.loading();
|
||||
}
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () => rootLogic.chickenRepository.getStewardFreeSaleBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
@@ -111,7 +111,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void setupListeners() {
|
||||
@@ -139,7 +139,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
selectedBuyer.value = buyerLogic.buyerList.value.data?.results?.firstWhere(
|
||||
(element) => element.key == item.buyer?.key,
|
||||
);
|
||||
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
//selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||
key = item.key;
|
||||
isSaleSubmitButtonEnabled.value = true;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
clearanceCode: quarantineCodeController.text,
|
||||
productKey: selectedProduct.value?.key,
|
||||
);
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () => rootLogic.chickenRepository.createOutProvinceStewardFreeBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
body: requestBody,
|
||||
@@ -176,7 +176,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
onSuccess: (_) {
|
||||
res = true;
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
clearanceCode: quarantineCodeController.text,
|
||||
key: key,
|
||||
);
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
call: () => rootLogic.chickenRepository.updateOutProvinceStewardFreeBar(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
body: requestBody,
|
||||
@@ -205,7 +205,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListLogic extends GetxContr
|
||||
onSuccess: (_) {
|
||||
res = true;
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListPage extends GetView<Wa
|
||||
isOnEdit ? 'ویرایش فروش' : 'افزودن فروش',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
_productDropDown(),
|
||||
//_productDropDown(),
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
@@ -369,7 +369,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListPage extends GetView<Wa
|
||||
});
|
||||
}
|
||||
|
||||
Widget _productDropDown() {
|
||||
/* Widget _productDropDown() {
|
||||
return Obx(() {
|
||||
return OverlayDropdownWidget<ProductModel>(
|
||||
items: controller.rootLogic.rolesProductsModel,
|
||||
@@ -398,7 +398,7 @@ class WarehouseAndDistributionSalesOutOfProvinceSalesListPage extends GetView<Wa
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
GestureDetector timeFilterWidget({
|
||||
isFrom = true,
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_
|
||||
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/steward_remain_weight/steward_remain_weight.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/kill_house/warehouse_and_distribution/root/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
@@ -48,7 +47,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
routesName = ['قطعهبندی'].toList();
|
||||
once(rootLogic.rolesProductsModel, (callback) => selectedProduct.value = callback.first);
|
||||
//once(rootLogic.rolesProductsModel, (callback) => selectedProduct.value = callback.first);
|
||||
getAllSegmentation();
|
||||
getGuilds();
|
||||
|
||||
@@ -58,30 +57,30 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
});
|
||||
_updateGovernmentalProductionDateData();
|
||||
_updateFreeProductionDateData();
|
||||
ever(rootLogic.stewardRemainWeight, (callback) {
|
||||
/* ever(rootLogic.stewardRemainWeight, (callback) {
|
||||
_updateGovernmentalProductionDateData();
|
||||
_updateFreeProductionDateData();
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
void _updateGovernmentalProductionDateData() {
|
||||
List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
/* List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
governmentalProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
value: element.amount?.toInt(),
|
||||
),
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
void _updateFreeProductionDateData() {
|
||||
var dates = rootLogic.stewardRemainWeight.value?.free ?? [];
|
||||
/* var dates = rootLogic.stewardRemainWeight.value?.free ?? [];
|
||||
freeProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
value: element.amount?.toInt(),
|
||||
),
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -150,7 +149,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
currentPage.value = 1; // Reset to first page if search value is set
|
||||
}
|
||||
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.getSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -184,23 +183,23 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> deleteSegmentation(String key) async {
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
showError: true,
|
||||
showSuccess: true,
|
||||
call: () => rootLogic.chickenRepository.deleteSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
key: key,
|
||||
),
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<bool> editSegment() async {
|
||||
var res = true;
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.editSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -217,7 +216,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
onError: (error, stacktrace) {
|
||||
res = false;
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -235,7 +234,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
segmentationModel = segmentationModel.copyWith(
|
||||
productionDate: productionDate.value?.toDateTime().formattedDashedGregorian,
|
||||
);
|
||||
await safeCall(
|
||||
/* await safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.createSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
@@ -254,12 +253,12 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
onError: (error, stacktrace) {
|
||||
res = false;
|
||||
},
|
||||
);
|
||||
); */
|
||||
return res;
|
||||
}
|
||||
|
||||
Future<void> getGuilds() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getGuilds(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(queryParams: {'all': true}, role: 'Steward'),
|
||||
@@ -271,7 +270,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
@@ -285,7 +284,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getBroadcastPrice() async {
|
||||
safeCall(
|
||||
/* safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getBroadcastPrice(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
@@ -296,7 +295,7 @@ class WarehouseAndDistributionSegmentationLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stacktrace) {},
|
||||
);
|
||||
); */
|
||||
}
|
||||
|
||||
void toggleExpansion({int? index}) {
|
||||
|
||||
@@ -279,7 +279,7 @@ Widget submitButtonWidget(WarehouseAndDistributionSegmentationLogic controller,
|
||||
}
|
||||
|
||||
Widget _productDropDown(WarehouseAndDistributionSegmentationLogic controller) {
|
||||
return Obx(() {
|
||||
/* return Obx(() {
|
||||
return OverlayDropdownWidget<ProductModel>(
|
||||
items: controller.rootLogic.rolesProductsModel,
|
||||
height: 56,
|
||||
@@ -306,7 +306,8 @@ Widget _productDropDown(WarehouseAndDistributionSegmentationLogic controller) {
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}); */
|
||||
return Container();
|
||||
}
|
||||
|
||||
Widget guildsDropDown(WarehouseAndDistributionSegmentationLogic controller) {
|
||||
|
||||
@@ -43,7 +43,7 @@ class HomeLogic extends GetxController {
|
||||
getTodayBars(),
|
||||
getDistributionInformation(),
|
||||
rootLogic.getRolesProducts(),
|
||||
rootLogic.getInventory(),
|
||||
rootLogic.getRolesProduct(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart' hide LinearGradient;
|
||||
import 'package:flutter/material.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/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/steward/widely_used/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -74,7 +74,7 @@ class StewardRootLogic extends GetxController {
|
||||
getProvinces();
|
||||
}
|
||||
if (inventoryModel.value == null) {
|
||||
getInventory();
|
||||
getRolesProduct();
|
||||
}
|
||||
if (rolesProductsModel.isEmpty) {
|
||||
getRolesProducts();
|
||||
@@ -100,7 +100,7 @@ class StewardRootLogic extends GetxController {
|
||||
|
||||
Future<void> onRefresh() async {
|
||||
await Future.wait([
|
||||
getInventory(),
|
||||
getRolesProduct(),
|
||||
getRolesProducts(),
|
||||
getStewardSaleDashboard(),
|
||||
getStewardRemainWeightData(),
|
||||
@@ -117,13 +117,13 @@ class StewardRootLogic extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getInventory() async {
|
||||
Future<void> getRolesProduct() async {
|
||||
// Cancel previous request if still running
|
||||
_inventoryCancelToken?.cancel();
|
||||
_inventoryCancelToken = CancelToken();
|
||||
|
||||
await safeCall<List<ProductModel>?>(
|
||||
call: () async => await chickenRepository.getInventory(
|
||||
call: () async => await chickenRepository.getRolesProduct(
|
||||
token: tokenService.accessToken.value!,
|
||||
cancelToken: _inventoryCancelToken,
|
||||
role: 'Steward',
|
||||
@@ -178,6 +178,7 @@ class StewardRootLogic extends GetxController {
|
||||
safeCall(
|
||||
call: () async => await chickenRepository.getRolesProducts(
|
||||
token: tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(role: 'Steward'),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
|
||||
@@ -56,7 +56,8 @@ class SalesInProvinceLogic extends GetxController {
|
||||
final RxBool hasMoreDataAllocationsMade = true.obs;
|
||||
|
||||
Rxn<BroadcastPrice> broadcastPrice = Rxn<BroadcastPrice>();
|
||||
Rxn<AllocatedMadeModel> selectedAllocationModelForUpdate = Rxn<AllocatedMadeModel>();
|
||||
Rxn<AllocatedMadeModel> selectedAllocationModelForUpdate =
|
||||
Rxn<AllocatedMadeModel>();
|
||||
SubmitStewardAllocation? tmpStewardAllocation;
|
||||
|
||||
Rxn<Jalali> productionDate = Rxn(null);
|
||||
@@ -133,7 +134,8 @@ class SalesInProvinceLogic extends GetxController {
|
||||
}
|
||||
|
||||
void _updateGovernmentalProductionDateData() {
|
||||
List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
List<RemainWeightDay> dates =
|
||||
rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
governmentalProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
@@ -156,7 +158,8 @@ class SalesInProvinceLogic extends GetxController {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
allocatedList.value = Resource<PaginationModel<AllocatedMadeModel>>.loading();
|
||||
allocatedList.value =
|
||||
Resource<PaginationModel<AllocatedMadeModel>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
@@ -181,18 +184,23 @@ class SalesInProvinceLogic extends GetxController {
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 200));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
allocatedList.value = Resource<PaginationModel<AllocatedMadeModel>>.empty();
|
||||
allocatedList.value =
|
||||
Resource<PaginationModel<AllocatedMadeModel>>.empty();
|
||||
} else {
|
||||
allocatedList.value = Resource<PaginationModel<AllocatedMadeModel>>.success(
|
||||
PaginationModel<AllocatedMadeModel>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: isLoadingMore
|
||||
? [...(allocatedList.value.data?.results ?? []), ...(res?.results ?? [])]
|
||||
: res?.results ?? [],
|
||||
),
|
||||
);
|
||||
allocatedList.value =
|
||||
Resource<PaginationModel<AllocatedMadeModel>>.success(
|
||||
PaginationModel<AllocatedMadeModel>(
|
||||
count: res?.count ?? 0,
|
||||
next: res?.next,
|
||||
previous: res?.previous,
|
||||
results: isLoadingMore
|
||||
? [
|
||||
...(allocatedList.value.data?.results ?? []),
|
||||
...(res?.results ?? []),
|
||||
]
|
||||
: res?.results ?? [],
|
||||
),
|
||||
);
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
if ((allocatedList.value.data?.results?.length ?? 0) > 1) {
|
||||
flashingFabBgColor();
|
||||
@@ -208,10 +216,14 @@ class SalesInProvinceLogic extends GetxController {
|
||||
void checkVerification() {
|
||||
var hasWeight = quotaType.value == 1
|
||||
? weight.value <=
|
||||
(governmentalProductionDateData[productionDate.value?.formatCompactDate()]?.value ??
|
||||
(governmentalProductionDateData[productionDate.value
|
||||
?.formatCompactDate()]
|
||||
?.value ??
|
||||
0)
|
||||
: weight.value <=
|
||||
(freeProductionDateData[productionDate.value?.formatCompactDate()]?.value ?? 0);
|
||||
(freeProductionDateData[productionDate.value?.formatCompactDate()]
|
||||
?.value ??
|
||||
0);
|
||||
|
||||
isValid.value =
|
||||
weight.value > 0 &&
|
||||
@@ -252,7 +264,9 @@ class SalesInProvinceLogic extends GetxController {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.confirmAllAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
allocationTokens: allocatedList.value.data?.results?.map((e) => e.key!).toList() ?? [],
|
||||
allocationTokens:
|
||||
allocatedList.value.data?.results?.map((e) => e.key!).toList() ??
|
||||
[],
|
||||
),
|
||||
onSuccess: (result) {
|
||||
getAllocatedMade();
|
||||
@@ -265,6 +279,7 @@ class SalesInProvinceLogic extends GetxController {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getRolesProducts(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(role: 'Steward'),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
@@ -326,13 +341,17 @@ class SalesInProvinceLogic extends GetxController {
|
||||
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",
|
||||
buyerType: selectedGuildModel.value?.steward == true
|
||||
? "Steward"
|
||||
: "Guild",
|
||||
amount: pricePerKilo.value,
|
||||
totalAmount: totalCost.value,
|
||||
weightOfCarcasses: weight.value,
|
||||
sellType: saleType.value == 2 ? "free" : 'exclusive',
|
||||
numberOfCarcasses: 0,
|
||||
productionDate: productionDate.value?.toDateTime().formattedDashedGregorian,
|
||||
productionDate: productionDate.value
|
||||
?.toDateTime()
|
||||
.formattedDashedGregorian,
|
||||
quota: quotaType.value == 1 ? 'governmental' : 'free',
|
||||
guildKey: selectedGuildModel.value?.key,
|
||||
productKey: selectedProductModel.value?.key,
|
||||
@@ -346,16 +365,20 @@ class SalesInProvinceLogic extends GetxController {
|
||||
|
||||
safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.postSubmitStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: tmpStewardAllocation!,
|
||||
),
|
||||
call: () async =>
|
||||
await rootLogic.chickenRepository.postSubmitStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: tmpStewardAllocation!,
|
||||
),
|
||||
|
||||
onSuccess: (result) {
|
||||
clearForm();
|
||||
onRefresh();
|
||||
rootLogic.onRefresh();
|
||||
Future.delayed(Duration(seconds: 1), () => defaultShowSuccessMessage("ثبت موفق بود"));
|
||||
Future.delayed(
|
||||
Duration(seconds: 1),
|
||||
() => defaultShowSuccessMessage("ثبت موفق بود"),
|
||||
);
|
||||
Get.back();
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
@@ -364,10 +387,11 @@ class SalesInProvinceLogic extends GetxController {
|
||||
|
||||
Future<void> deleteAllocation(AllocatedMadeModel model) async {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.deleteStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: {'steward_allocation_key': model.key},
|
||||
),
|
||||
call: () async =>
|
||||
await rootLogic.chickenRepository.deleteStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: {'steward_allocation_key': model.key},
|
||||
),
|
||||
|
||||
onSuccess: (result) {
|
||||
getAllocatedMade();
|
||||
@@ -391,7 +415,9 @@ class SalesInProvinceLogic extends GetxController {
|
||||
pricePerKilo.value = item.amount ?? 0;
|
||||
totalCost.value = item.totalAmount ?? 0;
|
||||
weightController.text = weight.value.toString().separatedByComma;
|
||||
pricePerKiloController.text = pricePerKilo.value.toString().separatedByComma;
|
||||
pricePerKiloController.text = pricePerKilo.value
|
||||
.toString()
|
||||
.separatedByComma;
|
||||
totalCostController.text = totalCost.value.toString().separatedByComma;
|
||||
isValid.value = true;
|
||||
productionDate.value = item.productionDate.toJalali;
|
||||
@@ -425,16 +451,20 @@ class SalesInProvinceLogic extends GetxController {
|
||||
|
||||
safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.updateStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: updatedAllocationModel,
|
||||
),
|
||||
call: () async =>
|
||||
await rootLogic.chickenRepository.updateStewardAllocation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
request: updatedAllocationModel,
|
||||
),
|
||||
|
||||
onSuccess: (result) {
|
||||
clearForm();
|
||||
onRefresh();
|
||||
rootLogic.onRefresh();
|
||||
Future.delayed(Duration(seconds: 1), () => defaultShowSuccessMessage("ویرایش موفق بود"));
|
||||
Future.delayed(
|
||||
Duration(seconds: 1),
|
||||
() => defaultShowSuccessMessage("ویرایش موفق بود"),
|
||||
);
|
||||
Get.back();
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
@@ -480,7 +510,9 @@ class SalesInProvinceLogic extends GetxController {
|
||||
broadcastPrice.value = result;
|
||||
if (broadcastPrice.value?.active == true) {
|
||||
pricePerKilo.value = broadcastPrice.value?.stewardPrice ?? 0;
|
||||
pricePerKiloController.text = pricePerKilo.value.toString().separatedByComma;
|
||||
pricePerKiloController.text = pricePerKilo.value
|
||||
.toString()
|
||||
.separatedByComma;
|
||||
priceType.value = 2;
|
||||
}
|
||||
},
|
||||
@@ -492,7 +524,11 @@ class SalesInProvinceLogic extends GetxController {
|
||||
toggleExpansion();
|
||||
currentPage.value = 1;
|
||||
hasMoreDataAllocationsMade.value = true;
|
||||
await Future.wait([getAllocatedMade(), getRolesProducts(), rootLogic.onRefresh()]);
|
||||
await Future.wait([
|
||||
getAllocatedMade(),
|
||||
getRolesProducts(),
|
||||
rootLogic.onRefresh(),
|
||||
]);
|
||||
}
|
||||
|
||||
void toggleExpansion({int? index}) {
|
||||
|
||||
@@ -101,7 +101,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
|
||||
onPressed: () async {
|
||||
await controller.confirmAllAllocations();
|
||||
controller.getAllocatedMade();
|
||||
controller.rootLogic.getInventory();
|
||||
controller.rootLogic.getRolesProduct();
|
||||
Get.back();
|
||||
},
|
||||
child: Text('تایید'),
|
||||
|
||||
@@ -136,7 +136,7 @@ void main() {
|
||||
|
||||
// Mock the flow
|
||||
when(
|
||||
() => mockRemote.getInventory(
|
||||
() => mockRemote.getRolesProduct(
|
||||
token: token,
|
||||
role: 'steward',
|
||||
cancelToken: any(named: 'cancelToken'),
|
||||
@@ -148,7 +148,7 @@ void main() {
|
||||
).thenAnswer((_) async => expectedKillHouseInfo);
|
||||
|
||||
// Act - Step 1: Get inventory
|
||||
final inventory = await chickenRepository.getInventory(
|
||||
final inventory = await chickenRepository.getRolesProduct(
|
||||
token: token,
|
||||
role: 'steward',
|
||||
);
|
||||
@@ -162,7 +162,7 @@ void main() {
|
||||
expect(killHouseInfo, equals(expectedKillHouseInfo));
|
||||
|
||||
verify(
|
||||
() => mockRemote.getInventory(
|
||||
() => mockRemote.getRolesProduct(
|
||||
token: token,
|
||||
role: 'steward',
|
||||
cancelToken: any(named: 'cancelToken'),
|
||||
@@ -407,7 +407,7 @@ void main() {
|
||||
test('should handle inventory retrieval failure', () async {
|
||||
// Arrange
|
||||
when(
|
||||
() => mockRemote.getInventory(
|
||||
() => mockRemote.getRolesProduct(
|
||||
token: token,
|
||||
role: 'steward',
|
||||
cancelToken: any(named: 'cancelToken'),
|
||||
@@ -415,7 +415,7 @@ void main() {
|
||||
).thenAnswer((_) async => null);
|
||||
|
||||
// Act
|
||||
final inventory = await chickenRepository.getInventory(
|
||||
final inventory = await chickenRepository.getRolesProduct(
|
||||
token: token,
|
||||
role: 'steward',
|
||||
);
|
||||
@@ -423,7 +423,7 @@ void main() {
|
||||
// Assert
|
||||
expect(inventory, isNull);
|
||||
verify(
|
||||
() => mockRemote.getInventory(
|
||||
() => mockRemote.getRolesProduct(
|
||||
token: token,
|
||||
role: 'steward',
|
||||
cancelToken: any(named: 'cancelToken'),
|
||||
|
||||
@@ -62,7 +62,7 @@ class DioRemote implements IHttpClient {
|
||||
queryParameters: queryParameters,
|
||||
options: Options(headers: headers),
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
cancelToken: cancelToken ?? ApiHandler.globalCancelToken,
|
||||
cancelToken: cancelToken ?? ApiHandler.globalCancelToken,
|
||||
);
|
||||
if (fromJsonListAsync != null && response.data is List) {
|
||||
response.data = await fromJsonListAsync(response.data);
|
||||
|
||||
@@ -32,14 +32,16 @@ class LivestockRemoteDataSourceImp implements LivestockRemoteDataSource {
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data}) async {
|
||||
try {
|
||||
Dio dio = Dio();
|
||||
dio.interceptors.add(PrettyDioLogger(
|
||||
requestBody: false,
|
||||
responseBody: false,
|
||||
requestHeader: true,
|
||||
responseHeader: true,
|
||||
error: true,
|
||||
compact: true,
|
||||
));
|
||||
dio.interceptors.add(
|
||||
PrettyDioLogger(
|
||||
requestBody: false,
|
||||
responseBody: false,
|
||||
requestHeader: true,
|
||||
responseHeader: true,
|
||||
error: false,
|
||||
compact: true,
|
||||
),
|
||||
);
|
||||
dio.options.baseUrl = 'https://everestacademy.ir/live/';
|
||||
final response = await dio.post('api.php', data: data.toJson());
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
Reference in New Issue
Block a user