Enhancements

pull/2/head
zaid_daoud 2 years ago
parent 7d7594a3ab
commit 575005ebdd

@ -55,7 +55,7 @@ class ServiceRequestFaultDescriptionProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List listJson = json.decode(response.body)["data"]['asset']['modelDefinition']['modelDefRelatedDefects'];
_items = listJson.map((type) => FaultDescription.fromJson(type)).toList();
_items = listJson?.map((type) => FaultDescription.fromJson(type))?.toList() ?? [];
}
_loading = false;
notifyListeners();

@ -234,7 +234,7 @@ class SearchWorkOrder {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['parentWOId'] = parentWOId;
map['workOrderNo'] = workOrderNo;
map['workOrderYear'] = workOrderYear;
@ -250,7 +250,7 @@ class SearchWorkOrder {
}
map['visitDate'] = visitDate;
if (assistantEmployees != null) {
map['assistantEmployees'] = assistantEmployees.map((v) => v?.user?.id).toList();
map['assistantEmployees'] = assistantEmployees.map((v) => v?.toJson()).toList();
}
if (supplier != null) {
map['supplier'] = supplier.toJson();
@ -379,8 +379,8 @@ class WoParentDto {
map['assetType'] = assetType.toMap();
}
map['vendorTicketNumber'] = vendorTicketNumber;
map['callId'] = callId??0;
map['id'] = id??0;
map['callId'] = callId ?? 0;
map['id'] = id ?? 0;
if (stepsWorkOrderDto != null) {
map['stepsWorkOrderDto'] = stepsWorkOrderDto.toJson();
}
@ -444,7 +444,7 @@ class SuppEngineerWorkOrders {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['supplierContactId'] = supplierContactId;
map['personName'] = personName;
map['personRoleName'] = personRoleName;
@ -508,7 +508,7 @@ class StepsWorkOrderDto {
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['sequence'] = sequence;
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['statusValue'] = statusValue;
map['typeTransaction'] = typeTransaction;
@ -543,7 +543,7 @@ class SupplierModel {
});
SupplierModel.fromJson(dynamic json) {
id = json['id']??0;
id = json['id'] ?? 0;
suppliername = json['suppliername'];
name = json['name'];
website = json['website'];
@ -634,7 +634,7 @@ class SupplierModel {
List<SuppTCodes> suppTCodes,
}) =>
SupplierModel(
id: id ?? this.id??0,
id: id ?? this.id ?? 0,
suppliername: suppliername ?? this.suppliername,
name: name ?? this.name,
website: website ?? this.website,
@ -656,7 +656,7 @@ class SupplierModel {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['suppliername'] = suppliername;
map['name'] = name;
map['website'] = website;
@ -716,14 +716,14 @@ class SuppTCodes {
String codeValue,
}) =>
SuppTCodes(
id: id ?? this.id??0,
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??0;
map['id'] = id ?? 0;
map['supplierId'] = supplierId;
map['codeTypeId'] = codeTypeId;
map['codeValue'] = codeValue;
@ -778,7 +778,7 @@ class SuppPersons {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['supplierId'] = supplierId;
map['personName'] = personName;
map['personRoleId'] = personRoleId;
@ -821,7 +821,7 @@ class Attachments {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['supplierId'] = supplierId;
map['attachmentName'] = attachmentName;
map['attachmentURL'] = attachmentURL;
@ -856,7 +856,7 @@ class Addresses {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['supplierId'] = supplierId;
map['address'] = address;
return map;
@ -890,7 +890,7 @@ class Faxes {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['supplierId'] = supplierId;
map['fax'] = fax;
return map;
@ -924,7 +924,7 @@ class Telephones {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['supplierId'] = supplierId;
map['telephone'] = telephone;
return map;
@ -953,7 +953,7 @@ class AttachmentsWorkOrder {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
return map;
}
@ -996,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();
}
@ -1034,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;
@ -1093,7 +1093,7 @@ class ContactPersonWorkOrders {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['employeeCode'] = employeeCode;
map['name'] = name;
map['telephone'] = telephone;
@ -1127,7 +1127,7 @@ class AssistantEmployees {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
if (user != null) {
map['user'] = user.toJson();
}
@ -1157,7 +1157,7 @@ class UserModel {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
return map;
}
@ -1185,7 +1185,7 @@ class AssignedEmployee {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
return map;
}
@ -1263,7 +1263,7 @@ class CallRequest {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['callNo'] = callNo;
map['callComments'] = callComments;
if (asset != null) {
@ -1319,7 +1319,7 @@ class FirstAction {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -1353,7 +1353,7 @@ class DefectType {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -1387,7 +1387,7 @@ class Status {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -1446,7 +1446,7 @@ class CallSiteContactPerson {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['employeeCode'] = employeeCode;
map['name'] = name;
map['telephone'] = telephone;
@ -1516,7 +1516,7 @@ class Asset {
systemID = json['systemID'];
assetNumber = json['assetNumber'];
modelDefinition = json['modelDefinition'] != null ? ModelDefinition.fromJson(json['modelDefinition']) : null;
supplier = json['supplier'] != null ? SupplierModel.fromJson(json['supplier']) : null;
supplier = json['supplier'] != null ? Supplier.fromJson(json['supplier']) : null;
ipAddress = json['ipAddress'];
macAddress = json['macAddress'];
portNumber = json['portNumber'];
@ -1570,7 +1570,7 @@ class Asset {
String systemID;
String assetNumber;
ModelDefinition modelDefinition;
SupplierModel supplier;
Supplier supplier;
String ipAddress;
String macAddress;
String portNumber;
@ -1715,7 +1715,7 @@ class Asset {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['assetSerialNo'] = assetSerialNo;
map['systemID'] = systemID;
map['assetNumber'] = assetNumber;
@ -1831,7 +1831,7 @@ class TechnicalGuidanceBooks {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
if (guidanceBook != null) {
map['guidanceBook'] = guidanceBook.toJson();
}
@ -1866,7 +1866,7 @@ class GuidanceBook {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -1900,7 +1900,7 @@ class RemainderWarrantyMonths {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -1934,7 +1934,7 @@ class ExtendedWarrantyMonths {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -1968,7 +1968,7 @@ class SiteWarrantyMonths {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2002,7 +2002,7 @@ class CommissioningStatus {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2046,7 +2046,7 @@ class OriginSite {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['customerCode'] = customerCode;
map['custName'] = custName;
if (buildings != null) {
@ -2093,7 +2093,7 @@ class Buildings {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
if (floors != null) {
@ -2140,7 +2140,7 @@ class Floors {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
if (departments != null) {
@ -2172,7 +2172,7 @@ class Departments {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
return map;
}
@ -2203,7 +2203,7 @@ class OriginDepartment {
String ntCode,
}) =>
OriginDepartment(
id: id ?? this.id??0,
id: id ?? this.id ?? 0,
departmentName: departmentName ?? this.departmentName,
departmentCode: departmentCode ?? this.departmentCode,
ntCode: ntCode ?? this.ntCode,
@ -2245,7 +2245,7 @@ class Currency {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2284,7 +2284,7 @@ class Department {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['departmentName'] = departmentName;
map['departmentCode'] = departmentCode;
map['ntCode'] = ntCode;
@ -2319,7 +2319,7 @@ class Floor {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2353,7 +2353,7 @@ class Building {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2397,7 +2397,7 @@ class Site {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['customerCode'] = customerCode;
map['custName'] = custName;
if (buildings != null) {
@ -2444,7 +2444,7 @@ class ParentAsset {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['assetSerialNo'] = assetSerialNo;
map['assetNumber'] = assetNumber;
map['tagCode'] = tagCode;
@ -2480,7 +2480,7 @@ class IsParent {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2516,7 +2516,7 @@ class OldAsset {
String systemId,
}) =>
OldAsset(
id: id ?? this.id??0,
id: id ?? this.id ?? 0,
assetSerialNo: assetSerialNo ?? this.assetSerialNo,
assetNumber: assetNumber ?? this.assetNumber,
tagCode: tagCode ?? this.tagCode,
@ -2560,7 +2560,7 @@ class AssetReplace {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['name'] = name;
map['value'] = value;
return map;
@ -2589,7 +2589,7 @@ class Supplier {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['suppliername'] = suppliername;
return map;
}
@ -2682,7 +2682,7 @@ class ModelDefinition {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['assetName'] = assetName;
map['modelDefCode'] = modelDefCode;
map['modelName'] = modelName;
@ -2725,7 +2725,7 @@ class Suppliers {
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id??0;
map['id'] = id ?? 0;
map['suppliername'] = suppliername;
return map;
}
@ -2756,7 +2756,7 @@ class ModelDefRelatedDefects {
String estimatedTime,
}) =>
ModelDefRelatedDefects(
id: id ?? this.id??0,
id: id ?? this.id ?? 0,
defectName: defectName ?? this.defectName,
workPerformed: workPerformed ?? this.workPerformed,
estimatedTime: estimatedTime ?? this.estimatedTime,

@ -47,7 +47,7 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
@override
void initState() {
_subWorkOrders =SearchWorkOrder(assignedEmployee: widget.workOrder.assignedEmployee, callRequest: CallRequest());
_subWorkOrders = SearchWorkOrder(assignedEmployee: widget.workOrder.assignedEmployee, callRequest: CallRequest());
_serviceReport = ServiceReport(id: widget.workOrder.id, type: widget.workOrder.assetType, equipmentStatus: widget.workOrder.equipmentStatus);
super.initState();
}
@ -182,7 +182,7 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
height: 4,
),
ServiceReportFaultDescription(
requestId: widget.workOrder.callRequest.id.toString(),
requestId: widget.workOrder?.id?.toString(),
initialValue: _subWorkOrders.faultDescription,
onSelect: (status) {
_subWorkOrders.faultDescription = status;
@ -195,15 +195,11 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle("Solution"),
const ASubTitle("Solution"),
const SizedBox(
height: 4,
),
ATextFormField(
labelText: _subWorkOrders.faultDescription?.workPerformed??"",
textInputType: TextInputType.multiline,
enable:false
),
ATextFormField(labelText: _subWorkOrders.faultDescription?.workPerformed ?? "", textInputType: TextInputType.multiline, enable: false),
],
),
const SizedBox(height: 8),
@ -283,25 +279,20 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
child: AButton(
text: subtitle.create,
onPressed: () async {
_subWorkOrders.parentWOId=widget.workOrder.id;
_subWorkOrders.parentWOId = widget.workOrder.id;
_validate = true;
setState(() {});
if(validate()){
if(_subWorkOrders.startofWorkTime == null)
{
Fluttertoast.showToast(msg: subtitle.startDate + " required");
setState(() {});
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.endofWorkTime == null)
{
Fluttertoast.showToast(msg: subtitle.endDate + " required");
} else if (_subWorkOrders.calllastSituation == null) {
Fluttertoast.showToast(msg: "${subtitle.callLastSituation} required");
return;
} else
if(_subWorkOrders.calllastSituation == null)
{
Fluttertoast.showToast(msg: subtitle.callLastSituation + " required");
return;
}
}
_validate = false;
_isLoading = true;
setState(() {});
@ -311,7 +302,7 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
final status = await serviceRequestsProvider.createSubWorkOrder(workOrder: _subWorkOrders);
_isLoading = false;
setState(() {});
if (status>= 200 && status< 300) {
if (status >= 200 && status < 300) {
Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully);
Navigator.of(context).pop();
Navigator.of(context).pop();
@ -328,8 +319,8 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
);
}
bool validate(){
if(_subWorkOrders.faultDescription == null || _subWorkOrders.reason == null || _subWorkOrders.equipmentStatus == null|| _subWorkOrders.visitDate == null) {
bool validate() {
if (_subWorkOrders.faultDescription == null || _subWorkOrders.reason == null || _subWorkOrders.equipmentStatus == null || _subWorkOrders.visitDate == null) {
return false;
} else {
return true;

@ -85,7 +85,7 @@ class _WorkOrderDetailsBottomSheetState extends State<WorkOrderDetailsBottomShee
ADateTimePicker(
date: DateTime.tryParse(_workOrder.startofWorkTime ?? ""),
from: DateTime.now().subtract(const Duration(days: 365)),
to: DateTime.now().add(const Duration(days: 365)),
to: DateTime.now(),
onDateTimePicker: (date) {
_workOrder.startofWorkTime = date?.toIso8601String();
setState(() {});
@ -106,7 +106,7 @@ class _WorkOrderDetailsBottomSheetState extends State<WorkOrderDetailsBottomShee
ADateTimePicker(
date: DateTime.tryParse(_workOrder.endofWorkTime ?? ""),
from: DateTime.now().subtract(const Duration(days: 365)),
to: DateTime.now().add(const Duration(days: 365)),
to: DateTime.now(),
onDateTimePicker: (date) {
_workOrder.endofWorkTime = date?.toIso8601String();
setState(() {});
@ -121,9 +121,8 @@ class _WorkOrderDetailsBottomSheetState extends State<WorkOrderDetailsBottomShee
ASubTitle(subtitle.workingHours),
const SizedBox(height: 4),
ATextFormField(
initialValue: null,
textAlign: TextAlign.center,
hintText: _workOrder.startofWorkTime == null
labelText: _workOrder.startofWorkTime == null
? "0"
: ((DateTime.tryParse(_workOrder.endofWorkTime ?? "")?.difference(DateTime.tryParse(_workOrder.startofWorkTime ?? ""))?.inMinutes ?? 0) / 60)
?.toStringAsFixed(2)
@ -134,7 +133,11 @@ class _WorkOrderDetailsBottomSheetState extends State<WorkOrderDetailsBottomShee
// validator: (value) => Validator.isNumeric(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value) {
_workOrder.workingHours = double.tryParse(value);
_workOrder.workingHours = double.tryParse(
((DateTime.tryParse(_workOrder.endofWorkTime ?? "")?.difference(DateTime.tryParse(_workOrder.startofWorkTime ?? ""))?.inMinutes ?? 0) / 60)
?.toStringAsFixed(2)
?.toString() ??
"0");
},
),
const SizedBox(height: 8),

Loading…
Cancel
Save