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