work order

pull/2/head
nextwo 3 years ago
parent ffaa340d9d
commit f97712e434

@ -1,6 +1,7 @@
import 'package:test_sa/models/fault_description.dart';
import 'package:test_sa/models/lookup.dart';
import '../fault_description.dart';
class SearchWorkOrder {
SearchWorkOrder({
this.id,
@ -233,7 +234,7 @@ class SearchWorkOrder {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['parentWOId'] = parentWOId;
map['workOrderNo'] = workOrderNo;
map['workOrderYear'] = workOrderYear;
@ -378,8 +379,8 @@ class WoParentDto {
map['assetType'] = assetType.toMap();
}
map['vendorTicketNumber'] = vendorTicketNumber;
map['callId'] = callId;
map['id'] = id;
map['callId'] = callId??0;
map['id'] = id??0;
if (stepsWorkOrderDto != null) {
map['stepsWorkOrderDto'] = stepsWorkOrderDto.toJson();
}
@ -443,7 +444,7 @@ class SuppEngineerWorkOrders {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierContactId'] = supplierContactId;
map['personName'] = personName;
map['personRoleName'] = personRoleName;
@ -507,7 +508,7 @@ class StepsWorkOrderDto {
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['sequence'] = sequence;
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['statusValue'] = statusValue;
map['typeTransaction'] = typeTransaction;
@ -542,7 +543,7 @@ class SupplierModel {
});
SupplierModel.fromJson(dynamic json) {
id = json['id'];
id = json['id']??0;
suppliername = json['suppliername'];
name = json['name'];
website = json['website'];
@ -633,7 +634,7 @@ class SupplierModel {
List<SuppTCodes> suppTCodes,
}) =>
SupplierModel(
id: id ?? this.id,
id: id ?? this.id??0,
suppliername: suppliername ?? this.suppliername,
name: name ?? this.name,
website: website ?? this.website,
@ -655,7 +656,7 @@ class SupplierModel {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['suppliername'] = suppliername;
map['name'] = name;
map['website'] = website;
@ -715,14 +716,14 @@ class SuppTCodes {
String codeValue,
}) =>
SuppTCodes(
id: id ?? this.id,
id: id ?? this.id??0,
supplierId: supplierId ?? this.supplierId,
codeTypeId: codeTypeId ?? this.codeTypeId,
codeValue: codeValue ?? this.codeValue,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierId'] = supplierId;
map['codeTypeId'] = codeTypeId;
map['codeValue'] = codeValue;
@ -777,7 +778,7 @@ class SuppPersons {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierId'] = supplierId;
map['personName'] = personName;
map['personRoleId'] = personRoleId;
@ -820,7 +821,7 @@ class Attachments {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierId'] = supplierId;
map['attachmentName'] = attachmentName;
map['attachmentURL'] = attachmentURL;
@ -855,7 +856,7 @@ class Addresses {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierId'] = supplierId;
map['address'] = address;
return map;
@ -889,7 +890,7 @@ class Faxes {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierId'] = supplierId;
map['fax'] = fax;
return map;
@ -923,7 +924,7 @@ class Telephones {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['supplierId'] = supplierId;
map['telephone'] = telephone;
return map;
@ -952,7 +953,7 @@ class AttachmentsWorkOrder {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
return map;
}
@ -995,7 +996,7 @@ class SparePartsWorkOrders {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
map['id'] = id??0;
if (sparePart != null) {
map['sparePart'] = sparePart.toJson();
}
@ -1033,7 +1034,7 @@ class SparePart {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
map['id'] = id??0;
map['partNo'] = partNo;
map['partName'] = partName;
return map;
@ -1092,7 +1093,7 @@ class ContactPersonWorkOrders {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['employeeCode'] = employeeCode;
map['name'] = name;
map['telephone'] = telephone;
@ -1126,7 +1127,7 @@ class AssistantEmployees {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
if (user != null) {
map['user'] = user.toJson();
}
@ -1156,7 +1157,7 @@ class UserModel {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
return map;
}
@ -1184,7 +1185,7 @@ class AssignedEmployee {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
return map;
}
@ -1262,7 +1263,7 @@ class CallRequest {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['callNo'] = callNo;
map['callComments'] = callComments;
if (asset != null) {
@ -1318,7 +1319,7 @@ class FirstAction {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -1352,7 +1353,7 @@ class DefectType {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -1386,7 +1387,7 @@ class Status {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -1445,7 +1446,7 @@ class CallSiteContactPerson {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['employeeCode'] = employeeCode;
map['name'] = name;
map['telephone'] = telephone;
@ -1714,7 +1715,7 @@ class Asset {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['assetSerialNo'] = assetSerialNo;
map['systemID'] = systemID;
map['assetNumber'] = assetNumber;
@ -1830,7 +1831,7 @@ class TechnicalGuidanceBooks {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
if (guidanceBook != null) {
map['guidanceBook'] = guidanceBook.toJson();
}
@ -1865,7 +1866,7 @@ class GuidanceBook {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -1899,7 +1900,7 @@ class RemainderWarrantyMonths {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -1933,7 +1934,7 @@ class ExtendedWarrantyMonths {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -1967,7 +1968,7 @@ class SiteWarrantyMonths {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2001,7 +2002,7 @@ class CommissioningStatus {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2045,7 +2046,7 @@ class OriginSite {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['customerCode'] = customerCode;
map['custName'] = custName;
if (buildings != null) {
@ -2092,7 +2093,7 @@ class Buildings {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
if (floors != null) {
@ -2139,7 +2140,7 @@ class Floors {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
if (departments != null) {
@ -2171,7 +2172,7 @@ class Departments {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
return map;
}
@ -2202,7 +2203,7 @@ class OriginDepartment {
String ntCode,
}) =>
OriginDepartment(
id: id ?? this.id,
id: id ?? this.id??0,
departmentName: departmentName ?? this.departmentName,
departmentCode: departmentCode ?? this.departmentCode,
ntCode: ntCode ?? this.ntCode,
@ -2244,7 +2245,7 @@ class Currency {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2283,7 +2284,7 @@ class Department {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['departmentName'] = departmentName;
map['departmentCode'] = departmentCode;
map['ntCode'] = ntCode;
@ -2318,7 +2319,7 @@ class Floor {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2352,7 +2353,7 @@ class Building {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2396,7 +2397,7 @@ class Site {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['customerCode'] = customerCode;
map['custName'] = custName;
if (buildings != null) {
@ -2443,7 +2444,7 @@ class ParentAsset {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['assetSerialNo'] = assetSerialNo;
map['assetNumber'] = assetNumber;
map['tagCode'] = tagCode;
@ -2479,7 +2480,7 @@ class IsParent {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2515,7 +2516,7 @@ class OldAsset {
String systemId,
}) =>
OldAsset(
id: id ?? this.id,
id: id ?? this.id??0,
assetSerialNo: assetSerialNo ?? this.assetSerialNo,
assetNumber: assetNumber ?? this.assetNumber,
tagCode: tagCode ?? this.tagCode,
@ -2559,7 +2560,7 @@ class AssetReplace {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['name'] = name;
map['value'] = value;
return map;
@ -2588,7 +2589,7 @@ class Supplier {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['suppliername'] = suppliername;
return map;
}
@ -2681,7 +2682,7 @@ class ModelDefinition {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['assetName'] = assetName;
map['modelDefCode'] = modelDefCode;
map['modelName'] = modelName;
@ -2724,7 +2725,7 @@ class Suppliers {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['id'] = id??0;
map['suppliername'] = suppliername;
return map;
}
@ -2755,7 +2756,7 @@ class ModelDefRelatedDefects {
String estimatedTime,
}) =>
ModelDefRelatedDefects(
id: id ?? this.id,
id: id ?? this.id??0,
defectName: defectName ?? this.defectName,
workPerformed: workPerformed ?? this.workPerformed,
estimatedTime: estimatedTime ?? this.estimatedTime,

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
@ -43,12 +44,13 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
ServiceReport _serviceReport;
File _image;
bool _isLoading = false;
bool _validate = false;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
final Subtitle subtitle = AppLocalization.of(context).subtitle;
@ -56,196 +58,220 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
Container(
color: AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
children: [
const ABackButton(),
Expanded(
child: Center(
child: Text(
"New Work Order",
style: Theme.of(context).textTheme.titleLarge.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
child: Form(
key: _formKey,
child: Column(
children: [
Container(
color: AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
children: [
const ABackButton(),
Expanded(
child: Center(
child: Text(
"New Work Order",
style: Theme.of(context).textTheme.titleLarge.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
),
const SizedBox(
width: 48,
)
],
),
],
const SizedBox(
width: 48,
)
],
),
],
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
child: Column(
children: [
WorkOrderDetails(
item: widget.workOrder,
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ASubTitle("Equipment status"),
const SizedBox(
height: 4,
),
ServiceReportEquipmentStatusMenu(
report: _serviceReport,
onSelect: (status) {
_subWorkOrders.equipmentStatus = status;
_serviceReport.equipmentStatus = status;
},
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ASubTitle("Return to Service"),
const SizedBox(
height: 4,
),
Row(
children: [
Expanded(
child: ADatePicker(
date: DateTime.tryParse(_subWorkOrders.visitDate ?? ""),
from: DateTime(1950),
onDatePicker: (date) {
_subWorkOrders.visitDate = date?.toIso8601String();
setState(() {});
},
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
child: Column(
children: [
WorkOrderDetails(
item: widget.workOrder,
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ASubTitle("Equipment status"),
if (_validate && _subWorkOrders?.equipmentStatus == null)
ASubTitle(
subtitle.requiredWord,
color: Colors.red,
),
],
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle("Failure ${subtitle.reasons}"),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReportReason,
onSelect: (status) {
_serviceReportReason = status;
_subWorkOrders.reason = status;
},
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(subtitle.faultDescription),
const SizedBox(
height: 4,
),
ServiceReportFaultDescription(
requestId: widget.workOrder.callRequest.id.toString(),
initialValue: _subWorkOrders.faultDescription,
onSelect: (status) {
_subWorkOrders.faultDescription = status;
},
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ASubTitle("Solution"),
const SizedBox(
height: 4,
),
ATextFormField(
labelText: "Add some text",
textInputType: TextInputType.multiline,
onSaved: (value) {},
),
],
),
const SizedBox(height: 8),
InkWell(
onTap: () async {
await showModalBottomSheet(
context: context,
useSafeArea: true,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => WorkOrderDetailsBottomSheet(subWorkOrder: _subWorkOrders),
);
log(_subWorkOrders?.toJson()?.toString());
},
child: Card(
child: ListTile(
title: Row(
const SizedBox(
height: 4,
),
ServiceReportEquipmentStatusMenu(
report: _serviceReport,
onSelect: (status) {
_subWorkOrders.equipmentStatus = status;
_serviceReport.equipmentStatus = status;
},
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ASubTitle("Return to Service"),
if (_validate && _subWorkOrders.visitDate == null)
ASubTitle(
subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
Row(
children: [
Text(
"WO Details",
style: Theme.of(context).textTheme.bodyMedium,
Expanded(
child: ADatePicker(
date: DateTime.tryParse(_subWorkOrders.visitDate ?? ""),
from: DateTime(1950),
onDatePicker: (date) {
_subWorkOrders.visitDate = date?.toIso8601String();
setState(() {});
},
),
),
const Text("*", style: TextStyle(color: Colors.red)),
],
),
trailing: const Icon(Icons.arrow_forward_ios, size: 14, color: AColors.primaryColor),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle("Failure ${subtitle.reasons}"),
if (_validate && _subWorkOrders.reason == null)
ASubTitle(
subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReportReason,
onSelect: (status) {
_serviceReportReason = status;
_subWorkOrders.reason = status;
},
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(subtitle.faultDescription),
if (_validate && _subWorkOrders.faultDescription == null)
ASubTitle(
subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
ServiceReportFaultDescription(
requestId: widget.workOrder.callRequest.id.toString(),
initialValue: _subWorkOrders.faultDescription,
onSelect: (status) {
_subWorkOrders.faultDescription = status;
setState(() {});
},
),
],
),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle("Solution"),
const SizedBox(
height: 4,
),
ATextFormField(
labelText: _subWorkOrders.faultDescription?.workPerformed??"",
textInputType: TextInputType.multiline,
enable:false
),
],
),
const SizedBox(height: 8),
InkWell(
onTap: () async {
await showModalBottomSheet(
context: context,
useSafeArea: true,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => WorkOrderDetailsBottomSheet(subWorkOrder: _subWorkOrders),
);
log(_subWorkOrders?.toJson()?.toString());
},
child: Card(
child: ListTile(
title: Row(
children: [
Text(
"WO Details",
style: Theme.of(context).textTheme.bodyMedium,
),
const Text("*", style: TextStyle(color: Colors.red)),
],
),
trailing: const Icon(Icons.arrow_forward_ios, size: 14, color: AColors.primaryColor),
),
),
),
),
const SizedBox(height: 8),
InkWell(
onTap: () async {
await showModalBottomSheet(
context: context,
useSafeArea: true,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => SparePartsBottomSheet(subWorkOrder: _subWorkOrders),
);
log(_subWorkOrders?.toJson()?.toString());
},
child: Card(
child: ListTile(
title: Row(
children: [
Text(
"Spare Parts",
style: Theme.of(context).textTheme.bodyMedium,
),
const Text("*", style: TextStyle(color: Colors.red)),
],
const SizedBox(height: 8),
InkWell(
onTap: () async {
await showModalBottomSheet(
context: context,
useSafeArea: true,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => SparePartsBottomSheet(subWorkOrder: _subWorkOrders),
);
log(_subWorkOrders?.toJson()?.toString());
},
child: Card(
child: ListTile(
title: Row(
children: [
Text(
"Spare Parts",
style: Theme.of(context).textTheme.bodyMedium,
),
const Text("*", style: TextStyle(color: Colors.red)),
],
),
trailing: const Icon(Icons.arrow_forward_ios, size: 14, color: AColors.primaryColor),
),
trailing: const Icon(Icons.arrow_forward_ios, size: 14, color: AColors.primaryColor),
),
),
),
const SizedBox(height: 8),
AMiniOneImagePicker(
image: _image,
onPick: (image) {
_image = image;
_subWorkOrders.attachmentsWorkOrder.add(AttachmentsWorkOrder(name: "${image.path.split("/").last}|${base64Encode(image.readAsBytesSync())}"));
},
),
const SizedBox(height: 50),
],
const SizedBox(height: 8),
AMiniOneImagePicker(
image: _image,
onPick: (image) {
_image = image;
_subWorkOrders.attachmentsWorkOrder.add(AttachmentsWorkOrder(name: "${image.path.split("/").last}|${base64Encode(image.readAsBytesSync())}"));
},
),
const SizedBox(height: 50),
],
),
),
),
],
],
),
),
),
),
@ -255,28 +281,56 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
child: AButton(
text: subtitle.create,
onPressed: () async {
_subWorkOrders.parentWOId = widget.workOrder.id;
_isLoading = true;
setState(() {});
if (_formKey.currentState?.validate() ?? false) {}
_formKey.currentState?.save();
final serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context, listen: false);
final status = await serviceRequestsProvider.createSubWorkOrder(workOrder: _subWorkOrders);
_isLoading = false;
_subWorkOrders.parentWOId=widget.workOrder.id;
_validate = true;
setState(() {});
if (status >= 200 && status < 300) {
Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully);
Navigator.of(context).pop();
Navigator.of(context).pop();
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: serviceRequestsProvider.stateCode, subtitle: subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
if(validate()){
if(_subWorkOrders.startofWorkTime == null)
{
Fluttertoast.showToast(msg: subtitle.startDate + " required");
return;
} else
if(_subWorkOrders.endofWorkTime == null)
{
Fluttertoast.showToast(msg: subtitle.endDate + " required");
return;
} else
if(_subWorkOrders.calllastSituation == null)
{
Fluttertoast.showToast(msg: subtitle.callLastSituation + " required");
return;
}
_validate = false;
_isLoading = true;
setState(() {});
if (_formKey.currentState?.validate() ?? false) {}
_formKey.currentState?.save();
final serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context, listen: false);
final status = await serviceRequestsProvider.createSubWorkOrder(workOrder: _subWorkOrders);
_isLoading = false;
setState(() {});
if (status>= 200 && status< 300) {
Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully);
Navigator.of(context).pop();
Navigator.of(context).pop();
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: serviceRequestsProvider.stateCode, subtitle: subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
}
},
),
),
);
}
bool validate(){
if(_subWorkOrders.faultDescription == null || _subWorkOrders.reason == null || _subWorkOrders.equipmentStatus == null|| _subWorkOrders.visitDate == null) {
return false;
} else {
return true;
}
}
}

Loading…
Cancel
Save