Browse Source

fix get danh sach vat tu

master
daivph 5 years ago
parent
commit
a96e0a02a7
8 changed files with 22 additions and 26 deletions
  1. +1
    -1
      ios/Flutter/.last_build_id
  2. +5
    -5
      lib/data/api/dio_provider.dart
  3. +2
    -2
      lib/data/api/rest_client.dart
  4. +3
    -2
      lib/data/api/rest_client.g.dart
  5. +2
    -2
      lib/data/repository/repository.dart
  6. +3
    -3
      lib/presentation/screens/actions/harvest/sc_edit_action_harvest.dart
  7. +5
    -10
      lib/presentation/screens/resources/bloc/supply_bloc.dart
  8. +1
    -1
      lib/utils/const_common.dart

+ 1
- 1
ios/Flutter/.last_build_id View File

@@ -1 +1 @@
dab672e712362fdbbfa98386624f95d6
440505e9ea1eee7043d2cbfeb318f6bc

+ 5
- 5
lib/data/api/dio_provider.dart View File

@@ -26,11 +26,11 @@ class HttpLogInterceptor extends InterceptorsWrapper {
var token = await pref.getString(DATA_CONST.TOKEN_KEY);
options.headers["Authorization"] = "Bearer $token";
options.receiveTimeout = 20000;
// log("onRequest: ${options.uri}\n"
// "data=${options.data}\n"
// "method=${options.method}\n"
// "headers=${options.headers}\n"
// "queryParameters=${options.queryParameters}");
log("onRequest: ${options.uri}\n"
"data=${options.data}\n"
"method=${options.method}\n"
"headers=${options.headers}\n"
"queryParameters=${options.queryParameters}");
return options;
}


+ 2
- 2
lib/data/api/rest_client.dart View File

@@ -39,8 +39,8 @@ abstract class RestClient {
@PUT("/api/update-my-profile")
Future<Account> updateProfile(@Body() Account account);

@GET("/api/list-supplies-in-warehouses/ALL?q={query}")
Future<List<Supply>> getSupplies(
@GET("/api/list-supplies-in-warehouses/{type}?q={query}")
Future<List<Supply>> getSupplies(@Path() String type,
{@DioOptions() Options options, @Path() String query = ""});

//Common

+ 3
- 2
lib/data/api/rest_client.g.dart View File

@@ -128,7 +128,8 @@ class _RestClient implements RestClient {
}

@override
getSupplies({options, query = ""}) async {
getSupplies(type, {options, query = ""}) async {
ArgumentError.checkNotNull(type, 'type');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
queryParameters.removeWhere((k, v) => v == null);
@@ -137,7 +138,7 @@ class _RestClient implements RestClient {
newOptions.extra.addAll(_extra);
newOptions.headers.addAll(<String, dynamic>{});
final Response<List<dynamic>> _result = await _dio.request(
'/api/list-supplies-in-warehouses/ALL?q=$query',
'/api/list-supplies-in-warehouses/$type?q=$query',
queryParameters: queryParameters,
options: newOptions.merge(method: 'GET', baseUrl: baseUrl),
data: _data);

+ 2
- 2
lib/data/repository/repository.dart View File

@@ -82,11 +82,11 @@ class Repository {
return value;
}

Future<List<Supply>> getSupplies({String query = ""}) async {
Future<List<Supply>> getSupplies(String type, {String query = ""}) async {
final client = RestClient(dio);
var op = buildConfigurableCacheOptions(
forceRefresh: true, maxAge: Duration(days: ConstCommon.kMaxAgeCache));
return client.getSupplies(query: query, options: op);
return client.getSupplies(type, query: query, options: op);
}

Future<List<Device>> getDeviceForActivity() async {

+ 3
- 3
lib/presentation/screens/actions/harvest/sc_edit_action_harvest.dart View File

@@ -411,7 +411,7 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> {
child: Text(
plot_action_harvest_process,
style: TextStyle(
color: Colors.white, fontSize: 16),
color: Colors.white, fontSize: 14),
),
),
),
@@ -437,7 +437,7 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> {
child: Text(
plot_action_packing,
style: TextStyle(
color: Colors.white, fontSize: 16),
color: Colors.white, fontSize: 14),
),
),
)
@@ -471,7 +471,7 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> {
child: Text(
plot_action_sell,
style: TextStyle(
color: Colors.white, fontSize: 16),
color: Colors.white, fontSize: 14),
),
),
)

+ 5
- 10
lib/presentation/screens/resources/bloc/supply_bloc.dart View File

@@ -19,7 +19,7 @@ class SupplyBloc extends Bloc<SupplyEvent, SupplyState> {
) async* {
if (event is DataFetched) {
try {
final response = await repository.getSupplies(query: event.type);
final response = await repository.getSupplies(event.type);
List<Supply> supplies = response.map((supply) {
if (supply.id == event.selectedId) {
supply.isSelected = true;
@@ -32,7 +32,7 @@ class SupplyBloc extends Bloc<SupplyEvent, SupplyState> {
}
} else if (event is OnRefresh) {
try {
final response = await repository.getSupplies(query: event.type);
final response = await repository.getSupplies(event.type);
List<Supply> supplies = response.map((supply) {
if (supply.id == event.selectedId) {
supply.isSelected = true;
@@ -45,14 +45,9 @@ class SupplyBloc extends Bloc<SupplyEvent, SupplyState> {
}
} else if (event is OnSearch) {
try {
final response = await repository.getSupplies(query: event.type);
bool query(Supply supply) =>
event.searchString.isEmpty ||
supply.tbSuppliesName
.toLowerCase()
.contains(event.searchString.toLowerCase());
final result = response.where(query).toList();
List<Supply> supplies = result.map((supply) {
final response =
await repository.getSupplies(event.type, query: event.searchString);
List<Supply> supplies = response.map((supply) {
if (supply.id == event.selectedId) {
supply.isSelected = true;
}

+ 1
- 1
lib/utils/const_common.dart View File

@@ -81,7 +81,7 @@ class ConstCommon {
static const String supplyTypeDung = "PHANBON";
static const String supplyTypeSubStrate = "GIATHE";
static const String supplyTypeProtectPlant = "THUOCBVTV";
static const String supplyTypeAll = "";
static const String supplyTypeAll = "ALL";
}

enum CRUDStatus { unknown, add, edit, delete }

Loading…
Cancel
Save