internal audit api's implementation in progress
parent
09843a9625
commit
a8e8774040
@ -0,0 +1,284 @@
|
||||
class EquipmentInternalAuditDataModel {
|
||||
int? id;
|
||||
String? requestNo;
|
||||
String? createdDate;
|
||||
int? requestNoSequence;
|
||||
Auditor? auditor;
|
||||
Status? status;
|
||||
Asset? asset;
|
||||
AssignEmployee? assignEmployee;
|
||||
dynamic manufacture;
|
||||
String? remarks;
|
||||
List<EquipmentsFinding>? equipmentsFindings;
|
||||
List<dynamic>? attachments;
|
||||
|
||||
EquipmentInternalAuditDataModel({
|
||||
this.id,
|
||||
this.requestNo,
|
||||
this.createdDate,
|
||||
this.requestNoSequence,
|
||||
this.auditor,
|
||||
this.status,
|
||||
this.asset,
|
||||
this.assignEmployee,
|
||||
this.manufacture,
|
||||
this.remarks,
|
||||
this.equipmentsFindings,
|
||||
this.attachments,
|
||||
});
|
||||
|
||||
EquipmentInternalAuditDataModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
requestNo = json['requestNo'];
|
||||
createdDate = json['createdDate'];
|
||||
requestNoSequence = json['requestNoSequence'];
|
||||
auditor = json['auditor'] != null ? Auditor.fromJson(json['auditor']) : null;
|
||||
status = json['status'] != null ? Status.fromJson(json['status']) : null;
|
||||
asset = json['asset'] != null ? Asset.fromJson(json['asset']) : null;
|
||||
assignEmployee = json['assignEmployee'] != null ? AssignEmployee.fromJson(json['assignEmployee']) : null;
|
||||
manufacture = json['manufacture'];
|
||||
remarks = json['remarks'];
|
||||
if (json['equipmentsFindings'] != null) {
|
||||
equipmentsFindings = <EquipmentsFinding>[];
|
||||
json['equipmentsFindings'].forEach((v) {
|
||||
equipmentsFindings!.add(EquipmentsFinding.fromJson(v));
|
||||
});
|
||||
}
|
||||
attachments = json['attachments'] != null ? List<dynamic>.from(json['attachments']) : [];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {};
|
||||
data['id'] = id;
|
||||
data['requestNo'] = requestNo;
|
||||
data['createdDate'] = createdDate;
|
||||
data['requestNoSequence'] = requestNoSequence;
|
||||
if (auditor != null) {
|
||||
data['auditor'] = auditor!.toJson();
|
||||
}
|
||||
if (status != null) {
|
||||
data['status'] = status!.toJson();
|
||||
}
|
||||
if (asset != null) {
|
||||
data['asset'] = asset!.toJson();
|
||||
}
|
||||
if (assignEmployee != null) {
|
||||
data['assignEmployee'] = assignEmployee!.toJson();
|
||||
}
|
||||
data['manufacture'] = manufacture;
|
||||
data['remarks'] = remarks;
|
||||
if (equipmentsFindings != null) {
|
||||
data['equipmentsFindings'] =
|
||||
equipmentsFindings!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['attachments'] = attachments;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Auditor {
|
||||
String? userId;
|
||||
String? userName;
|
||||
String? email;
|
||||
String? employeeId;
|
||||
int? languageId;
|
||||
String? extensionNo;
|
||||
String? phoneNumber;
|
||||
bool? isActive;
|
||||
|
||||
Auditor({
|
||||
this.userId,
|
||||
this.userName,
|
||||
this.email,
|
||||
this.employeeId,
|
||||
this.languageId,
|
||||
this.extensionNo,
|
||||
this.phoneNumber,
|
||||
this.isActive,
|
||||
});
|
||||
|
||||
Auditor.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['userId'];
|
||||
userName = json['userName'];
|
||||
email = json['email'];
|
||||
employeeId = json['employeeId'];
|
||||
languageId = json['languageId'];
|
||||
extensionNo = json['extensionNo'];
|
||||
phoneNumber = json['phoneNumber'];
|
||||
isActive = json['isActive'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {};
|
||||
data['userId'] = userId;
|
||||
data['userName'] = userName;
|
||||
data['email'] = email;
|
||||
data['employeeId'] = employeeId;
|
||||
data['languageId'] = languageId;
|
||||
data['extensionNo'] = extensionNo;
|
||||
data['phoneNumber'] = phoneNumber;
|
||||
data['isActive'] = isActive;
|
||||
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 = {};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['value'] = value;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Asset {
|
||||
int? id;
|
||||
String? assetNumber;
|
||||
String? assetSerialNo;
|
||||
String? assetName;
|
||||
String? modelName;
|
||||
String? manufacturerName;
|
||||
String? siteName;
|
||||
int? siteId;
|
||||
String? modelDefinition;
|
||||
|
||||
Asset({
|
||||
this.id,
|
||||
this.assetNumber,
|
||||
this.assetSerialNo,
|
||||
this.assetName,
|
||||
this.modelName,
|
||||
this.manufacturerName,
|
||||
this.siteName,
|
||||
this.siteId,
|
||||
this.modelDefinition,
|
||||
});
|
||||
|
||||
Asset.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
assetNumber = json['assetNumber'];
|
||||
assetSerialNo = json['assetSerialNo'];
|
||||
assetName = json['assetName'];
|
||||
modelName = json['modelName'];
|
||||
manufacturerName = json['manufacturerName'];
|
||||
siteName = json['siteName'];
|
||||
siteId = json['siteId'];
|
||||
modelDefinition = json['modelDefinition'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {};
|
||||
data['id'] = id;
|
||||
data['assetNumber'] = assetNumber;
|
||||
data['assetSerialNo'] = assetSerialNo;
|
||||
data['assetName'] = assetName;
|
||||
data['modelName'] = modelName;
|
||||
data['manufacturerName'] = manufacturerName;
|
||||
data['siteName'] = siteName;
|
||||
data['siteId'] = siteId;
|
||||
data['modelDefinition'] = modelDefinition;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class AssignEmployee {
|
||||
String? userId;
|
||||
String? userName;
|
||||
String? email;
|
||||
String? employeeId;
|
||||
int? languageId;
|
||||
String? extensionNo;
|
||||
String? phoneNumber;
|
||||
bool? isActive;
|
||||
|
||||
AssignEmployee({
|
||||
this.userId,
|
||||
this.userName,
|
||||
this.email,
|
||||
this.employeeId,
|
||||
this.languageId,
|
||||
this.extensionNo,
|
||||
this.phoneNumber,
|
||||
this.isActive,
|
||||
});
|
||||
|
||||
AssignEmployee.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['userId'];
|
||||
userName = json['userName'];
|
||||
email = json['email'];
|
||||
employeeId = json['employeeId'];
|
||||
languageId = json['languageId'];
|
||||
extensionNo = json['extensionNo'];
|
||||
phoneNumber = json['phoneNumber'];
|
||||
isActive = json['isActive'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {};
|
||||
data['userId'] = userId;
|
||||
data['userName'] = userName;
|
||||
data['email'] = email;
|
||||
data['employeeId'] = employeeId;
|
||||
data['languageId'] = languageId;
|
||||
data['extensionNo'] = extensionNo;
|
||||
data['phoneNumber'] = phoneNumber;
|
||||
data['isActive'] = isActive;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class EquipmentsFinding {
|
||||
int? id;
|
||||
Finding? finding;
|
||||
|
||||
EquipmentsFinding({this.id, this.finding});
|
||||
|
||||
EquipmentsFinding.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
finding = json['finding'] != null ? Finding.fromJson(json['finding']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {};
|
||||
data['id'] = id;
|
||||
if (finding != null) {
|
||||
data['finding'] = finding!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Finding {
|
||||
int? id;
|
||||
String? name;
|
||||
int? value;
|
||||
|
||||
Finding({this.id, this.name, this.value});
|
||||
|
||||
Finding.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
value = json['value'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['value'] = value;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/device/asset.dart';
|
||||
import 'package:test_sa/models/fault_description.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/models/internal_audit_attachment_model.dart';
|
||||
|
||||
class EquipmentInternalAuditFormModel {
|
||||
int? id=0;
|
||||
String? deviceArName;
|
||||
String? auditorId;
|
||||
String? woOrderNo;
|
||||
List<String>? devicePhotos;
|
||||
List<Lookup> findings =[];
|
||||
List<InternalAuditAttachments> attachments = [];
|
||||
String? remarks;
|
||||
Asset? device;
|
||||
EquipmentInternalAuditFormModel({
|
||||
this.id,
|
||||
this.deviceArName,
|
||||
this.auditorId,
|
||||
this.devicePhotos,
|
||||
this.woOrderNo,
|
||||
this.remarks,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id??0,
|
||||
'assetId': device?.id,
|
||||
'auditorId': auditorId,
|
||||
'findings': findings.map((e) => {'findingId': e.value}).toList(),
|
||||
'attachments': attachments.map((e) => e.toJson()).toList(),
|
||||
'remarks': remarks,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
class InternalAuditAttachments {
|
||||
InternalAuditAttachments({this.id,this.originalName, this.name,this.createdBy});
|
||||
|
||||
int? id;
|
||||
String? name;
|
||||
String? originalName;
|
||||
String ?createdBy;
|
||||
InternalAuditAttachments.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
originalName = json['originalName'];
|
||||
createdBy = json['createdBy'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
// data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['originalName'] = originalName;
|
||||
// data['createdBy'] = createdBy;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/device/asset.dart';
|
||||
import 'package:test_sa/models/fault_description.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class InternalAuditModel {
|
||||
String? id;
|
||||
int? deviceId;
|
||||
String? deviceArName;
|
||||
String? woOrderNo;
|
||||
List<String>? devicePhotos;
|
||||
Lookup? auditCheckList;
|
||||
String? comments;
|
||||
Asset? device;
|
||||
|
||||
InternalAuditModel({
|
||||
this.id,
|
||||
this.deviceArName,
|
||||
this.devicePhotos,
|
||||
this.deviceId,
|
||||
this.woOrderNo,
|
||||
this.comments,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class SystemInternalAuditFormModel {
|
||||
int? id = 0;
|
||||
String? auditorId;
|
||||
String? assignEmployeeId;
|
||||
Lookup? findingType;
|
||||
String? findingDescription;
|
||||
Lookup? workOrderType;
|
||||
int? correctiveMaintenanceId;
|
||||
int? planPreventiveVisitId;
|
||||
int? assetTransferId;
|
||||
int? taskJobId;
|
||||
int? taskAlertJobId;
|
||||
int? gasRefillId;
|
||||
int? planRecurrentTaskId;
|
||||
int? statusId;
|
||||
|
||||
SystemInternalAuditFormModel({
|
||||
this.id,
|
||||
this.auditorId,
|
||||
this.assignEmployeeId,
|
||||
this.findingType,
|
||||
this.findingDescription,
|
||||
this.workOrderType,
|
||||
this.correctiveMaintenanceId,
|
||||
this.planPreventiveVisitId,
|
||||
this.assetTransferId,
|
||||
this.taskJobId,
|
||||
this.taskAlertJobId,
|
||||
this.gasRefillId,
|
||||
this.planRecurrentTaskId,
|
||||
this.statusId,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'auditorId': auditorId,
|
||||
'assignEmployeeId': assignEmployeeId,
|
||||
'findingTypeId': findingType?.id,
|
||||
'findingDescription': findingDescription,
|
||||
'workOrderTypeId': workOrderType?.id,
|
||||
'correctiveMaintenanceId': correctiveMaintenanceId,
|
||||
'planPreventiveVisitId': planPreventiveVisitId,
|
||||
'assetTransferId': assetTransferId,
|
||||
'taskJobId': taskJobId,
|
||||
'taskAlertJobId': taskAlertJobId,
|
||||
'gasRefillId': gasRefillId,
|
||||
'planRecurrentTaskId': planRecurrentTaskId,
|
||||
'statusId': statusId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class WoAutoCompleteModel {
|
||||
int? id;
|
||||
String? workOrderNo;
|
||||
String? displayName;
|
||||
|
||||
WoAutoCompleteModel({this.id, this.workOrderNo, this.displayName});
|
||||
|
||||
WoAutoCompleteModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
workOrderNo = json['workOrderNo'];
|
||||
displayName = json['workOrderNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] =id;
|
||||
data['woOrderNo'] = workOrderNo;
|
||||
data['displayName'] = workOrderNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,192 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/models/equipment_internal_audit_data_model.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/pages/update_internal_audit_page.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
||||
import 'package:test_sa/views/widgets/images/files_list.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
||||
|
||||
class EquipmentInternalAuditDetailPage extends StatefulWidget {
|
||||
static const String id = "/details-internal-audit";
|
||||
|
||||
final int auditId;
|
||||
|
||||
const EquipmentInternalAuditDetailPage({Key? key, required this.auditId}) : super(key: key);
|
||||
|
||||
@override
|
||||
_EquipmentInternalAuditDetailPageState createState() {
|
||||
return _EquipmentInternalAuditDetailPageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _EquipmentInternalAuditDetailPageState extends State<EquipmentInternalAuditDetailPage> {
|
||||
bool isWoType = true;
|
||||
EquipmentInternalAuditDataModel? model;
|
||||
late InternalAuditProvider _internalAuditProvider;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_internalAuditProvider = Provider.of<InternalAuditProvider>(context, listen: false);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
getAuditData();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getAuditData() async {
|
||||
model = await _internalAuditProvider.getEquipmentInternalAuditById(widget.auditId);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO need to check when implementing provider needed or not .
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: "Request Details"),
|
||||
body: Selector<InternalAuditProvider, bool>(
|
||||
selector: (_, provider) => provider.isLoading,
|
||||
builder: (_, isLoading, __) {
|
||||
if (isLoading) return const ALoading();
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
assetDetails(),
|
||||
8.height,
|
||||
requestDetails(),
|
||||
8.height,
|
||||
//TODO need to check for comments
|
||||
// if (model.comment?.isNotEmpty ?? false) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"Comments".addTranslation,
|
||||
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
// model.comment!.bodyText(context),
|
||||
// 8.height,
|
||||
// ],
|
||||
//TODO need to check for attachments
|
||||
// if ( _model.attachment.isNotEmpty) ...[
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"Attachments".addTranslation,
|
||||
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
8.height,
|
||||
// FilesList(images: _model.attachment?.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
|
||||
// ],
|
||||
],
|
||||
).paddingAll(0).toShadowContainer(context),
|
||||
).expanded,
|
||||
if (context.userProvider.isEngineer)
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
label: "Update",
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, UpdateInternalAuditPage.id);
|
||||
}),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
Widget workOrderInformation() {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"WO Info",
|
||||
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
6.height,
|
||||
'${context.translation.woNumber}: ${'-'}'.bodyText(context),
|
||||
'${'WO Type'.addTranslation}: ${'-'}'.bodyText(context),
|
||||
'${context.translation.site}: ${'-'}'.bodyText(context),
|
||||
'${context.translation.assetName}: ${'-'}'.bodyText(context),
|
||||
'${context.translation.manufacture}: ${'-'}'.bodyText(context),
|
||||
'${context.translation.model}: ${'-'}'.bodyText(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget requestDetails() {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Divider().defaultStyle(context),
|
||||
Text(
|
||||
"Request Details",
|
||||
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
6.height,
|
||||
if (model != null && model!.equipmentsFindings != null && model!.equipmentsFindings!.isNotEmpty)
|
||||
...model!.equipmentsFindings!.map((item) {
|
||||
final findingName = item.finding?.name ?? 'Unknown';
|
||||
return checklistWidget(value: findingName.addTranslation);
|
||||
}).toList()
|
||||
else
|
||||
Text('No findings available'.addTranslation),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget assetDetails() {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Asset Details",
|
||||
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
6.height,
|
||||
'${context.translation.assetName}: ${model?.asset?.assetName ?? '-'}'.bodyText(context),
|
||||
'${context.translation.assetNo}: ${model?.asset?.assetNumber ?? '-'}'.bodyText(context),
|
||||
'${context.translation.manufacture}: ${model?.asset?.manufacturerName ?? '-'}'.bodyText(context),
|
||||
'${context.translation.model}: ${model?.asset?.modelName ?? '-'}'.bodyText(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget checklistWidget({required String value}) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: true,
|
||||
activeColor: AppColor.neutral120,
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity: const VisualDensity(horizontal: -4, vertical: -3),
|
||||
onChanged: (value) {},
|
||||
),
|
||||
value.bodyText(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/models/system_internal_audit_form_model.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/provider/internal_audit_provider.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_text_style.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class SystemAuditWoAutoCompleteField extends StatefulWidget {
|
||||
final String initialValue;
|
||||
final int? woTypeId;
|
||||
final TextEditingController controller;
|
||||
final bool clearAfterPick;
|
||||
final Function(WoAutoCompleteModel) onPick;
|
||||
|
||||
const SystemAuditWoAutoCompleteField({Key? key, required this.initialValue, this.woTypeId, required this.onPick, this.clearAfterPick = true, required this.controller}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SystemAuditWoAutoCompleteFieldState createState() => _SystemAuditWoAutoCompleteFieldState();
|
||||
}
|
||||
|
||||
class _SystemAuditWoAutoCompleteFieldState extends State<SystemAuditWoAutoCompleteField> {
|
||||
late InternalAuditProvider _provider;
|
||||
|
||||
//
|
||||
// late TextEditingController _controller;
|
||||
|
||||
bool loading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// w controller = widget.controller ?? TextEditingController(text: widget.initialValue);
|
||||
super.initState();
|
||||
_provider = Provider.of<InternalAuditProvider>(context, listen: false);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant SystemAuditWoAutoCompleteField oldWidget) {
|
||||
// if (widget.initialValue != oldWidget.initialValue) {
|
||||
// // _controller = widget.controller ?? TextEditingController(text: widget.initialValue);
|
||||
// }
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (widget.controller == null) {
|
||||
// _controller.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10));
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background(context),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||
),
|
||||
child: Autocomplete<WoAutoCompleteModel>(
|
||||
optionsBuilder: (TextEditingValue textEditingValue) async {
|
||||
if (textEditingValue.text.isEmpty) {
|
||||
if (loading) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
return const Iterable<WoAutoCompleteModel>.empty();
|
||||
}
|
||||
if (!loading) {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
}
|
||||
List<WoAutoCompleteModel> workOrders = (await _provider.getWorkOrderByWoType(text: textEditingValue.text, woId:widget.woTypeId));
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
return workOrders;
|
||||
},
|
||||
displayStringForOption: (WoAutoCompleteModel option) => option.displayName ?? '',
|
||||
fieldViewBuilder: (BuildContext context, TextEditingController fieldTextEditingController, FocusNode fieldFocusNode, VoidCallback onFieldSubmitted) {
|
||||
return TextField(
|
||||
controller: widget.controller,
|
||||
focusNode: fieldFocusNode,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.black10),
|
||||
textAlign: TextAlign.start,
|
||||
decoration: InputDecoration(
|
||||
border: border,
|
||||
disabledBorder: border,
|
||||
focusedBorder: border,
|
||||
enabledBorder: border,
|
||||
errorBorder: border,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 16.toScreenWidth),
|
||||
constraints: const BoxConstraints(),
|
||||
suffixIconConstraints: const BoxConstraints(maxHeight: 24, maxWidth: 24 + 8),
|
||||
filled: true,
|
||||
fillColor: AppColor.fieldBgColor(context),
|
||||
errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60),
|
||||
floatingLabelStyle: AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20),
|
||||
labelText: context.translation.woNumber,
|
||||
labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.textColor(context)),
|
||||
suffixIcon: loading ? const CircularProgressIndicator(color: AppColor.primary10, strokeWidth: 3.0).paddingOnly(end: 8) : null,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: (text) {
|
||||
fieldTextEditingController.text = text;
|
||||
},
|
||||
onSubmitted: (String value) {
|
||||
onFieldSubmitted();
|
||||
},
|
||||
);
|
||||
},
|
||||
onSelected: (WoAutoCompleteModel selection) {
|
||||
if (widget.clearAfterPick) {
|
||||
widget.controller.clear();
|
||||
} else {
|
||||
widget.controller.text = (selection.displayName ?? "");
|
||||
}
|
||||
widget.onPick(selection);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// String getUrl(int? woTypeId) {
|
||||
// if (woTypeId == null) return '';
|
||||
// String base = URLs.woAutoCompleteBase;
|
||||
// var urlMap = {
|
||||
// 1: '$base/ServiceRequest/WorkOrderAutoComplete', // CM
|
||||
// 2: '$base/GasRefill/GetGasRefillAutoComplete', // Gas Refill
|
||||
// 3: '$base/AssetTransfer/GetAssetTransferAutoComplete', // Asset Transfer
|
||||
// 4: '$base/PlanPreventiveVisit/GetAutoCompletePlanPreventiveVisit', // PPM Request
|
||||
// 5: '$base/PlanRecurrentTasks/GetPlanRecurrentTask', // Recurrent WO
|
||||
// 6: '$base/TaskJobs/AutocompleteTaskJob', // Task
|
||||
// 7: '$base/TaskJobs/AutocompleteTaskJob', // Recall & Alert
|
||||
// };
|
||||
// return urlMap[woTypeId] ?? '';
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/all_requests_and_count_model.dart';
|
||||
import 'package:test_sa/models/new_models/dashboard_detail.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/pages/equipment_internal_audit/equipment_internal_audit_detail_page.dart';
|
||||
import 'package:test_sa/modules/internal_audit_module/pages/system_internal_audit/system_internal_audit_detail_page.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
|
||||
class SystemInternalAuditItemView extends StatelessWidget {
|
||||
final Data? requestData;
|
||||
final RequestsDetails? requestDetails;
|
||||
final bool showShadow;
|
||||
|
||||
const SystemInternalAuditItemView({Key? key, this.requestData, this.requestDetails, this.showShadow = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO need to refactor this code repetation @waseem
|
||||
log('request details ${requestDetails?.toJson()}');
|
||||
if (requestData != null) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
StatusLabel(
|
||||
label: requestData!.statusName!,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, requestData!.statusName!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, requestData!.statusName!),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(
|
||||
requestData!.transactionDate?.toServiceRequestCardFormat ?? "",
|
||||
textAlign: TextAlign.end,
|
||||
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
||||
),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
(requestData?.typeTransaction ?? "Internal Audit Request").heading5(context),
|
||||
infoWidget(label: context.translation.assetNo, value: requestData?.assetNumber, context: context),
|
||||
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.viewDetails,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
||||
),
|
||||
4.width,
|
||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => SystemInternalAuditDetailPage(auditId: requestDetails!.id!)));
|
||||
});
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
StatusLabel(
|
||||
label: requestDetails!.status!,
|
||||
textColor: AppColor.getRequestStatusTextColorByName(context, requestDetails?.status!),
|
||||
backgroundColor: AppColor.getRequestStatusColorByName(context, requestDetails?.status!),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(
|
||||
requestDetails!.date?.toServiceRequestCardFormat ?? "",
|
||||
textAlign: TextAlign.end,
|
||||
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
||||
),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
(requestDetails?.nameOfType ?? "Internal Audit Request").heading5(context),
|
||||
infoWidget(label: context.translation.assetNumber, value: requestDetails!.assetNo, context: context),
|
||||
infoWidget(label: context.translation.assetSN, value: requestDetails!.assetSN, context: context),
|
||||
infoWidget(label: context.translation.model, value: requestDetails!.model, context: context),
|
||||
8.height,
|
||||
// infoWidget(label: context.translation.site, value: requestDetails!.site, context: context),
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.viewDetails,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
|
||||
),
|
||||
4.width,
|
||||
Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
|
||||
],
|
||||
),
|
||||
],
|
||||
).toShadowContainer(context, withShadow: showShadow).onPress(() async {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => SystemInternalAuditDetailPage(auditId: requestDetails!.id!)));
|
||||
});
|
||||
}
|
||||
|
||||
Widget infoWidget({required String label, String? value, required BuildContext context}) {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
return '$label: $value'.bodyText(context);
|
||||
}
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
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/lookup.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
class InternalAuditWoTypeProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getData({int? id}) async {
|
||||
if (loading ?? false) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.getInternalAuditWoType);
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
items = listJson.map((department) => Lookup.fromJson(department)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue