Merge branch 'zaid_development_new' into 'main_latest_merged'
Zaid development new See merge request haroon6138/cloudsolutions-atoms!31merge-requests/32/merge
commit
f118bb4276
@ -0,0 +1,75 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/user.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/user.dart';
|
||||||
|
|
||||||
|
class ServiceReportEquipmentStatusProvider extends ChangeNotifier {
|
||||||
|
//reset provider data
|
||||||
|
void reset() {
|
||||||
|
_status = null;
|
||||||
|
_stateCode = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// state code of current request to defied error message
|
||||||
|
// like 400 customer request failed
|
||||||
|
// 500 service not available
|
||||||
|
int _stateCode;
|
||||||
|
|
||||||
|
int get stateCode => _stateCode;
|
||||||
|
|
||||||
|
// contain user data
|
||||||
|
// when user not login or register _user = null
|
||||||
|
List<Lookup> _status;
|
||||||
|
|
||||||
|
List<Lookup> get statuses => _status;
|
||||||
|
|
||||||
|
// when categories in-process _loading = true
|
||||||
|
// done _loading = true
|
||||||
|
// failed _loading = false
|
||||||
|
bool _loading;
|
||||||
|
|
||||||
|
bool get isLoading => _loading;
|
||||||
|
|
||||||
|
set isLoading(bool isLoading) {
|
||||||
|
_loading = isLoading;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return -2 if request in progress
|
||||||
|
/// return -1 if error happen when sending request
|
||||||
|
/// return state code if request complete may be 200, 404 or 403
|
||||||
|
/// for more details check http state manager
|
||||||
|
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||||
|
Future<int> getTypes({String host, User user}) async {
|
||||||
|
if (_loading == true) return -2;
|
||||||
|
_loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
Response response;
|
||||||
|
try {
|
||||||
|
response = await ApiManager.instance.get(URLs.equipmentStatus);
|
||||||
|
|
||||||
|
_stateCode = response.statusCode;
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
// client's request was successfully received
|
||||||
|
List categoriesListJson = json.decode(response.body)["data"];
|
||||||
|
_status = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||||
|
}
|
||||||
|
_loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return response.statusCode;
|
||||||
|
} catch (error) {
|
||||||
|
_loading = false;
|
||||||
|
_stateCode = -1;
|
||||||
|
notifyListeners();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||||
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||||
|
import 'package:test_sa/models/user.dart';
|
||||||
|
|
||||||
|
import '../../../../../models/fault_description.dart';
|
||||||
|
|
||||||
|
class ServiceRequestFaultDescriptionProvider extends ChangeNotifier {
|
||||||
|
//reset provider data
|
||||||
|
void reset() {
|
||||||
|
_items = null;
|
||||||
|
_stateCode = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// state code of current request to defied error message
|
||||||
|
// like 400 customer request failed
|
||||||
|
// 500 service not available
|
||||||
|
int _stateCode;
|
||||||
|
int get stateCode => _stateCode;
|
||||||
|
|
||||||
|
// contain user data
|
||||||
|
// when user not login or register _user = null
|
||||||
|
List<FaultDescription> _items;
|
||||||
|
List<FaultDescription> get items => _items;
|
||||||
|
|
||||||
|
// when categories in-process _loading = true
|
||||||
|
// done _loading = true
|
||||||
|
// failed _loading = false
|
||||||
|
bool _loading;
|
||||||
|
bool get isLoading => _loading;
|
||||||
|
set isLoading(bool isLoading) {
|
||||||
|
_loading = isLoading;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return -2 if request in progress
|
||||||
|
/// return -1 if error happen when sending request
|
||||||
|
/// return state code if request complete may be 200, 404 or 403
|
||||||
|
/// for more details check http state manager
|
||||||
|
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||||
|
Future<int> getCallRequestForWorkOrder({String host, User user, String requestId}) async {
|
||||||
|
if (_loading == true) return -2;
|
||||||
|
_loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
Response response;
|
||||||
|
try {
|
||||||
|
response = await ApiManager.instance.get(
|
||||||
|
URLs.getCallRequestForWorkOrder + "?callId=$requestId",
|
||||||
|
);
|
||||||
|
_stateCode = response.statusCode;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
_loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return response.statusCode;
|
||||||
|
} catch (error) {
|
||||||
|
_loading = false;
|
||||||
|
_stateCode = -1;
|
||||||
|
notifyListeners();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,541 @@
|
|||||||
|
class CallRequestForWorkOrder {
|
||||||
|
int id;
|
||||||
|
String callNo;
|
||||||
|
Asset asset;
|
||||||
|
AssignedEmployee assignedEmployee;
|
||||||
|
List<CallSiteContactPerson> callSiteContactPerson;
|
||||||
|
Status status;
|
||||||
|
Status callLastSituation;
|
||||||
|
Status defectType;
|
||||||
|
Status firstAction;
|
||||||
|
int assetType;
|
||||||
|
|
||||||
|
CallRequestForWorkOrder(
|
||||||
|
{this.id, this.callNo, this.asset, this.assignedEmployee, this.callSiteContactPerson, this.status, this.callLastSituation, this.defectType, this.firstAction, this.assetType});
|
||||||
|
|
||||||
|
CallRequestForWorkOrder.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
callNo = json['callNo'];
|
||||||
|
asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null;
|
||||||
|
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : null;
|
||||||
|
if (json['callSiteContactPerson'] != null) {
|
||||||
|
callSiteContactPerson = <CallSiteContactPerson>[];
|
||||||
|
json['callSiteContactPerson'].forEach((v) {
|
||||||
|
callSiteContactPerson.add(new CallSiteContactPerson.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
status = json['status'] != null ? new Status.fromJson(json['status']) : null;
|
||||||
|
callLastSituation = json['callLastSituation'] != null ? new Status.fromJson(json['callLastSituation']) : null;
|
||||||
|
defectType = json['defectType'] != null ? new Status.fromJson(json['defectType']) : null;
|
||||||
|
firstAction = json['firstAction'] != null ? new Status.fromJson(json['firstAction']) : null;
|
||||||
|
assetType = json['assetType'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['callNo'] = this.callNo;
|
||||||
|
if (this.asset != null) {
|
||||||
|
data['asset'] = this.asset.toJson();
|
||||||
|
}
|
||||||
|
if (this.assignedEmployee != null) {
|
||||||
|
data['assignedEmployee'] = this.assignedEmployee.toJson();
|
||||||
|
}
|
||||||
|
if (this.callSiteContactPerson != null) {
|
||||||
|
data['callSiteContactPerson'] = this.callSiteContactPerson.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.status != null) {
|
||||||
|
data['status'] = this.status.toJson();
|
||||||
|
}
|
||||||
|
if (this.callLastSituation != null) {
|
||||||
|
data['callLastSituation'] = this.callLastSituation.toJson();
|
||||||
|
}
|
||||||
|
if (this.defectType != null) {
|
||||||
|
data['defectType'] = this.defectType.toJson();
|
||||||
|
}
|
||||||
|
if (this.firstAction != null) {
|
||||||
|
data['firstAction'] = this.firstAction.toJson();
|
||||||
|
}
|
||||||
|
data['assetType'] = this.assetType;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Asset {
|
||||||
|
int id;
|
||||||
|
String assetSerialNo;
|
||||||
|
String systemID;
|
||||||
|
String assetNumber;
|
||||||
|
ModelDefinition modelDefinition;
|
||||||
|
String supplier;
|
||||||
|
String ipAddress;
|
||||||
|
String macAddress;
|
||||||
|
String portNumber;
|
||||||
|
String assetReplace;
|
||||||
|
String oldAsset;
|
||||||
|
bool isParent;
|
||||||
|
String parentAsset;
|
||||||
|
int assetType;
|
||||||
|
Site site;
|
||||||
|
Building building;
|
||||||
|
String floor;
|
||||||
|
Department department;
|
||||||
|
String room;
|
||||||
|
String testsDay;
|
||||||
|
String purchasingPrice;
|
||||||
|
String nbv;
|
||||||
|
String currency;
|
||||||
|
String poNo;
|
||||||
|
String invoiceNumber;
|
||||||
|
String invoiceDate;
|
||||||
|
String replacementDate;
|
||||||
|
Department originDepartment;
|
||||||
|
Site originSite;
|
||||||
|
String budgetYear;
|
||||||
|
String lastPOPrice;
|
||||||
|
String commissioningStatus;
|
||||||
|
String productionDate;
|
||||||
|
String edd;
|
||||||
|
String technicalInspectionDate;
|
||||||
|
String deliveryInspectionDate;
|
||||||
|
String endUserAcceptanceDate;
|
||||||
|
String receivingCommittee;
|
||||||
|
String siteWarrantyMonths;
|
||||||
|
String extendedWarrantyMonths;
|
||||||
|
String remainderWarrantyMonths;
|
||||||
|
String eomWarrantyMonthsNo;
|
||||||
|
String warrantyValue;
|
||||||
|
String warrantyEndDate;
|
||||||
|
String warrantyContractConditions;
|
||||||
|
List technicalGuidanceBooks;
|
||||||
|
String comment;
|
||||||
|
String tagCode;
|
||||||
|
|
||||||
|
Asset(
|
||||||
|
{this.id,
|
||||||
|
this.assetSerialNo,
|
||||||
|
this.systemID,
|
||||||
|
this.assetNumber,
|
||||||
|
this.modelDefinition,
|
||||||
|
this.supplier,
|
||||||
|
this.ipAddress,
|
||||||
|
this.macAddress,
|
||||||
|
this.portNumber,
|
||||||
|
this.assetReplace,
|
||||||
|
this.oldAsset,
|
||||||
|
this.isParent,
|
||||||
|
this.parentAsset,
|
||||||
|
this.assetType,
|
||||||
|
this.site,
|
||||||
|
this.building,
|
||||||
|
this.floor,
|
||||||
|
this.department,
|
||||||
|
this.room,
|
||||||
|
this.testsDay,
|
||||||
|
this.purchasingPrice,
|
||||||
|
this.nbv,
|
||||||
|
this.currency,
|
||||||
|
this.poNo,
|
||||||
|
this.invoiceNumber,
|
||||||
|
this.invoiceDate,
|
||||||
|
this.replacementDate,
|
||||||
|
this.originDepartment,
|
||||||
|
this.originSite,
|
||||||
|
this.budgetYear,
|
||||||
|
this.lastPOPrice,
|
||||||
|
this.commissioningStatus,
|
||||||
|
this.productionDate,
|
||||||
|
this.edd,
|
||||||
|
this.technicalInspectionDate,
|
||||||
|
this.deliveryInspectionDate,
|
||||||
|
this.endUserAcceptanceDate,
|
||||||
|
this.receivingCommittee,
|
||||||
|
this.siteWarrantyMonths,
|
||||||
|
this.extendedWarrantyMonths,
|
||||||
|
this.remainderWarrantyMonths,
|
||||||
|
this.eomWarrantyMonthsNo,
|
||||||
|
this.warrantyValue,
|
||||||
|
this.warrantyEndDate,
|
||||||
|
this.warrantyContractConditions,
|
||||||
|
this.technicalGuidanceBooks,
|
||||||
|
this.comment,
|
||||||
|
this.tagCode});
|
||||||
|
|
||||||
|
Asset.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
assetSerialNo = json['assetSerialNo'];
|
||||||
|
systemID = json['systemID'];
|
||||||
|
assetNumber = json['assetNumber'];
|
||||||
|
modelDefinition = json['modelDefinition'] != null ? new ModelDefinition.fromJson(json['modelDefinition']) : null;
|
||||||
|
supplier = json['supplier'];
|
||||||
|
ipAddress = json['ipAddress'];
|
||||||
|
macAddress = json['macAddress'];
|
||||||
|
portNumber = json['portNumber'];
|
||||||
|
assetReplace = json['assetReplace'];
|
||||||
|
oldAsset = json['oldAsset'];
|
||||||
|
isParent = json['isParent'];
|
||||||
|
parentAsset = json['parentAsset'];
|
||||||
|
assetType = json['assetType'];
|
||||||
|
site = json['site'] != null ? new Site.fromJson(json['site']) : null;
|
||||||
|
building = json['building'];
|
||||||
|
floor = json['floor'];
|
||||||
|
department = json['department'] != null ? new Department.fromJson(json['department']) : null;
|
||||||
|
room = json['room'];
|
||||||
|
testsDay = json['testsDay'];
|
||||||
|
purchasingPrice = json['purchasingPrice'];
|
||||||
|
nbv = json['nbv'];
|
||||||
|
currency = json['currency'];
|
||||||
|
poNo = json['poNo'];
|
||||||
|
invoiceNumber = json['invoiceNumber'];
|
||||||
|
invoiceDate = json['invoiceDate'];
|
||||||
|
replacementDate = json['replacementDate'];
|
||||||
|
originDepartment = json['originDepartment'] != null ? new Department.fromJson(json['originDepartment']) : null;
|
||||||
|
originSite = json['originSite'] != null ? new Site.fromJson(json['originSite']) : null;
|
||||||
|
budgetYear = json['budgetYear'];
|
||||||
|
lastPOPrice = json['lastPOPrice'];
|
||||||
|
commissioningStatus = json['commissioningStatus'];
|
||||||
|
productionDate = json['productionDate'];
|
||||||
|
edd = json['edd'];
|
||||||
|
technicalInspectionDate = json['technicalInspectionDate'];
|
||||||
|
deliveryInspectionDate = json['deliveryInspectionDate'];
|
||||||
|
endUserAcceptanceDate = json['endUserAcceptanceDate'];
|
||||||
|
receivingCommittee = json['receivingCommittee'];
|
||||||
|
siteWarrantyMonths = json['siteWarrantyMonths'];
|
||||||
|
extendedWarrantyMonths = json['extendedWarrantyMonths'];
|
||||||
|
remainderWarrantyMonths = json['remainderWarrantyMonths'];
|
||||||
|
eomWarrantyMonthsNo = json['eomWarrantyMonthsNo'];
|
||||||
|
warrantyValue = json['warrantyValue'];
|
||||||
|
warrantyEndDate = json['warrantyEndDate'];
|
||||||
|
warrantyContractConditions = json['warrantyContractConditions'];
|
||||||
|
if (json['technicalGuidanceBooks'] != null) {
|
||||||
|
technicalGuidanceBooks = [];
|
||||||
|
json['technicalGuidanceBooks'].forEach((v) {
|
||||||
|
//technicalGuidanceBooks.add(new Null.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
comment = json['comment'];
|
||||||
|
tagCode = json['tagCode'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['assetSerialNo'] = this.assetSerialNo;
|
||||||
|
data['systemID'] = this.systemID;
|
||||||
|
data['assetNumber'] = this.assetNumber;
|
||||||
|
if (this.modelDefinition != null) {
|
||||||
|
data['modelDefinition'] = this.modelDefinition.toJson();
|
||||||
|
}
|
||||||
|
data['supplier'] = this.supplier;
|
||||||
|
data['ipAddress'] = this.ipAddress;
|
||||||
|
data['macAddress'] = this.macAddress;
|
||||||
|
data['portNumber'] = this.portNumber;
|
||||||
|
data['assetReplace'] = this.assetReplace;
|
||||||
|
data['oldAsset'] = this.oldAsset;
|
||||||
|
data['isParent'] = this.isParent;
|
||||||
|
data['parentAsset'] = this.parentAsset;
|
||||||
|
data['assetType'] = this.assetType;
|
||||||
|
if (this.site != null) {
|
||||||
|
data['site'] = this.site.toJson();
|
||||||
|
}
|
||||||
|
data['building'] = this.building;
|
||||||
|
data['floor'] = this.floor;
|
||||||
|
if (this.department != null) {
|
||||||
|
data['department'] = this.department.toJson();
|
||||||
|
}
|
||||||
|
data['room'] = this.room;
|
||||||
|
data['testsDay'] = this.testsDay;
|
||||||
|
data['purchasingPrice'] = this.purchasingPrice;
|
||||||
|
data['nbv'] = this.nbv;
|
||||||
|
data['currency'] = this.currency;
|
||||||
|
data['poNo'] = this.poNo;
|
||||||
|
data['invoiceNumber'] = this.invoiceNumber;
|
||||||
|
data['invoiceDate'] = this.invoiceDate;
|
||||||
|
data['replacementDate'] = this.replacementDate;
|
||||||
|
if (this.originDepartment != null) {
|
||||||
|
data['originDepartment'] = this.originDepartment.toJson();
|
||||||
|
}
|
||||||
|
if (this.originSite != null) {
|
||||||
|
data['originSite'] = this.originSite.toJson();
|
||||||
|
}
|
||||||
|
data['budgetYear'] = this.budgetYear;
|
||||||
|
data['lastPOPrice'] = this.lastPOPrice;
|
||||||
|
data['commissioningStatus'] = this.commissioningStatus;
|
||||||
|
data['productionDate'] = this.productionDate;
|
||||||
|
data['edd'] = this.edd;
|
||||||
|
data['technicalInspectionDate'] = this.technicalInspectionDate;
|
||||||
|
data['deliveryInspectionDate'] = this.deliveryInspectionDate;
|
||||||
|
data['endUserAcceptanceDate'] = this.endUserAcceptanceDate;
|
||||||
|
data['receivingCommittee'] = this.receivingCommittee;
|
||||||
|
data['siteWarrantyMonths'] = this.siteWarrantyMonths;
|
||||||
|
data['extendedWarrantyMonths'] = this.extendedWarrantyMonths;
|
||||||
|
data['remainderWarrantyMonths'] = this.remainderWarrantyMonths;
|
||||||
|
data['eomWarrantyMonthsNo'] = this.eomWarrantyMonthsNo;
|
||||||
|
data['warrantyValue'] = this.warrantyValue;
|
||||||
|
data['warrantyEndDate'] = this.warrantyEndDate;
|
||||||
|
data['warrantyContractConditions'] = this.warrantyContractConditions;
|
||||||
|
if (this.technicalGuidanceBooks != null) {
|
||||||
|
data['technicalGuidanceBooks'] = this.technicalGuidanceBooks.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
data['comment'] = this.comment;
|
||||||
|
data['tagCode'] = this.tagCode;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModelDefinition {
|
||||||
|
int id;
|
||||||
|
String assetName;
|
||||||
|
String modelDefCode;
|
||||||
|
String modelName;
|
||||||
|
int manufacturerId;
|
||||||
|
String manufacturerName;
|
||||||
|
String supplierName;
|
||||||
|
String replacementDate;
|
||||||
|
int lifeSpan;
|
||||||
|
List<ModelDefRelatedDefects> modelDefRelatedDefects;
|
||||||
|
List suppliers;
|
||||||
|
|
||||||
|
ModelDefinition(
|
||||||
|
{this.id,
|
||||||
|
this.assetName,
|
||||||
|
this.modelDefCode,
|
||||||
|
this.modelName,
|
||||||
|
this.manufacturerId,
|
||||||
|
this.manufacturerName,
|
||||||
|
this.supplierName,
|
||||||
|
this.replacementDate,
|
||||||
|
this.lifeSpan,
|
||||||
|
this.modelDefRelatedDefects,
|
||||||
|
this.suppliers});
|
||||||
|
|
||||||
|
ModelDefinition.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
assetName = json['assetName'];
|
||||||
|
modelDefCode = json['modelDefCode'];
|
||||||
|
modelName = json['modelName'];
|
||||||
|
manufacturerId = json['manufacturerId'];
|
||||||
|
manufacturerName = json['manufacturerName'];
|
||||||
|
supplierName = json['supplierName'];
|
||||||
|
replacementDate = json['replacementDate'];
|
||||||
|
lifeSpan = json['lifeSpan'];
|
||||||
|
if (json['modelDefRelatedDefects'] != null) {
|
||||||
|
modelDefRelatedDefects = <ModelDefRelatedDefects>[];
|
||||||
|
json['modelDefRelatedDefects'].forEach((v) {
|
||||||
|
modelDefRelatedDefects.add(new ModelDefRelatedDefects.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['suppliers'] != null) {
|
||||||
|
suppliers = [];
|
||||||
|
json['suppliers'].forEach((v) {
|
||||||
|
// suppliers!.add(new Null.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['assetName'] = this.assetName;
|
||||||
|
data['modelDefCode'] = this.modelDefCode;
|
||||||
|
data['modelName'] = this.modelName;
|
||||||
|
data['manufacturerId'] = this.manufacturerId;
|
||||||
|
data['manufacturerName'] = this.manufacturerName;
|
||||||
|
data['supplierName'] = this.supplierName;
|
||||||
|
data['replacementDate'] = this.replacementDate;
|
||||||
|
data['lifeSpan'] = this.lifeSpan;
|
||||||
|
if (this.modelDefRelatedDefects != null) {
|
||||||
|
data['modelDefRelatedDefects'] = this.modelDefRelatedDefects.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.suppliers != null) {
|
||||||
|
data['suppliers'] = this.suppliers.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModelDefRelatedDefects {
|
||||||
|
int id;
|
||||||
|
String defectName;
|
||||||
|
String workPerformed;
|
||||||
|
String estimatedTime;
|
||||||
|
|
||||||
|
ModelDefRelatedDefects({this.id, this.defectName, this.workPerformed, this.estimatedTime});
|
||||||
|
|
||||||
|
ModelDefRelatedDefects.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
defectName = json['defectName'];
|
||||||
|
workPerformed = json['workPerformed'];
|
||||||
|
estimatedTime = json['estimatedTime'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['defectName'] = this.defectName;
|
||||||
|
data['workPerformed'] = this.workPerformed;
|
||||||
|
data['estimatedTime'] = this.estimatedTime;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Site {
|
||||||
|
int id;
|
||||||
|
int customerCode;
|
||||||
|
String custName;
|
||||||
|
List buildings;
|
||||||
|
|
||||||
|
Site({this.id, this.customerCode, this.custName, this.buildings});
|
||||||
|
|
||||||
|
Site.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
customerCode = json['customerCode'];
|
||||||
|
custName = json['custName'];
|
||||||
|
if (json['buildings'] != null) {
|
||||||
|
buildings = [];
|
||||||
|
json['buildings'].forEach((v) {
|
||||||
|
// buildings!.add(new Null.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['customerCode'] = this.customerCode;
|
||||||
|
data['custName'] = this.custName;
|
||||||
|
if (this.buildings != null) {
|
||||||
|
data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Department {
|
||||||
|
int id;
|
||||||
|
String departmentName;
|
||||||
|
String departmentCode;
|
||||||
|
String ntCode;
|
||||||
|
|
||||||
|
Department({this.id, this.departmentName, this.departmentCode, this.ntCode});
|
||||||
|
|
||||||
|
Department.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
departmentName = json['departmentName'];
|
||||||
|
departmentCode = json['departmentCode'];
|
||||||
|
ntCode = json['ntCode'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['departmentName'] = this.departmentName;
|
||||||
|
data['departmentCode'] = this.departmentCode;
|
||||||
|
data['ntCode'] = this.ntCode;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AssignedEmployee {
|
||||||
|
String id;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
AssignedEmployee({this.id, this.name});
|
||||||
|
|
||||||
|
AssignedEmployee.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
name = json['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['name'] = this.name;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CallSiteContactPerson {
|
||||||
|
int id;
|
||||||
|
Null employeeCode;
|
||||||
|
String name;
|
||||||
|
String telephone;
|
||||||
|
String job;
|
||||||
|
String email;
|
||||||
|
Null land;
|
||||||
|
String contactUserId;
|
||||||
|
|
||||||
|
CallSiteContactPerson({this.id, this.employeeCode, this.name, this.telephone, this.job, this.email, this.land, this.contactUserId});
|
||||||
|
|
||||||
|
CallSiteContactPerson.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
employeeCode = json['employeeCode'];
|
||||||
|
name = json['name'];
|
||||||
|
telephone = json['telephone'];
|
||||||
|
job = json['job'];
|
||||||
|
email = json['email'];
|
||||||
|
land = json['land'];
|
||||||
|
contactUserId = json['contactUserId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['employeeCode'] = this.employeeCode;
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['telephone'] = this.telephone;
|
||||||
|
data['job'] = this.job;
|
||||||
|
data['email'] = this.email;
|
||||||
|
data['land'] = this.land;
|
||||||
|
data['contactUserId'] = this.contactUserId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Status {
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
int value;
|
||||||
|
|
||||||
|
Status({this.id, this.name, this.value});
|
||||||
|
|
||||||
|
Status.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
name = json['name'];
|
||||||
|
value = json['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['value'] = this.value;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Building {
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
int value;
|
||||||
|
var floor;
|
||||||
|
|
||||||
|
Building({this.id, this.name, this.value,this.floor});
|
||||||
|
|
||||||
|
Building.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
name = json['name'];
|
||||||
|
value = json['value'];
|
||||||
|
floor = json['floor'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['value'] = this.value;
|
||||||
|
data['floor'] = this.floor;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
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<String, dynamic> toJson() {
|
||||||
|
final map = <String, dynamic>{};
|
||||||
|
map['id'] = id;
|
||||||
|
map['defectName'] = defectName;
|
||||||
|
map['workPerformed'] = workPerformed;
|
||||||
|
map['estimatedTime'] = estimatedTime;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:test_sa/models/fault_description.dart';
|
||||||
|
import 'package:test_sa/views/app_style/colors.dart';
|
||||||
|
import 'package:test_sa/views/app_style/sizing.dart';
|
||||||
|
|
||||||
|
class FaultDescriptionMenu extends StatefulWidget {
|
||||||
|
final List<FaultDescription> statuses;
|
||||||
|
final FaultDescription initialStatus;
|
||||||
|
final Function(FaultDescription) onSelect;
|
||||||
|
|
||||||
|
const FaultDescriptionMenu({Key key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SingleStatusMenuState createState() => _SingleStatusMenuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SingleStatusMenuState extends State<FaultDescriptionMenu> {
|
||||||
|
FaultDescription _selectedStatus;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void setState(VoidCallback fn) {
|
||||||
|
if (mounted) super.setState(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant FaultDescriptionMenu oldWidget) {
|
||||||
|
if (widget.initialStatus != null) {
|
||||||
|
final result = widget.statuses?.where((element) {
|
||||||
|
return element == widget.initialStatus;
|
||||||
|
});
|
||||||
|
if (result.isNotEmpty) {
|
||||||
|
_selectedStatus = result.first;
|
||||||
|
} else {
|
||||||
|
_selectedStatus = null;
|
||||||
|
}
|
||||||
|
if ((widget.initialStatus?.id ?? "") != (_selectedStatus?.id ?? "")) {
|
||||||
|
widget.onSelect(_selectedStatus);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_selectedStatus = null;
|
||||||
|
}
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
if (widget.initialStatus != null) {
|
||||||
|
final result = widget.statuses?.where((element) {
|
||||||
|
return element == widget.initialStatus;
|
||||||
|
});
|
||||||
|
if (result.isNotEmpty) _selectedStatus = result.first;
|
||||||
|
if (widget.initialStatus.id != _selectedStatus?.id) {
|
||||||
|
widget.onSelect(_selectedStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AColors.inputFieldBackgroundColor,
|
||||||
|
border: Border.all(
|
||||||
|
color: Color(0xffefefef),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||||
|
// boxShadow: const [
|
||||||
|
// AppStyle.boxShadow
|
||||||
|
// ]
|
||||||
|
),
|
||||||
|
child: DropdownButton<FaultDescription>(
|
||||||
|
value: _selectedStatus,
|
||||||
|
iconSize: 24,
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||||
|
elevation: 0,
|
||||||
|
isExpanded: true,
|
||||||
|
hint: Text(
|
||||||
|
"Select",
|
||||||
|
style: Theme.of(context).textTheme.subtitle1,
|
||||||
|
),
|
||||||
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
|
underline: SizedBox.shrink(),
|
||||||
|
onChanged: (FaultDescription newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selectedStatus = newValue;
|
||||||
|
});
|
||||||
|
widget.onSelect(newValue);
|
||||||
|
},
|
||||||
|
items: widget.statuses.map<DropdownMenuItem<FaultDescription>>(
|
||||||
|
(FaultDescription value) {
|
||||||
|
return DropdownMenuItem<FaultDescription>(
|
||||||
|
value: value,
|
||||||
|
child: Text(
|
||||||
|
value.defectName ?? "",
|
||||||
|
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontSize: 11,
|
||||||
|
//fontWeight: FontWeight.bold
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_report_equipment_status_provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/service_report.dart';
|
||||||
|
import 'package:test_sa/models/service_request/service_request.dart';
|
||||||
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||||
|
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||||
|
|
||||||
|
class ServiceReportEquipmentStatusMenu extends StatefulWidget {
|
||||||
|
final Function(Lookup) onSelect;
|
||||||
|
final ServiceReport report;
|
||||||
|
final ServiceRequest request;
|
||||||
|
|
||||||
|
const ServiceReportEquipmentStatusMenu({Key key, this.onSelect, this.report, this.request}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ServiceReportEquipmentStatusMenu> createState() => _ServiceReportEquipmentStatusMenuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ServiceReportEquipmentStatusMenuState extends State<ServiceReportEquipmentStatusMenu> {
|
||||||
|
bool firstTime = true;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
SettingProvider settingProvider = Provider.of<SettingProvider>(context);
|
||||||
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
||||||
|
ServiceReportEquipmentStatusProvider menuProvider = Provider.of<ServiceReportEquipmentStatusProvider>(context);
|
||||||
|
ServiceReportLastCallsProvider callsLastSituationsProvider = Provider.of<ServiceReportLastCallsProvider>(context);
|
||||||
|
if (firstTime) {
|
||||||
|
callsLastSituationsProvider.reset();
|
||||||
|
|
||||||
|
firstTime = false;
|
||||||
|
}
|
||||||
|
return LoadingManager(
|
||||||
|
isLoading: menuProvider.isLoading == true || callsLastSituationsProvider.isLoading == true,
|
||||||
|
isFailedLoading: menuProvider.statuses == null || callsLastSituationsProvider.calls == null,
|
||||||
|
stateCode: menuProvider.stateCode == null || callsLastSituationsProvider.stateCode == null ? null : max(menuProvider.stateCode ?? 0, callsLastSituationsProvider.stateCode ?? 0),
|
||||||
|
onRefresh: () async {
|
||||||
|
await callsLastSituationsProvider.getCalls(
|
||||||
|
user: userProvider.user,
|
||||||
|
host: settingProvider.host,
|
||||||
|
serviceStatus: widget.report.equipmentStatus?.id,
|
||||||
|
typeName: widget.report.type?.name,
|
||||||
|
id: widget.report.id,
|
||||||
|
woId: widget.request.id,
|
||||||
|
);
|
||||||
|
if (menuProvider.stateCode == null) {
|
||||||
|
menuProvider.reset();
|
||||||
|
await menuProvider.getTypes(user: userProvider.user, host: settingProvider.host);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: SingleStatusMenu(
|
||||||
|
statuses: menuProvider.statuses,
|
||||||
|
initialStatus: widget.report.equipmentStatus,
|
||||||
|
onSelect: (status) {
|
||||||
|
widget.report.callLastSituation = null;
|
||||||
|
callsLastSituationsProvider.getCalls(
|
||||||
|
user: userProvider.user,
|
||||||
|
host: settingProvider.host,
|
||||||
|
serviceStatus: status.id,
|
||||||
|
id: widget.report.id,
|
||||||
|
woId: widget.request.id,
|
||||||
|
typeName: widget.report.type?.name,
|
||||||
|
);
|
||||||
|
|
||||||
|
widget.onSelect(status);
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_report_fault_description_provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||||
|
import 'package:test_sa/models/fault_description.dart';
|
||||||
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||||
|
import 'package:test_sa/views/widgets/status/report/fault_desc_menu.dart';
|
||||||
|
|
||||||
|
import '../../app_text_form_field.dart';
|
||||||
|
|
||||||
|
class ServiceReportFaultDescription extends StatelessWidget {
|
||||||
|
final String requestId;
|
||||||
|
final Function(FaultDescription) onSelect;
|
||||||
|
final FaultDescription initialValue;
|
||||||
|
|
||||||
|
const ServiceReportFaultDescription({Key key, this.requestId, this.onSelect, this.initialValue}) : super(key: key);
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
SettingProvider settingProvider = Provider.of<SettingProvider>(context);
|
||||||
|
UserProvider userProvider = Provider.of<UserProvider>(context);
|
||||||
|
ServiceRequestFaultDescriptionProvider menuProvider = Provider.of<ServiceRequestFaultDescriptionProvider>(context);
|
||||||
|
return LoadingManager(
|
||||||
|
isLoading: menuProvider.isLoading,
|
||||||
|
isFailedLoading: menuProvider.items == null,
|
||||||
|
stateCode: menuProvider.stateCode,
|
||||||
|
onRefresh: () async {
|
||||||
|
menuProvider.reset();
|
||||||
|
await menuProvider.getCallRequestForWorkOrder(user: userProvider.user, host: settingProvider.host, requestId: requestId);
|
||||||
|
},
|
||||||
|
child: (menuProvider.items?.isEmpty ?? true)
|
||||||
|
? const ATextFormField(
|
||||||
|
initialValue: "",
|
||||||
|
enable: false,
|
||||||
|
)
|
||||||
|
: FaultDescriptionMenu(
|
||||||
|
initialStatus: initialValue,
|
||||||
|
statuses: menuProvider.items,
|
||||||
|
onSelect: onSelect,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue