|
|
|
|
@ -4,15 +4,21 @@ import 'package:test_sa/controllers/providers/api/service_requests_provider.dart
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_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/models/enums/user_types.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/search_work_order.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/service_request.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/app_style/sizing.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/create_service_report.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/requests/work_order/future_service_report.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/info_row.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
class WorkOrderListPage extends StatelessWidget {
|
|
|
|
|
@ -32,7 +38,7 @@ class WorkOrderListPage extends StatelessWidget {
|
|
|
|
|
serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
|
|
|
|
|
serviceRequest = ModalRoute.of(context).settings.arguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print("serviceRequest.statusValue:${serviceRequest.statusValue}");
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.workOrder),
|
|
|
|
|
backgroundColor: const Color(0xfff8f9fb),
|
|
|
|
|
@ -42,79 +48,46 @@ class WorkOrderListPage extends StatelessWidget {
|
|
|
|
|
builder: (context, snap) {
|
|
|
|
|
workOrders = snap.data as List<SearchWorkOrder>;
|
|
|
|
|
if (snap.connectionState == ConnectionState.waiting) return Center(child: CircularProgressIndicator());
|
|
|
|
|
if (snap.connectionState == ConnectionState.done && (snap.data?.length ?? 0) != 0) {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
padding: EdgeInsets.all(21),
|
|
|
|
|
itemCount: workOrders.length,
|
|
|
|
|
separatorBuilder: (czt, index) => 21.height,
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: workOrders?.length ?? 0,
|
|
|
|
|
separatorBuilder: (czt, index) => 8.height,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
|
|
|
|
|
|
|
|
|
return ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
|
|
|
|
primary: itemColor.withOpacity(.7),
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
),
|
|
|
|
|
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
|
|
|
|
|
),
|
|
|
|
|
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// onPressed(request);
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.callId,
|
|
|
|
|
content: serviceRequest.requestCode,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.orderWorkNumber,
|
|
|
|
|
info: workOrders[index].workOrderNo.toString(),
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.visitDate,
|
|
|
|
|
info: workOrders[index].visitDate,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(title: context.translation.assignedEmployee, info: workOrders[index].assignedEmployee?.name ?? ""),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.assetSN,
|
|
|
|
|
info: workOrders[index].callRequest.asset.assetSerialNo,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.assetName,
|
|
|
|
|
info: workOrders[index].callRequest.asset.modelDefinition.assetName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.assetNumber,
|
|
|
|
|
info: workOrders[index].callRequest.asset.assetNumber,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.model,
|
|
|
|
|
info: workOrders[index].callRequest.asset.modelDefinition.modelName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: context.translation.site,
|
|
|
|
|
info: workOrders[index].callRequest.asset.site.custName,
|
|
|
|
|
),
|
|
|
|
|
RequestInfoRow(
|
|
|
|
|
title: "Call last Situation",
|
|
|
|
|
info: workOrders[index].currentSituation.name ?? '',
|
|
|
|
|
),
|
|
|
|
|
_userProvider.user.type == UsersTypes.engineer && workOrders[index].workOrderNo != null
|
|
|
|
|
? Padding(
|
|
|
|
|
padding: EdgeInsets.all(32),
|
|
|
|
|
child: AButton(
|
|
|
|
|
text: context.translation.editServiceReport,
|
|
|
|
|
onPressed: serviceRequest.statusValue == 5 || serviceRequest.statusValue == 3
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
StatusLabel(label: workOrders[index].currentSituation.name, textColor: AppColor.orange60, backgroundColor: AppColor.orange40),
|
|
|
|
|
8.height,
|
|
|
|
|
Text(serviceRequest.requestCode, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
if (serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3)
|
|
|
|
|
"edit".toSvgAsset(height: 48, width: 48).onPress(() {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (_) => FutureServiceReport(
|
|
|
|
|
@ -122,57 +95,80 @@ class WorkOrderListPage extends StatelessWidget {
|
|
|
|
|
workOrder: workOrders[index],
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: SizedBox.shrink(),
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer)
|
|
|
|
|
Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(32),
|
|
|
|
|
child: AButton(
|
|
|
|
|
text: "Create Work Order",
|
|
|
|
|
onPressed: serviceRequest.statusValue == 5 || serviceRequest.statusValue == 3
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CreateServiceReport(request: serviceRequest)));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.assetName}: ${workOrders[index].callRequest.asset.modelDefinition.assetName}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.status}: ${workOrders[index].currentSituation.name}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
Text(workOrders[index].visitDate.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Column(
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.orderWorkNumber}: ${workOrders[index].workOrderNo}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${context.translation.assignedEmployee}: ${workOrders[index].assignedEmployee?.name ?? ""}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
Text('${context.translation.assetSN}: ${workOrders[index].callRequest.asset.assetSerialNo ?? ""}', style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575))),
|
|
|
|
|
Text('${context.translation.assetName}: ${workOrders[index].callRequest.asset.modelDefinition.assetName ?? ""}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575))),
|
|
|
|
|
Text('${context.translation.assetNumber}: ${workOrders[index].callRequest.asset.assetNumber ?? ""}', style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575))),
|
|
|
|
|
Text('${context.translation.model}: ${workOrders[index].callRequest.asset.modelDefinition.modelName ?? ""}',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575))),
|
|
|
|
|
Text('${context.translation.site}: ${workOrders[index].callRequest.asset.site.custName ?? ""}', style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575))),
|
|
|
|
|
Text('${"Call last Situation"}: ${workOrders[index].calllastSituation.name ?? '' ?? ""}', style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575))),
|
|
|
|
|
16.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Center(
|
|
|
|
|
child: ASubTitle(context.translation.dataNotFound),
|
|
|
|
|
Text(
|
|
|
|
|
'View Details',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
const Icon(
|
|
|
|
|
Icons.arrow_forward,
|
|
|
|
|
color: Color(0xFF4A8DB7),
|
|
|
|
|
size: 14,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(16).onPress(() {
|
|
|
|
|
// onPressed(request);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer)
|
|
|
|
|
Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(32),
|
|
|
|
|
child: AButton(
|
|
|
|
|
text: "Create Work Order",
|
|
|
|
|
onPressed: serviceRequest.statusValue == 5 || serviceRequest.statusValue == 3
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CreateServiceReport(request: serviceRequest)));
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (_userProvider.user.type != UsersTypes.engineer && (serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3))
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
label: context.translation.createWorkOrder,
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CreateServiceReport(request: serviceRequest)));
|
|
|
|
|
}).paddingOnly(start: 16, end: 16, bottom: 16)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
|