Browse Source

plot action history

master
daivph 5 years ago
parent
commit
a2ae8c105b
6 changed files with 104 additions and 18 deletions
  1. +40
    -2
      lib/custom_model/CropPlot.dart
  2. +8
    -8
      lib/data/api/dio_provider.dart
  3. +1
    -2
      lib/presentation/screens/plot/sc_plot.dart
  4. +0
    -1
      lib/presentation/screens/plot_detail/bloc/plot_detail_bloc.dart
  5. +1
    -2
      lib/presentation/screens/plot_detail/sc_plot_action.dart
  6. +54
    -3
      lib/presentation/screens/plot_detail/sc_plot_information.dart

+ 40
- 2
lib/custom_model/CropPlot.dart View File

@@ -72,6 +72,7 @@ class TbCropDTO {
String netHouseName;
int areaId;
String area;
List<TbDetailUsers> tbDetailUsers;

TbCropDTO(
{this.id,
@@ -90,7 +91,8 @@ class TbCropDTO {
this.netHouseId,
this.netHouseName,
this.areaId,
this.area});
this.area,
this.tbDetailUsers});

TbCropDTO.fromJson(Map<String, dynamic> json) {
id = json['id'];
@@ -110,6 +112,12 @@ class TbCropDTO {
netHouseName = json['netHouseName'];
areaId = json['areaId'];
area = json['area'];
if (json['tbDetailUsers'] != null) {
tbDetailUsers = new List<TbDetailUsers>();
json['tbDetailUsers'].forEach((v) {
tbDetailUsers.add(new TbDetailUsers.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
@@ -131,6 +139,32 @@ class TbCropDTO {
data['netHouseName'] = this.netHouseName;
data['areaId'] = this.areaId;
data['area'] = this.area;
if (this.tbDetailUsers != null) {
data['tbDetailUsers'] =
this.tbDetailUsers.map((v) => v.toJson()).toList();
}
return data;
}
}

class TbDetailUsers {
int id;
String fullName;
String phone;

TbDetailUsers({this.id, this.fullName, this.phone});

TbDetailUsers.fromJson(Map<String, dynamic> json) {
id = json['id'];
fullName = json['fullName'];
phone = json['phone'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['fullName'] = this.fullName;
data['phone'] = this.phone;
return data;
}
}
@@ -143,6 +177,7 @@ class Activities {
String description;
int activityTypeId;
String activityTypeName;
String activityTypeDescription;

Activities(
{this.id,
@@ -151,7 +186,8 @@ class Activities {
this.executeDate,
this.description,
this.activityTypeId,
this.activityTypeName});
this.activityTypeName,
this.activityTypeDescription});

Activities.fromJson(Map<String, dynamic> json) {
id = json['id'];
@@ -161,6 +197,7 @@ class Activities {
description = json['description'];
activityTypeId = json['activityTypeId'];
activityTypeName = json['activityTypeName'];
activityTypeDescription = json['activityTypeDescription'];
}

Map<String, dynamic> toJson() {
@@ -172,6 +209,7 @@ class Activities {
data['description'] = this.description;
data['activityTypeId'] = this.activityTypeId;
data['activityTypeName'] = this.activityTypeName;
data['activityTypeDescription'] = this.activityTypeDescription;
return data;
}
}

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

@@ -21,24 +21,24 @@ 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;
}

@override
Future onResponse(Response response) {
log("onResponse: $response");
// log("onResponse: $response");
return super.onResponse(response);
}

@override
Future onError(DioError err) {
log("onError: $err\n"
"Response: ${err.response}");
// log("onError: $err\n"
// "Response: ${err.response}");
return super.onError(err);
}
}

+ 1
- 2
lib/presentation/screens/plot/sc_plot.dart View File

@@ -140,8 +140,7 @@ class ItemInfinityWidget extends StatelessWidget {
child: Card(
color: backgroundColor,
child: ListTile(
title: Text(
item.code.toString() + " - " + item.suppliesName.toString(),
title: Text("${item.code ?? ''} - ${item.suppliesName ?? ''}",
style: TextStyle(color: textColor)),
subtitle: Text(item.startDate.format_DDMMYY_HHmm().toString(),
style: TextStyle(color: textColor)),

+ 0
- 1
lib/presentation/screens/plot_detail/bloc/plot_detail_bloc.dart View File

@@ -35,7 +35,6 @@ class PlotDetailBloc extends Bloc<PlotDetailEvent, PlotDetailState> {
if (state is PlotDetailSuccess) {
final currentState = state as PlotDetailSuccess;
int page = currentState.page + 1;
yield PlotDetailLoading();
final response = await repository.getPlotDetail(event.cropId,
page: page, size: pageSize);
yield response.activities.isEmpty

+ 1
- 2
lib/presentation/screens/plot_detail/sc_plot_action.dart View File

@@ -249,8 +249,7 @@ class ItemInfinityWidget extends StatelessWidget {
return GestureDetector(
child: Card(
child: ListTile(
//TODO: Update actitivy name from Api
title: Text(item.activityTypeName.toString()),
title: Text(item.activityTypeDescription ?? ''),
subtitle: Text(item.executeDate.format_DDMMYY_HHmm()),
),
),

+ 54
- 3
lib/presentation/screens/plot_detail/sc_plot_information.dart View File

@@ -63,12 +63,24 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {
}

_statusController.text = statusCrop;
_houseNameController.text = _crop.netHouseName.toString();
_codeController.text = _crop.code.toString();
_supplyNameController.text = _crop.suppliesName.toString();
_houseNameController.text = _crop.netHouseName?.toString();
_codeController.text = _crop.code?.toString();
_supplyNameController.text = _crop.suppliesName?.toString();
_areaController.text = _crop.areaM2.formatNumtoStringDecimal();
_seedingDateController.text = result.sowingDate.format_DDMMYY_HHmm();
_timeSoakSeedController.text =
result.soakSeedsTime.formatNumtoStringDecimal();
_timeNurserySeedController.text =
result.soakSeedsTime.formatNumtoStringDecimal();
_quantityPlantController.text =
result.numberPlants.formatNumtoStringDecimal();
_currentPlantController.text =
result.numberCurrentPlants.formatNumtoStringDecimal();
_timeEndGrowController.text = _crop.endDate.format_DDMMYY_HHmm();
_descriptionController.text =
_crop.description == null ? "" : _crop.description.toString();
var technicians = _crop.tbDetailUsers.map((e) => e.fullName).join(",");
_mainTechnicianController.text = technicians;
}, (err) {});
}

@@ -80,6 +92,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {
LoadingDialog.hideLoadingDialog(context);
flutterToast.showToast(
child: WidgetToast(message: label_update_success));
controller.initValue();
}).catchError((error) {
_scaffoldKey.currentState.showSnackBar(SnackBar(
content: Row(
@@ -101,6 +114,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _statusField() {
return TextFormField(
enabled: false,
controller: _statusController,
decoration: InputDecoration(labelText: "Trạng thái"),
);
@@ -108,6 +122,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _houseNameField() {
return TextFormField(
enabled: false,
controller: _houseNameController,
decoration: InputDecoration(labelText: "Nhà màng"),
);
@@ -115,6 +130,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _codeField() {
return TextFormField(
enabled: false,
controller: _codeController,
decoration: InputDecoration(labelText: "Mã lô"),
);
@@ -122,6 +138,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _supplyNameField() {
return TextFormField(
enabled: false,
controller: _supplyNameController,
decoration: InputDecoration(labelText: "Giống"),
);
@@ -129,6 +146,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _seedingDateField() {
return TextFormField(
enabled: false,
controller: _seedingDateController,
decoration: InputDecoration(labelText: "Ngày gieo trồng"),
);
@@ -136,6 +154,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _timeSoakSeedField() {
return TextFormField(
enabled: false,
controller: _timeSoakSeedController,
decoration: InputDecoration(labelText: "Thời gian ngâm hạt"),
);
@@ -143,6 +162,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _timeNurserySeedField() {
return TextFormField(
enabled: false,
controller: _timeNurserySeedController,
decoration: InputDecoration(labelText: "Thời gian vô khây ươm"),
);
@@ -150,6 +170,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _quantityPlantField() {
return TextFormField(
enabled: false,
controller: _quantityPlantController,
decoration: InputDecoration(labelText: "Số lượng cây trồng"),
);
@@ -157,6 +178,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _currentPlantField() {
return TextFormField(
enabled: false,
controller: _currentPlantController,
decoration: InputDecoration(labelText: "Số lượng cây hiện tại"),
);
@@ -164,6 +186,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _timeEndGrowField() {
return TextFormField(
enabled: false,
controller: _timeEndGrowController,
decoration: InputDecoration(labelText: "Ngày kết thúc canh tác"),
);
@@ -171,6 +194,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _mainTechnicianField() {
return TextFormField(
enabled: false,
controller: _mainTechnicianController,
decoration: InputDecoration(labelText: "Kỹ sư trực tiếp"),
);
@@ -178,6 +202,7 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {

Widget _areaField() {
return TextFormField(
enabled: false,
controller: _areaController,
decoration: InputDecoration(labelText: "Diện tích (m\u00B2)"),
);
@@ -311,17 +336,43 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> {
return LoadingListPage();
}
}))))));

@override
void dispose() {
_statusController.dispose();
_houseNameController.dispose();
_codeController.dispose();
_supplyNameController.dispose();
_seedingDateController.dispose();
_timeSoakSeedController.dispose();
_timeNurserySeedController.dispose();
_quantityPlantController.dispose();
_currentPlantController.dispose();
_timeEndGrowController.dispose();
_mainTechnicianController.dispose();
_areaController.dispose();
_descriptionController.dispose();
super.dispose();
}
}

class DescriptionChangeControler extends GetxController {
bool isChanged = false;

void initValue() {
isChanged = false;
update();
}

void changeValue(String oldValue, String newValue) {
if (oldValue != newValue) {
isChanged = true;
} else {
isChanged = false;
}
if (oldValue.isNullOrBlank && newValue.isEmpty) {
isChanged = false;
}
update();
}
}

Loading…
Cancel
Save