|
|
|
|
@ -1,18 +1,27 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/validator/validator.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/helper/utils.dart';
|
|
|
|
|
import 'package:test_sa/models/device/asset.dart';
|
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/building.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/floor.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/site.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/modules/incident_module/incident_lookup_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/incident_module/incident_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
|
|
|
|
import 'package:test_sa/modules/loan_module/provider/medical_department_provider.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
@ -21,10 +30,12 @@ import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart
|
|
|
|
|
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
import 'package:test_sa/providers/lookups/yes_no_lookup_provider.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/equipment/asset_picker.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
|
|
|
|
|
|
|
|
|
import '../../models/new_models/department.dart';
|
|
|
|
|
import 'incident_attachment_model.dart';
|
|
|
|
|
|
|
|
|
|
class CreateIncidentRequestPage extends StatefulWidget {
|
|
|
|
|
static const String id = "/create-incident";
|
|
|
|
|
@ -40,8 +51,10 @@ class CreateIncidentRequestPage extends StatefulWidget {
|
|
|
|
|
class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
final List<GenericAttachmentModel> attachments = [];
|
|
|
|
|
List<GenericAttachmentModel> attachments = [];
|
|
|
|
|
|
|
|
|
|
MedicalDepartmentModel? _medicalDepartmentModel;
|
|
|
|
|
Site? _empSite;
|
|
|
|
|
Site? _selectedSite;
|
|
|
|
|
Building? _selectedBuilding;
|
|
|
|
|
Floor? _selectedFloor;
|
|
|
|
|
@ -51,6 +64,12 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
|
|
|
|
|
Lookup? incidentType;
|
|
|
|
|
Lookup? ovrSystem;
|
|
|
|
|
Lookup? rootCause;
|
|
|
|
|
Lookup? involvedPerson;
|
|
|
|
|
Lookup? gender;
|
|
|
|
|
DateTime? occurrenceDate;
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> payload = {};
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -77,26 +96,39 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
...empSiteSection(),
|
|
|
|
|
16.height,
|
|
|
|
|
...incidentInfoSection(),
|
|
|
|
|
if (incidentType?.value == 1) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
"Asset Details".bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AssetPicker(
|
|
|
|
|
device: device,
|
|
|
|
|
showLoading: false,
|
|
|
|
|
borderColor: AppColor.black20,
|
|
|
|
|
onPick: (asset) async {
|
|
|
|
|
device = asset;
|
|
|
|
|
payload["assetId"] = asset.modelDefinition?.id;
|
|
|
|
|
payload["oracleCode"] = asset.modelDefinition?.oracleCodes?.first.codeValue;
|
|
|
|
|
payload["model"] = asset.modelDefinition?.modelName;
|
|
|
|
|
payload["manufacturer"] = asset.modelDefinition?.manufacturerId;
|
|
|
|
|
payload["assetOrigin"] = asset.modelDefinition?.assetName;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
if (incidentType?.value != 1) ...[
|
|
|
|
|
if (incidentType?.value != null && incidentType?.value != 1) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
...siteSection(),
|
|
|
|
|
],
|
|
|
|
|
16.height,
|
|
|
|
|
...vendorDetailsSection(),
|
|
|
|
|
...detailsSection(),
|
|
|
|
|
16.height,
|
|
|
|
|
...optionQuestions(),
|
|
|
|
|
16.height,
|
|
|
|
|
"Attachments".bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AttachmentPicker(
|
|
|
|
|
label: context.translation.attachments,
|
|
|
|
|
attachment: attachments,
|
|
|
|
|
@ -104,8 +136,8 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
showAsListView: true,
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: context.isDark ? AppColor.primary10 : AppColor.neutral120),
|
|
|
|
|
onChange: (attachments) {
|
|
|
|
|
attachments = attachments;
|
|
|
|
|
onChange: (_attachments) {
|
|
|
|
|
attachments = _attachments;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -127,6 +159,27 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> optionQuestions() {
|
|
|
|
|
return [
|
|
|
|
|
'Additional Information & Comments'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Some Comments",
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)),
|
|
|
|
|
labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff767676)),
|
|
|
|
|
floatingLabelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)),
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
makeMultiLinesNull: false,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
payload["comments"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> siteSection() {
|
|
|
|
|
return [
|
|
|
|
|
'Site Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
@ -144,6 +197,7 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_selectedSite = value;
|
|
|
|
|
payload["siteId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -165,6 +219,7 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
_selectedBuilding = value;
|
|
|
|
|
_selectedFloor = null;
|
|
|
|
|
_selectedDepartment = null;
|
|
|
|
|
payload["buildingId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -185,6 +240,7 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_selectedFloor = value;
|
|
|
|
|
_selectedDepartment = null;
|
|
|
|
|
payload["floorId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -204,53 +260,53 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
},
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_selectedDepartment = value;
|
|
|
|
|
// _demoFormModel.room = null;
|
|
|
|
|
payload["departmentId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List<Widget> siteSection() {
|
|
|
|
|
// return [
|
|
|
|
|
// 'Site Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<Site, SiteProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// title: context.translation.site,
|
|
|
|
|
// initialValue: _demoFormModel.site,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// if (value == null) return "Please select a site";
|
|
|
|
|
// return null;
|
|
|
|
|
// },
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// _demoFormModel.site = value;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<MedicalDepartmentModel, MedicalDepartmentProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// title: context.translation.department,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// if (value == null) return "Please select a department";
|
|
|
|
|
// return null;
|
|
|
|
|
// },
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// initialValue: _demoFormModel.department,
|
|
|
|
|
// requestById: context.userProvider.user?.clientId,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// _demoFormModel.department = value;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ];
|
|
|
|
|
// }
|
|
|
|
|
List<Widget> empSiteSection() {
|
|
|
|
|
return [
|
|
|
|
|
SingleItemDropDownMenu<Site, SiteProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: "Employee Site",
|
|
|
|
|
initialValue: _empSite,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select a site";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_empSite = value;
|
|
|
|
|
payload["requestorSiteId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<MedicalDepartmentModel, MedicalDepartmentProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: "Employee Department",
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if (value == null) return "Please select a department";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
initialValue: _medicalDepartmentModel,
|
|
|
|
|
requestById: context.userProvider.user?.clientId,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_medicalDepartmentModel = value;
|
|
|
|
|
payload["requestorFlowDepartmentId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> incidentInfoSection() {
|
|
|
|
|
return [
|
|
|
|
|
@ -270,6 +326,7 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
incidentType = value;
|
|
|
|
|
payload["incidentClassificationId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -288,6 +345,7 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
ovrSystem = value;
|
|
|
|
|
payload["existingOvrTicketId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -307,31 +365,14 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.vendorRepresentativeName = value;
|
|
|
|
|
payload["ovrTicketNumber"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.docName = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Contact Number",
|
|
|
|
|
labelText: "Incident Title",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
@ -340,34 +381,16 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.phone,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.docNumber = value;
|
|
|
|
|
payload["incidentTitle"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Email",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) {
|
|
|
|
|
return "Mandatory";
|
|
|
|
|
} else {
|
|
|
|
|
return Validator.isEmail(value!) ? null : context.translation.emailValidateMessage;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.docEmail = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Item Description",
|
|
|
|
|
labelText: "Incident Description",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
@ -375,171 +398,167 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.itemDescription = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Request Description",
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
// return null;
|
|
|
|
|
// },
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.requestDescription = value;
|
|
|
|
|
payload["incidentDescription"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> assetSection() {
|
|
|
|
|
List<Widget> detailsSection() {
|
|
|
|
|
return [
|
|
|
|
|
'Asset Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
'Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Model",
|
|
|
|
|
SingleItemDropDownMenu<Lookup, IncidentRootCauseLookupProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: "Root Cause",
|
|
|
|
|
initialValue: rootCause,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
if (value == null) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.model = value;
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
rootCause = value;
|
|
|
|
|
payload["rootCauseId"] = value?.id;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (rootCause?.value == 5) ...[
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Root Cause (Other)",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
payload["otherRootCause"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: "Manufacturer",
|
|
|
|
|
SingleItemDropDownMenu<Lookup, IncidentPersonInvolvedLookupProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: "Person Involved",
|
|
|
|
|
initialValue: involvedPerson,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
if (value == null) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
floatingLabelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.text,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.manufacturer = value;
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
involvedPerson = value;
|
|
|
|
|
payload["personInvolvedId"] = value?.id;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, DemoPeriodLookupProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// height: 56.toScreenHeight,
|
|
|
|
|
// title: "Demo Period",
|
|
|
|
|
// initialValue: demoPeriodLookup,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// if (value == null) return "Mandatory";
|
|
|
|
|
// return null;
|
|
|
|
|
// },
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// showAsBottomSheet: true,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// demoPeriodLookup = value;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> vendorDetailsSection() {
|
|
|
|
|
return [
|
|
|
|
|
'Vendor Details'.addTranslation.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Incident Title",
|
|
|
|
|
SingleItemDropDownMenu<Lookup, GenderLookupProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
title: "Gender",
|
|
|
|
|
initialValue: gender,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
if (value == null) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.vendorName = value;
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
gender = value;
|
|
|
|
|
payload["genderId"] = value?.id;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Incident Description",
|
|
|
|
|
labelText: "Person Involved ID",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
if (involvedPerson?.value == 3 && (value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.vendorRepresentativeName = value;
|
|
|
|
|
payload["personInvolvedEmployeeId"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Contact Number",
|
|
|
|
|
labelText: "Person Involved Name",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
if (involvedPerson?.value == 3 && (value ?? "").isEmpty) return "Mandatory";
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.phone,
|
|
|
|
|
textInputType: TextInputType.name,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.vendorNumber = value;
|
|
|
|
|
payload["personInvolvedEmployeeName"] = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: "",
|
|
|
|
|
labelText: "Email",
|
|
|
|
|
validator: (value) {
|
|
|
|
|
if ((value ?? "").isEmpty) {
|
|
|
|
|
return "Mandatory";
|
|
|
|
|
} else {
|
|
|
|
|
return Validator.isEmail(value!) ? null : context.translation.emailValidateMessage;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
showShadow: false,
|
|
|
|
|
textInputType: TextInputType.emailAddress,
|
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
// _demoFormModel.vendorEmail = value;
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: "Occurrence Date & Time",
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
date: occurrenceDate,
|
|
|
|
|
from: DateTime.now().subtract(const Duration(days: 365)),
|
|
|
|
|
// enable: widget.enabled ? _tempPickerTimer == null : false,
|
|
|
|
|
formatDateWithTime: true,
|
|
|
|
|
onDatePicker: (selectedDate) {
|
|
|
|
|
showTimePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialTime: TimeOfDay.now(),
|
|
|
|
|
builder: (BuildContext context, Widget? child) {
|
|
|
|
|
final ThemeData currentTheme = Theme.of(context);
|
|
|
|
|
return Theme(
|
|
|
|
|
data: currentTheme.copyWith(
|
|
|
|
|
timePickerTheme: TimePickerThemeData(
|
|
|
|
|
dialHandColor: AppColor.primary10,
|
|
|
|
|
dialBackgroundColor: Colors.grey.withOpacity(0.1),
|
|
|
|
|
hourMinuteColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.grey.withOpacity(0.1)),
|
|
|
|
|
dayPeriodColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? AppColor.primary10 : Colors.transparent),
|
|
|
|
|
dayPeriodTextColor: MaterialStateColor.resolveWith((states) => states.contains(MaterialState.selected) ? Colors.white : AppColor.primary10),
|
|
|
|
|
dayPeriodBorderSide: BorderSide(color: Colors.grey.withOpacity(0.2)),
|
|
|
|
|
entryModeIconColor: AppColor.primary10,
|
|
|
|
|
),
|
|
|
|
|
textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(foregroundColor: AppColor.primary10)),
|
|
|
|
|
),
|
|
|
|
|
child: child!,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
).then((selectedTime) {
|
|
|
|
|
if (selectedTime != null) {
|
|
|
|
|
occurrenceDate = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
@ -548,25 +567,32 @@ class _CreateIncidentRequestPageState extends State<CreateIncidentRequestPage> {
|
|
|
|
|
Future<void> _submit() async {
|
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
|
if (occurrenceDate == null) {
|
|
|
|
|
"Please select occurrence Data".showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
payload["occurrenceDate"] = occurrenceDate!.toIso8601String();
|
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
|
|
|
|
|
|
// _demoFormModel.demoAttachment = [];
|
|
|
|
|
// for (var item in attachments) {
|
|
|
|
|
// String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
|
|
|
// _demoFormModel.demoAttachment?.add(DemoAttachments(id: 0, attachmentName: fileName, demoRequestId: 0));
|
|
|
|
|
// }
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);
|
|
|
|
|
// Map<String, dynamic> body = _demoFormModel.toJson();
|
|
|
|
|
// body["id"] = 0;
|
|
|
|
|
// // body["LoanTypeId"] = 0;
|
|
|
|
|
// // body["requestorUserID"] = context.userProvider.user!.userID;
|
|
|
|
|
//
|
|
|
|
|
// bool isSuccess = await loanProvider.addLoanRequest(body);
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// if (isSuccess) {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// }
|
|
|
|
|
List<IncidentAttachments> attachmentList = [];
|
|
|
|
|
|
|
|
|
|
for (var item in attachments) {
|
|
|
|
|
String fileName = CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
|
|
|
attachmentList.add(IncidentAttachments(id: 0, attachmentName: fileName, incidentId: 0));
|
|
|
|
|
}
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
IncidentProvider incidentProvider = Provider.of<IncidentProvider>(context, listen: false);
|
|
|
|
|
payload["id"] = 0;
|
|
|
|
|
payload["isFromMobile"] = 0;
|
|
|
|
|
payload["requestorUserId"] = context.userProvider.user!.userID;
|
|
|
|
|
payload["requestorSiteId"] = context.userProvider.user!.clientId;
|
|
|
|
|
payload["incidentAttachments"] = attachmentList.map((v) => v.toJson()).toList();
|
|
|
|
|
bool isSuccess = await incidentProvider.addIncidentRequest(payload);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|