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

dab672e712362fdbbfa98386624f95d6
440505e9ea1eee7043d2cbfeb318f6bc

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

var token = await pref.getString(DATA_CONST.TOKEN_KEY); var token = await pref.getString(DATA_CONST.TOKEN_KEY);
options.headers["Authorization"] = "Bearer $token"; options.headers["Authorization"] = "Bearer $token";
options.receiveTimeout = 20000; 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; return options;
} }



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

@PUT("/api/update-my-profile") @PUT("/api/update-my-profile")
Future<Account> updateProfile(@Body() Account account); 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 = ""}); {@DioOptions() Options options, @Path() String query = ""});


//Common //Common

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

} }


@override @override
getSupplies({options, query = ""}) async {
getSupplies(type, {options, query = ""}) async {
ArgumentError.checkNotNull(type, 'type');
const _extra = <String, dynamic>{}; const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
newOptions.extra.addAll(_extra); newOptions.extra.addAll(_extra);
newOptions.headers.addAll(<String, dynamic>{}); newOptions.headers.addAll(<String, dynamic>{});
final Response<List<dynamic>> _result = await _dio.request( 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, queryParameters: queryParameters,
options: newOptions.merge(method: 'GET', baseUrl: baseUrl), options: newOptions.merge(method: 'GET', baseUrl: baseUrl),
data: _data); data: _data);

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

return value; return value;
} }


Future<List<Supply>> getSupplies({String query = ""}) async {
Future<List<Supply>> getSupplies(String type, {String query = ""}) async {
final client = RestClient(dio); final client = RestClient(dio);
var op = buildConfigurableCacheOptions( var op = buildConfigurableCacheOptions(
forceRefresh: true, maxAge: Duration(days: ConstCommon.kMaxAgeCache)); 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 { Future<List<Device>> getDeviceForActivity() async {

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

child: Text( child: Text(
plot_action_harvest_process, plot_action_harvest_process,
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 16),
color: Colors.white, fontSize: 14),
), ),
), ),
), ),
child: Text( child: Text(
plot_action_packing, plot_action_packing,
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 16),
color: Colors.white, fontSize: 14),
), ),
), ),
) )
child: Text( child: Text(
plot_action_sell, plot_action_sell,
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 16),
color: Colors.white, fontSize: 14),
), ),
), ),
) )

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

) async* { ) async* {
if (event is DataFetched) { if (event is DataFetched) {
try { try {
final response = await repository.getSupplies(query: event.type);
final response = await repository.getSupplies(event.type);
List<Supply> supplies = response.map((supply) { List<Supply> supplies = response.map((supply) {
if (supply.id == event.selectedId) { if (supply.id == event.selectedId) {
supply.isSelected = true; supply.isSelected = true;
} }
} else if (event is OnRefresh) { } else if (event is OnRefresh) {
try { try {
final response = await repository.getSupplies(query: event.type);
final response = await repository.getSupplies(event.type);
List<Supply> supplies = response.map((supply) { List<Supply> supplies = response.map((supply) {
if (supply.id == event.selectedId) { if (supply.id == event.selectedId) {
supply.isSelected = true; supply.isSelected = true;
} }
} else if (event is OnSearch) { } else if (event is OnSearch) {
try { 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) { if (supply.id == event.selectedId) {
supply.isSelected = true; supply.isSelected = true;
} }

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

static const String supplyTypeDung = "PHANBON"; static const String supplyTypeDung = "PHANBON";
static const String supplyTypeSubStrate = "GIATHE"; static const String supplyTypeSubStrate = "GIATHE";
static const String supplyTypeProtectPlant = "THUOCBVTV"; static const String supplyTypeProtectPlant = "THUOCBVTV";
static const String supplyTypeAll = "";
static const String supplyTypeAll = "ALL";
} }


enum CRUDStatus { unknown, add, edit, delete } enum CRUDStatus { unknown, add, edit, delete }

Loading…
Cancel
Save