|
|
|
|
@ -7,10 +7,13 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/ppm/ppm.dart';
|
|
|
|
|
import 'package:test_sa/models/ppm/ppm_attachment.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
|
|
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_asset_availability_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_electrical_safety_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_service_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_task_status_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/work_order/vendor_provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../models/lookup.dart';
|
|
|
|
|
import '../../../new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
@ -32,10 +35,16 @@ class PentryTBSForm extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
SupplierDetails initialSupplier;
|
|
|
|
|
SuppPersons _suppPerson;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
widget.model?.files ??= [];
|
|
|
|
|
widget.model?.files = (widget.model.files ?? []).where((element) => element.attachmentName != null && element.attachmentName.isNotEmpty).toList();
|
|
|
|
|
widget.model?.files = (widget.model.files ?? [])
|
|
|
|
|
.where((element) =>
|
|
|
|
|
element.attachmentName != null && element.attachmentName.isNotEmpty)
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
@ -44,11 +53,17 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.model.visitStatusId == null ? null : Lookup(name: widget.model.visitStatusName ?? "", id: widget.model.visitStatusId),
|
|
|
|
|
initialValue: widget.model.visitStatusId == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(
|
|
|
|
|
name: widget.model.visitStatusName ?? "",
|
|
|
|
|
id: widget.model.visitStatusId),
|
|
|
|
|
title: context.translation.ppmVisit,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value?.value == 4) {
|
|
|
|
|
"Status cannot be change to ${value.name}.".addTranslation.showToast;
|
|
|
|
|
"Status cannot be change to ${value.name}."
|
|
|
|
|
.addTranslation
|
|
|
|
|
.showToast;
|
|
|
|
|
setState(() {});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -75,7 +90,11 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.model.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId),
|
|
|
|
|
initialValue: widget.model.deviceStatusId == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(
|
|
|
|
|
name: widget.model.deviceStatusName ?? "",
|
|
|
|
|
id: widget.model.deviceStatusId),
|
|
|
|
|
title: context.translation.deviceStatus,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
@ -87,7 +106,11 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.model.taskStatusId == null ? null : Lookup(name: widget.model.taskStatusName ?? "", id: widget.model.taskStatusId),
|
|
|
|
|
initialValue: widget.model.taskStatusId == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(
|
|
|
|
|
name: widget.model.taskStatusName ?? "",
|
|
|
|
|
id: widget.model.taskStatusId),
|
|
|
|
|
title: context.translation.taskStatus,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
@ -99,7 +122,11 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.model.assetAvailabilityId == null ? null : Lookup(name: widget.model.assetAvailabilityName ?? "", id: widget.model.assetAvailabilityId),
|
|
|
|
|
initialValue: widget.model.assetAvailabilityId == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(
|
|
|
|
|
name: widget.model.assetAvailabilityName ?? "",
|
|
|
|
|
id: widget.model.assetAvailabilityId),
|
|
|
|
|
title: "Asset Availability",
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
@ -109,10 +136,13 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.model.typeOfServiceId == null ? null : Lookup(name: widget.model.typeOfServiceName ?? "", id: widget.model.typeOfServiceId),
|
|
|
|
|
initialValue: widget.model.typeOfServiceId == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(
|
|
|
|
|
name: widget.model.typeOfServiceName ?? "",
|
|
|
|
|
id: widget.model.typeOfServiceId),
|
|
|
|
|
title: context.translation.serviceType,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
@ -120,15 +150,29 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
widget.model.typeOfServiceName = value.name;
|
|
|
|
|
widget.model.safetyId = null;
|
|
|
|
|
widget.model.safetyName = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
widget.model.supplierId = null;
|
|
|
|
|
widget.model.supplierName = null;
|
|
|
|
|
initialSupplier = null;
|
|
|
|
|
_suppPerson = null;
|
|
|
|
|
widget.model.suppPersonId = null;
|
|
|
|
|
widget.model.suppPerson = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
if(widget.model?.typeOfServiceId !=66)...[
|
|
|
|
|
if (widget.model?.typeOfServiceId != 66) ...[
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.model.safetyId == null ? null : Lookup(name: widget.model.safetyName ?? "", id: widget.model.safetyId),
|
|
|
|
|
initialValue: widget.model.safetyId == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(
|
|
|
|
|
name: widget.model.safetyName ?? "",
|
|
|
|
|
id: widget.model.safetyId),
|
|
|
|
|
title: "Electrical Safety",
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
@ -139,6 +183,43 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
if (widget.model?.typeOfServiceId == 66) ...[
|
|
|
|
|
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.supplier,
|
|
|
|
|
initialValue: initialSupplier,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (supplier) {
|
|
|
|
|
if (supplier != null) {
|
|
|
|
|
widget.model.supplierId = supplier.id;
|
|
|
|
|
widget.model.supplierName = supplier.name;
|
|
|
|
|
initialSupplier = supplier;
|
|
|
|
|
_suppPerson = null;
|
|
|
|
|
widget.model.suppPersonId = null;
|
|
|
|
|
widget.model.suppPerson = null;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<SuppPersons, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.supplierEngineer,
|
|
|
|
|
enabled: initialSupplier?.suppPersons?.isNotEmpty ?? false,
|
|
|
|
|
initialValue: _suppPerson,
|
|
|
|
|
staticData: initialSupplier?.suppPersons,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (suppPerson) {
|
|
|
|
|
if (suppPerson != null) {
|
|
|
|
|
_suppPerson = suppPerson;
|
|
|
|
|
widget.model.suppPersonId = suppPerson.id;
|
|
|
|
|
widget.model.suppPerson = suppPerson.name;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: context.translation.actualVisitDate,
|
|
|
|
|
@ -147,7 +228,8 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
onDatePicker: (date) {
|
|
|
|
|
if (date == null) return;
|
|
|
|
|
if (date.isBefore(DateTime.parse(widget.model.expectedDate))) {
|
|
|
|
|
"Actual visit date must be greater then expected date".showToast;
|
|
|
|
|
"Actual visit date must be greater then expected date"
|
|
|
|
|
.showToast;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -181,9 +263,12 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
8.height,
|
|
|
|
|
MultiFilesPicker(
|
|
|
|
|
label: context.translation.attachImage,
|
|
|
|
|
files: widget.model.files.map((e) => File(e.attachmentName)).toList(),
|
|
|
|
|
files:
|
|
|
|
|
widget.model.files.map((e) => File(e.attachmentName)).toList(),
|
|
|
|
|
onChange: (files) {
|
|
|
|
|
widget.model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList();
|
|
|
|
|
widget.model.files = files
|
|
|
|
|
.map((e) => PpmAttachments(attachmentName: e.path))
|
|
|
|
|
.toList();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
@ -193,7 +278,8 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
newSignature: widget.model.localNurseSignature,
|
|
|
|
|
onChange: (signature) {
|
|
|
|
|
widget.model.localNurseSignature = signature;
|
|
|
|
|
widget.model.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
widget.model.nurseSignature =
|
|
|
|
|
"${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
@ -203,7 +289,8 @@ class _PentryTBSFormState extends State<PentryTBSForm> {
|
|
|
|
|
newSignature: widget.model.localEngineerSignature,
|
|
|
|
|
onChange: (signature) {
|
|
|
|
|
widget.model.localEngineerSignature = signature;
|
|
|
|
|
widget.model.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
widget.model.engSignature =
|
|
|
|
|
"${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
|