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

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