|
|
|
@@ -75,6 +75,8 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
var _nurseryDetails = <TbNurseryDetailsDTO>[]; |
|
|
|
var _supplyUsings = <SuppliesUsing>[]; |
|
|
|
|
|
|
|
var _previousGroupFieldName = ''; |
|
|
|
|
|
|
|
Future<Null> getSharedPrefs() async { |
|
|
|
var currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME); |
|
|
|
_executeByController.text = currentFullName ?? ""; |
|
|
|
@@ -162,6 +164,9 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
widget.activityType == 'ACTIVE_TYPE_SPRAYING_PESTICIDES') { |
|
|
|
_requestActivity.tbSuppliesUsingDetailsDTOs = _supplyUsings; |
|
|
|
} |
|
|
|
//delete images |
|
|
|
_requestActivity.deletedImages = |
|
|
|
Get.find<ChangeFileController>().deleteFiles; |
|
|
|
//convert data to json |
|
|
|
var activityCommonData = |
|
|
|
jsonEncode(_requestActivity.toJson()).toString(); |
|
|
|
@@ -192,7 +197,6 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
}, |
|
|
|
activityType: widget.activityType, |
|
|
|
activityData: activityCommonData, |
|
|
|
activityId: widget.activityId, |
|
|
|
filePaths: filePaths); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -230,8 +234,52 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
// |
|
|
|
// GENERATE DYNAMIC FORM |
|
|
|
// |
|
|
|
Widget groupName(String name) { |
|
|
|
if (_previousGroupFieldName == name || |
|
|
|
!Validators.stringNotNullOrEmpty(name)) { |
|
|
|
return SizedBox(); |
|
|
|
} else { |
|
|
|
var isShowEndline = false; |
|
|
|
if (Validators.stringNotNullOrEmpty(_previousGroupFieldName)) { |
|
|
|
isShowEndline = true; |
|
|
|
} else { |
|
|
|
//isShowEndline = false; |
|
|
|
} |
|
|
|
_previousGroupFieldName = name ?? ''; |
|
|
|
return Container( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
isShowEndline |
|
|
|
? Container( |
|
|
|
width: double.infinity, |
|
|
|
height: 0.35, |
|
|
|
color: Colors.grey[300], |
|
|
|
) |
|
|
|
: SizedBox(), |
|
|
|
Row( |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
width: 24, |
|
|
|
height: 0.35, |
|
|
|
color: Colors.grey[300], |
|
|
|
), |
|
|
|
Text(' ${name ?? ''} '), |
|
|
|
Expanded( |
|
|
|
child: Container( |
|
|
|
width: 5, |
|
|
|
height: 0.35, |
|
|
|
color: Colors.grey[300], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widget generateTextField(List<ActionUIField> fields) { |
|
|
|
Widget generateField(List<ActionUIField> fields) { |
|
|
|
return Wrap( |
|
|
|
children: [ |
|
|
|
ListView.separated( |
|
|
|
@@ -246,61 +294,86 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
itemBuilder: (context, index) { |
|
|
|
var field = fields[index]; |
|
|
|
if (field.tbControlTypeName == 'text') { |
|
|
|
return TextFormField( |
|
|
|
keyboardType: TextInputType.text, |
|
|
|
decoration: InputDecoration(labelText: field.description), |
|
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
|
onSaved: (newValue) {}, |
|
|
|
validator: field.isMandatory |
|
|
|
? (String value) { |
|
|
|
return Validators.validateNotNullOrEmpty( |
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
} |
|
|
|
: null, |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
groupName(field.groupName), |
|
|
|
TextFormField( |
|
|
|
keyboardType: TextInputType.text, |
|
|
|
decoration: InputDecoration(labelText: field.description), |
|
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
|
onSaved: (newValue) {}, |
|
|
|
validator: field.isMandatory |
|
|
|
? (String value) { |
|
|
|
return Validators.validateNotNullOrEmpty( |
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
} |
|
|
|
: null, |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} else if (field.tbControlTypeName == 'number') { |
|
|
|
return WidgetTextFormFieldNumber( |
|
|
|
hintValue: field.description, |
|
|
|
textController: textFieldControllers[field.id.toString()], |
|
|
|
onSaved: (newValue) {}, |
|
|
|
validator: field.isMandatory |
|
|
|
? (String value) { |
|
|
|
return Validators.validNumberOrEmpty( |
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
} |
|
|
|
: null, |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
groupName(field.groupName), |
|
|
|
WidgetTextFormFieldNumber( |
|
|
|
hintValue: field.description, |
|
|
|
textController: textFieldControllers[field.id.toString()], |
|
|
|
onSaved: (newValue) {}, |
|
|
|
validator: field.isMandatory |
|
|
|
? (String value) { |
|
|
|
return Validators.validNumberOrEmpty( |
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
} |
|
|
|
: null, |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} else if (field.tbControlTypeName == 'textarea') { |
|
|
|
return TextFieldAreaWidget( |
|
|
|
hint: field.description, |
|
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
|
onSaved: (newValue) {}); |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
groupName(field.groupName), |
|
|
|
TextFieldAreaWidget( |
|
|
|
hint: field.description, |
|
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
|
onSaved: (newValue) {}), |
|
|
|
], |
|
|
|
); |
|
|
|
} else if (field.tbControlTypeName == 'dropdown' || |
|
|
|
field.tbControlTypeName == 'radiobutton') { |
|
|
|
return DropdownSupplyWidget( |
|
|
|
titleName: field.description ?? '', |
|
|
|
tbSupply: field.tbActivityExtendTypeExternalTable ?? '', |
|
|
|
tag: field.name, |
|
|
|
value: field.description, |
|
|
|
hint: |
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
condition: field.tbActivityExtendTypeCondition, |
|
|
|
invalidMessage: '', |
|
|
|
onPressed: (commonData) { |
|
|
|
valueObjects[field.id.toString()] = |
|
|
|
commonData.id.toString(); |
|
|
|
}); |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
groupName(field.groupName), |
|
|
|
DropdownSupplyWidget( |
|
|
|
titleName: field.description ?? '', |
|
|
|
tbSupply: field.tbActivityExtendTypeExternalTable ?? '', |
|
|
|
tag: field.name, |
|
|
|
value: field.description, |
|
|
|
hint: |
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
condition: field.tbActivityExtendTypeCondition, |
|
|
|
invalidMessage: '', |
|
|
|
onPressed: (commonData) { |
|
|
|
valueObjects[field.id.toString()] = |
|
|
|
commonData.id.toString(); |
|
|
|
}), |
|
|
|
], |
|
|
|
); |
|
|
|
} else if (field.tbControlTypeName == 'date') { |
|
|
|
return FieldDateWidget( |
|
|
|
tag: field.name, |
|
|
|
value: field.description, |
|
|
|
hint: |
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
invalidMessage: '', |
|
|
|
onPressed: (selectedDate) { |
|
|
|
valueObjects[field.id.toString()] = selectedDate |
|
|
|
.convertLocalDateTimeToStringUtcDateTime(); |
|
|
|
}); |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
groupName(field.groupName), |
|
|
|
FieldDateWidget( |
|
|
|
tag: field.name, |
|
|
|
value: field.description, |
|
|
|
hint: |
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
invalidMessage: '', |
|
|
|
onPressed: (selectedDate) { |
|
|
|
valueObjects[field.id.toString()] = selectedDate |
|
|
|
.convertLocalDateTimeToStringUtcDateTime(); |
|
|
|
}), |
|
|
|
], |
|
|
|
); |
|
|
|
} else { |
|
|
|
return Container(); |
|
|
|
} |
|
|
|
@@ -398,29 +471,30 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
if (_requestActivity.tbObjectUpdateDTOList != null) { |
|
|
|
print(textFieldControllers.keys.toList()); |
|
|
|
_requestActivity.tbObjectUpdateDTOList.forEach((element) { |
|
|
|
if (element.tbObjectParameterDTO.tbControlTypeName == 'text' || |
|
|
|
element.tbObjectParameterDTO.tbControlTypeName == 'textarea') { |
|
|
|
if (element.tbObjectParameterDTO?.tbControlTypeName == 'text' || |
|
|
|
element.tbObjectParameterDTO?.tbControlTypeName == 'textarea') { |
|
|
|
SchedulerBinding.instance.addPostFrameCallback((_) { |
|
|
|
textFieldControllers[element.tbObjectParameterId.toString()].text = |
|
|
|
element.index; |
|
|
|
}); |
|
|
|
} else if (element.tbObjectParameterDTO.tbControlTypeName == 'number') { |
|
|
|
} else if (element.tbObjectParameterDTO?.tbControlTypeName == |
|
|
|
'number') { |
|
|
|
SchedulerBinding.instance.addPostFrameCallback((_) { |
|
|
|
textFieldControllers[element.tbObjectParameterId.toString()].text = |
|
|
|
element.index.formatStringToStringDecimal(); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
SchedulerBinding.instance.addPostFrameCallback((_) { |
|
|
|
print("SchedulerBinding"); |
|
|
|
if (element.tbObjectParameterDTO.tbControlTypeName == 'dropdown' || |
|
|
|
element.tbObjectParameterDTO.tbControlTypeName == 'radio') { |
|
|
|
if (element.tbObjectParameterDTO?.tbControlTypeName == 'dropdown' || |
|
|
|
element.tbObjectParameterDTO?.tbControlTypeName == 'radio') { |
|
|
|
var dropdownValueName = ''; |
|
|
|
if (element.tbObjectParameterDTO |
|
|
|
.tbActivityExtendTypeDropDownDTOList.isNotEmpty || |
|
|
|
?.tbActivityExtendTypeDropDownDTOList?.isNotEmpty || |
|
|
|
element.tbObjectParameterDTO |
|
|
|
.tbActivityExtendTypeDropDownDTOList != |
|
|
|
?.tbActivityExtendTypeDropDownDTOList != |
|
|
|
null) { |
|
|
|
element.tbObjectParameterDTO.tbActivityExtendTypeDropDownDTOList |
|
|
|
element |
|
|
|
.tbObjectParameterDTO?.tbActivityExtendTypeDropDownDTOList |
|
|
|
.forEach((dropdownData) { |
|
|
|
if (dropdownData.id == int.tryParse(element.index)) { |
|
|
|
dropdownValueName = dropdownData.name; |
|
|
|
@@ -431,12 +505,12 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
..id = int.tryParse(element.index) |
|
|
|
..name = dropdownValueName; |
|
|
|
Get.find<ChangeDropdownController>( |
|
|
|
tag: element.tbObjectParameterDTO.name) |
|
|
|
tag: element.tbObjectParameterDTO?.name) |
|
|
|
.change(commonData); |
|
|
|
} else if (element.tbObjectParameterDTO.tbControlTypeName == |
|
|
|
} else if (element.tbObjectParameterDTO?.tbControlTypeName == |
|
|
|
'date') { |
|
|
|
Get.find<ChangeDateTimePicker>( |
|
|
|
tag: element.tbObjectParameterDTO.name) |
|
|
|
tag: element.tbObjectParameterDTO?.name) |
|
|
|
.change(element.index |
|
|
|
.convertStringServerDateTimeToLocalDateTime()); |
|
|
|
} |
|
|
|
@@ -456,7 +530,6 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
], |
|
|
|
child: Scaffold( |
|
|
|
backgroundColor: Colors.white, |
|
|
|
// key: _scaffoldKey, |
|
|
|
appBar: AppBarWidget( |
|
|
|
isBack: true, |
|
|
|
action: InkWell( |
|
|
|
@@ -543,7 +616,7 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
SizedBox( |
|
|
|
height: 8.0, |
|
|
|
), |
|
|
|
generateTextField(_actionUIForm |
|
|
|
generateField(_actionUIForm |
|
|
|
.objectParameterDTOList), |
|
|
|
_executeByField(), |
|
|
|
SizedBox( |