From 1fa14c1a86cdd2289b43202c67e4666db3eef8c0 Mon Sep 17 00:00:00 2001 From: nextwo <1234> Date: Tue, 20 Jun 2023 09:43:53 +0300 Subject: [PATCH] work order --- .../service_request/search_work_order.dart | 84 ++----------------- .../create_sub_workorder_page.dart | 10 +-- 2 files changed, 11 insertions(+), 83 deletions(-) diff --git a/lib/models/service_request/search_work_order.dart b/lib/models/service_request/search_work_order.dart index 78a43616..2cdd3edd 100644 --- a/lib/models/service_request/search_work_order.dart +++ b/lib/models/service_request/search_work_order.dart @@ -1,5 +1,7 @@ import 'package:test_sa/models/lookup.dart'; +import '../fault_description.dart'; + class SearchWorkOrder { SearchWorkOrder({ this.id, @@ -63,7 +65,7 @@ class SearchWorkOrder { calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : null; currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null; repairLocation = json['repairLocation'] != null ? Lookup.fromJson(json['repairLocation']) : null; - reason = json['reason'] != null ? Reason.fromJson(json['reason']) : null; + reason = json['reason'] != null ? Lookup.fromJson(json['reason']) : null; startofWorkTime = json['startofWorkTime']; endofWorkTime = json['endofWorkTime']; workingHours = json['workingHours']; @@ -111,7 +113,7 @@ class SearchWorkOrder { Lookup calllastSituation; Lookup currentSituation; Lookup repairLocation; - Reason reason; + Lookup reason; String startofWorkTime; String endofWorkTime; num workingHours; @@ -144,7 +146,7 @@ class SearchWorkOrder { Lookup calllastSituation, Lookup currentSituation, Lookup repairLocation, - Reason reason, + Lookup reason, String startofWorkTime, String endofWorkTime, num workingHours, @@ -232,7 +234,7 @@ class SearchWorkOrder { map['repairLocation'] = repairLocation.toMap(); } if (reason != null) { - map['reason'] = reason.toJson(); + map['reason'] = reason.toMap(); } map['startofWorkTime'] = startofWorkTime; map['endofWorkTime'] = endofWorkTime; @@ -1004,80 +1006,6 @@ class SparePart { } } -class FaultDescription { - FaultDescription({ - this.id, - this.defectName, - this.workPerformed, - this.estimatedTime, - }); - - FaultDescription.fromJson(dynamic json) { - id = json['id']; - defectName = json['defectName']; - workPerformed = json['workPerformed']; - estimatedTime = json['estimatedTime']; - } - num id; - String defectName; - String workPerformed; - String estimatedTime; - FaultDescription copyWith({ - num id, - String defectName, - String workPerformed, - String estimatedTime, - }) => - FaultDescription( - id: id ?? this.id, - defectName: defectName ?? this.defectName, - workPerformed: workPerformed ?? this.workPerformed, - estimatedTime: estimatedTime ?? this.estimatedTime, - ); - Map toJson() { - final map = {}; - map['id'] = id; - map['defectName'] = defectName; - map['workPerformed'] = workPerformed; - map['estimatedTime'] = estimatedTime; - return map; - } -} - -class Reason { - Reason({ - this.id, - this.name, - this.value, - }); - - Reason.fromJson(dynamic json) { - id = json['id']; - name = json['name']; - value = json['value']; - } - num id; - String name; - num value; - Reason copyWith({ - num id, - String name, - num value, - }) => - Reason( - id: id ?? this.id, - name: name ?? this.name, - value: value ?? this.value, - ); - Map toJson() { - final map = {}; - map['id'] = id; - map['name'] = name; - map['value'] = value; - return map; - } -} - class ContactPersonWorkOrders { ContactPersonWorkOrders({ this.id, diff --git a/lib/views/pages/sub_workorder/create_sub_workorder_page.dart b/lib/views/pages/sub_workorder/create_sub_workorder_page.dart index 9c6eb283..9871ed31 100644 --- a/lib/views/pages/sub_workorder/create_sub_workorder_page.dart +++ b/lib/views/pages/sub_workorder/create_sub_workorder_page.dart @@ -43,7 +43,7 @@ class _CreateSubWorkOrderPageState extends State { @override Widget build(BuildContext context) { final Subtitle subtitle = AppLocalization.of(context).subtitle; - _serviceReport =ServiceReport(id: widget.workOrder.id, type: Lookup(name: widget.workOrder.assetType),equipmentStatus: Lookup(name: widget.workOrder.equipmentStatus) ); + _serviceReport =ServiceReport(id: widget.workOrder.id, type: widget.workOrder.assetType,equipmentStatus:widget.workOrder.equipmentStatus); return Scaffold( body: SafeArea( child: SingleChildScrollView( @@ -89,7 +89,7 @@ class _CreateSubWorkOrderPageState extends State { ServiceReportEquipmentStatusMenu( report: _serviceReport, onSelect: (status) { - _searchWorkOrders.equipmentStatus=status.name; + _searchWorkOrders.equipmentStatus=status; _serviceReport.equipmentStatus=status; }, ), @@ -129,7 +129,7 @@ class _CreateSubWorkOrderPageState extends State { initialValue: _serviceReportReason, onSelect: (status) { _serviceReportReason=status; - _searchWorkOrders.reason = status.name; + _searchWorkOrders.reason = status; }, ), ], @@ -146,7 +146,7 @@ class _CreateSubWorkOrderPageState extends State { requestId: widget.workOrder.id.toString(), initialValue: FaultDescription(id: _searchWorkOrders?.faultDescription?.id, defectName: _searchWorkOrders?.faultDescription?.defectName, workPerformed: _searchWorkOrders?.faultDescription?.workPerformed, estimatedTime: _searchWorkOrders?.faultDescription?.estimatedTime), onSelect: (status) { - _searchWorkOrders.faultDescription = ModelDefRelatedDefects(id: status?.id, defectName: status?.defectName, workPerformed: status?.workPerformed, estimatedTime: status?.estimatedTime); + _searchWorkOrders.faultDescription=status; }, ), ], @@ -243,7 +243,7 @@ class _CreateSubWorkOrderPageState extends State { child: AButton( text: subtitle.create, onPressed: () async { - _searchWorkOrders.parentWOId=widget.workOrder.id.toString(); + _searchWorkOrders.parentWOId=widget.workOrder.id; // validate = true; // if (!_formKey.currentState.validate()) { // setState(() {});