fix: Selector de dados (Motivo e Nivel)
This commit is contained in:
parent
5a67d5d3f9
commit
91d219e157
|
@ -19,9 +19,7 @@ Widget buildDetails(
|
|||
BuildContext context,
|
||||
Future<dynamic> Function(BuildContext, int, int, String, String)?
|
||||
changeStatusAction) {
|
||||
log('test');
|
||||
log('visitaWrapItem: ${visitaWrapItem.toString()}');
|
||||
log('test');
|
||||
|
||||
return VisitRequestTemplateComponentWidget(
|
||||
buttons: [
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
|
@ -116,11 +114,12 @@ Widget buildDetails(
|
|||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ScheduleCompleteVisitPageWidget(
|
||||
dropdownValue1: visitaWrapItem['MOT_DESCRICAO'],
|
||||
dropdownValue1: visitaWrapItem['MOT_DESCRICAO'],
|
||||
dropdownValue2: visitaWrapItem['NAC_DESCRICAO'],
|
||||
visitorJsonList: [visitaWrapItem],
|
||||
visitorStrList: visitaWrapItem['VTE_DOCUMENTO'],
|
||||
)),
|
||||
)
|
||||
),
|
||||
);
|
||||
},
|
||||
options: FFButtonOptions(
|
||||
|
@ -142,8 +141,8 @@ Widget buildDetails(
|
|||
status.active) // SHARE ACTION
|
||||
FFButtonWidget(
|
||||
text: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Reagendar',
|
||||
enText: 'Reschedule',
|
||||
ptText: 'Compartilhar',
|
||||
enText: 'Share',
|
||||
),
|
||||
icon: const Icon(Icons.share),
|
||||
onPressed: () async {
|
||||
|
|
|
@ -64,10 +64,7 @@ class _ScheduleCompleteVisitPageWidgetState
|
|||
|
||||
// On page load action.
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||
if ((widget.visitorStrList != null && widget.visitorStrList != '') &&
|
||||
((widget.visitorJsonList != null &&
|
||||
(widget.visitorJsonList)!.isNotEmpty) !=
|
||||
null)) {
|
||||
if ((widget.visitorStrList != null && widget.visitorStrList != '') && ((widget.visitorJsonList != null && (widget.visitorJsonList)!.isNotEmpty) != null)) {
|
||||
_model.visitorJsonList = widget.visitorJsonList!
|
||||
.where((e) =>
|
||||
widget.visitorStrList ==
|
||||
|
@ -85,12 +82,9 @@ class _ScheduleCompleteVisitPageWidgetState
|
|||
return;
|
||||
}
|
||||
|
||||
if ((widget.dropdownValue1 != null && widget.dropdownValue1 != '') &&
|
||||
(widget.dropdownValue2 != null && widget.dropdownValue2 != '')) {
|
||||
if ((widget.dropdownValue1 != null && widget.dropdownValue1 != '') && (widget.dropdownValue2 != null && widget.dropdownValue2 != '')) {
|
||||
_model.dropDownValue1 = widget.dropdownValue1!;
|
||||
log('_model.dropdownValue1: ${_model.dropDownValue1 ?? ''}');
|
||||
_model.dropDownValue2 = widget.dropdownValue2!;
|
||||
log('_model.dropdownValue2: ${_model.dropDownValue2 ?? ''}');
|
||||
safeSetState(() {});
|
||||
} else {
|
||||
return;
|
||||
|
@ -135,7 +129,7 @@ class _ScheduleCompleteVisitPageWidgetState
|
|||
}
|
||||
}
|
||||
|
||||
void_scrollListener() {
|
||||
void _scrollListener() {
|
||||
if (_visitHistoryController.position.pixels ==
|
||||
_visitHistoryController.position.maxScrollExtent) {
|
||||
_loadMoreVisitHistory();
|
||||
|
@ -1103,55 +1097,30 @@ Widget scheduleVisit(BuildContext context,
|
|||
),
|
||||
);
|
||||
}
|
||||
final dropDownGetDadosResponse =
|
||||
snapshot.data!;
|
||||
final reasonsJsonList =
|
||||
PhpGroup.getDadosCall.reasonsJsonList(
|
||||
dropDownGetDadosResponse.jsonBody,
|
||||
);
|
||||
// Algoritmo de match // PODE MANDAR DE VASCO
|
||||
if (_model.dropDownValue1 != null &&
|
||||
_model.dropDownValue1!.isNotEmpty) {
|
||||
final matchedValue =
|
||||
reasonsJsonList?.firstWhere(
|
||||
(element) =>
|
||||
element.toString() ==
|
||||
_model.dropDownValue1,
|
||||
orElse: () => null,
|
||||
);
|
||||
if (matchedValue != null) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
_model.dropDownValueController1
|
||||
?.value = matchedValue.toString();
|
||||
});
|
||||
|
||||
final dropDownGetDadosResponse = snapshot.data!;
|
||||
final reasonsJsonList = PhpGroup.getDadosCall.reasonsJsonList(dropDownGetDadosResponse.jsonBody);
|
||||
|
||||
if (_model.dropDownValue1 != '' && _model.dropDownValue1 != null) {
|
||||
String value = _model.dropDownValue1.toString() ?? '';
|
||||
|
||||
if (value.contains('{') && value.contains('}') && value.contains(':')) {
|
||||
// log("Valor e um Objeto | Usuário Escolheu o Motivo ${_model.dropDownValue1}");
|
||||
} else {
|
||||
// log("Valor e uma String | Usuário Escolheu o Motivo ${_model.dropDownValue1}");
|
||||
if (reasonsJsonList != null && reasonsJsonList.isNotEmpty) {
|
||||
var item = reasonsJsonList.where((reason) => reason['MOT_DESCRICAO'].toString().contains(_model.dropDownValue1 ?? ''));
|
||||
_model.dropDownValue1 = item.firstOrNull.toString() ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FlutterFlowDropDown<String>(
|
||||
fillColor: FlutterFlowTheme.of(context)
|
||||
.primaryBackground,
|
||||
controller:
|
||||
_model.dropDownValueController1 ??=
|
||||
FormFieldController<String>(
|
||||
_model.dropDownValue1 ?? ''),
|
||||
options: reasonsJsonList != null &&
|
||||
reasonsJsonList != []
|
||||
? List<String>.from(
|
||||
PhpGroup.getDadosCall
|
||||
.reasonsJsonList(
|
||||
dropDownGetDadosResponse
|
||||
.jsonBody,
|
||||
)!
|
||||
.map((e) => e.toString())
|
||||
.toList())
|
||||
: [],
|
||||
optionLabels: PhpGroup.getDadosCall
|
||||
.reasonsMotDescStrList(
|
||||
dropDownGetDadosResponse.jsonBody,
|
||||
),
|
||||
onChanged: (val) => safeSetState(
|
||||
() => _model.dropDownValue1 = val),
|
||||
fillColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
controller: _model.dropDownValueController1 ??= FormFieldController<String>(_model.dropDownValue1 ??= ''),
|
||||
options: reasonsJsonList != null && reasonsJsonList != [] ? reasonsJsonList.map((e) => e.toString()).toList() : [],
|
||||
optionLabels: PhpGroup.getDadosCall.reasonsMotDescStrList(dropDownGetDadosResponse.jsonBody),
|
||||
onChanged: (val) => safeSetState(() => _model.dropDownValue1 = val),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
textStyle: FlutterFlowTheme.of(context)
|
||||
|
@ -1253,30 +1222,29 @@ Widget scheduleVisit(BuildContext context,
|
|||
),
|
||||
);
|
||||
}
|
||||
final dropDownGetDadosResponse =
|
||||
snapshot.data!;
|
||||
final lavelList =
|
||||
PhpGroup.getDadosCall.levelJsonList(
|
||||
dropDownGetDadosResponse.jsonBody,
|
||||
);
|
||||
|
||||
final dropDownGetDadosResponse = snapshot.data!;
|
||||
final lavelList = PhpGroup.getDadosCall.levelJsonList(dropDownGetDadosResponse.jsonBody);
|
||||
|
||||
if (_model.dropDownValue2 != '' && _model.dropDownValue2 != null) {
|
||||
String value = _model.dropDownValue2.toString() ?? '';
|
||||
|
||||
if (value.contains('{') && value.contains('}') && value.contains(':')) {
|
||||
// log("Valor e um Objeto | Usuário Escolheu o Nivel ${_model.dropDownValue2}");
|
||||
} else {
|
||||
// log("Valor e uma String | Usuário Escolheu o Nivel ${_model.dropDownValue2}");
|
||||
if (lavelList != null && lavelList.isNotEmpty) {
|
||||
var item = lavelList.where((level) => level['NAC_DESCRICAO'].toString().contains(_model.dropDownValue2 ?? ''));
|
||||
_model.dropDownValue2 = item.firstOrNull.toString() ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FlutterFlowDropDown<String>(
|
||||
controller:
|
||||
_model.dropDownValueController2 ??=
|
||||
FormFieldController<String>(
|
||||
_model.dropDownValue2 ??= '',
|
||||
),
|
||||
options:
|
||||
lavelList != null && lavelList != []
|
||||
? List<String>.from(lavelList!
|
||||
.map((e) => e.toString())
|
||||
.toList())
|
||||
: [],
|
||||
optionLabels: PhpGroup.getDadosCall
|
||||
.levelNACDescricaoStrList(
|
||||
dropDownGetDadosResponse.jsonBody,
|
||||
),
|
||||
onChanged: (val) => safeSetState(
|
||||
() => _model.dropDownValue2 = val),
|
||||
controller: _model.dropDownValueController2 ??= FormFieldController<String>(_model.dropDownValue2 ??= ''),
|
||||
options: lavelList != null && lavelList != [] ? lavelList.map((e) => e.toString()).toList() : [],
|
||||
optionLabels: PhpGroup.getDadosCall.levelNACDescricaoStrList(dropDownGetDadosResponse.jsonBody),
|
||||
onChanged: (val) => safeSetState(() => _model.dropDownValue2 = val),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
textStyle: FlutterFlowTheme.of(context)
|
||||
|
@ -1323,7 +1291,7 @@ Widget scheduleVisit(BuildContext context,
|
|||
),
|
||||
],
|
||||
),
|
||||
if (_model.dropDownValue1 == '')
|
||||
if (_model.dropDownValue2 == '')
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
|
@ -1584,7 +1552,6 @@ Widget scheduleVisit(BuildContext context,
|
|||
),
|
||||
onPressed: _model.isValid()
|
||||
? () async {
|
||||
log(_model.dropDownValue1.toString());
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
|
@ -1607,7 +1574,6 @@ Widget scheduleVisit(BuildContext context,
|
|||
),
|
||||
icon: const Icon(Icons.done),
|
||||
onPressed: () async {
|
||||
log('visitorStrList ${_model.visitorStrList}');
|
||||
showAlertDialog(
|
||||
context,
|
||||
FFLocalizations.of(context)
|
||||
|
|
Loading…
Reference in New Issue