improvements

main_production_spare_part
Sikander Saleem 7 days ago
parent da680fb210
commit 75349c4724

@ -197,7 +197,6 @@ class PlanPreventiveVisit {
}); });
} }
if (json['activitySparePartsPPM'] != null) { if (json['activitySparePartsPPM'] != null) {
log("activitySparePartsPPM: ${json['activitySparePartsPPM']}");
activities = <PMSparePartActivityModel>[]; activities = <PMSparePartActivityModel>[];
json['activitySparePartsPPM'].forEach((v) { json['activitySparePartsPPM'].forEach((v) {
activities!.add(PMSparePartActivityModel.fromJson(v)); activities!.add(PMSparePartActivityModel.fromJson(v));

@ -1,4 +1,3 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'dart:io'; import 'dart:io';
@ -27,6 +26,7 @@ import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/loading_list_notifier.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart'; import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart'; import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
@ -80,8 +80,7 @@ class _SparePartRequestState extends State<SparePartRequest> {
activityStatus: statusLookup, activityStatus: statusLookup,
comment: '', comment: '',
); );
} else if (widget.provider.sparePartHelperModel == null || } else if (widget.provider.sparePartHelperModel == null || widget.provider.sparePartHelperModel?.id != widget.model?.id) {
widget.provider.sparePartHelperModel?.id != widget.model?.id) {
widget.provider.sparePartHelperModel = SparePartHelperModel( widget.provider.sparePartHelperModel = SparePartHelperModel(
id: widget.model?.id ?? 0, id: widget.model?.id ?? 0,
workOrderId: widget.fromCm ? widget.model?.workOrderId ?? widget.provider.currentWorkOrder?.data?.requestId : null, workOrderId: widget.fromCm ? widget.model?.workOrderId ?? widget.provider.currentWorkOrder?.data?.requestId : null,
@ -102,9 +101,7 @@ class _SparePartRequestState extends State<SparePartRequest> {
Future<void> _loadInitialData() async { Future<void> _loadInitialData() async {
setState(() => _isLoading = true); setState(() => _isLoading = true);
_spareParts = await _partsProvider!.getPartsListByDisplayName( _spareParts = await _partsProvider!.getPartsListByDisplayName(
assetId: widget.fromCm assetId: widget.fromCm ? widget.provider.currentWorkOrder?.data?.asset?.id : widget.provider.planPreventiveVisit.asset.id,
? widget.provider.currentWorkOrder?.data?.asset?.id
: widget.provider.planPreventiveVisit.asset.id,
); );
final bool isNewActivity = widget.model?.id == null || widget.model?.id == 0; final bool isNewActivity = widget.model?.id == null || widget.model?.id == 0;
_attachments = []; _attachments = [];
@ -183,9 +180,9 @@ class _SparePartRequestState extends State<SparePartRequest> {
) { ) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: 12,
children: [ children: [
context.translation.sparePartDetails.heading5(context).custom(color: AppColor.textStyleColor(context)), InfoHeader16Widget(context.translation.sparePartDetails),
12.height,
SingleItemDropDownMenu<SparePart, NullableLoadingProvider>( SingleItemDropDownMenu<SparePart, NullableLoadingProvider>(
context: context, context: context,
title: context.translation.part, title: context.translation.part,
@ -202,9 +199,8 @@ class _SparePartRequestState extends State<SparePartRequest> {
}, },
), ),
if (model?.sparePart?.id != null) ...[ if (model?.sparePart?.id != null) ...[
12.height,
SizedBox( SizedBox(
height: 30.toScreenHeight, // height: 30.toScreenHeight,
child: Text( child: Text(
'View Parts Availability', 'View Parts Availability',
style: TextStyle( style: TextStyle(
@ -227,8 +223,6 @@ class _SparePartRequestState extends State<SparePartRequest> {
}), }),
), ),
], ],
12.height,
AppTextFormField( AppTextFormField(
key: ValueKey('quantity_${model?.quantity}'), key: ValueKey('quantity_${model?.quantity}'),
initialValue: model?.quantity?.round().toString() ?? '', initialValue: model?.quantity?.round().toString() ?? '',
@ -248,9 +242,6 @@ class _SparePartRequestState extends State<SparePartRequest> {
model?.quantity = num.tryParse(text ?? ''); model?.quantity = num.tryParse(text ?? '');
}, },
), ),
12.height,
if (showInstallAndReturnQty) ...[ if (showInstallAndReturnQty) ...[
AppTextFormField( AppTextFormField(
key: ValueKey('installQty_${model?.installQty}'), key: ValueKey('installQty_${model?.installQty}'),
@ -271,7 +262,6 @@ class _SparePartRequestState extends State<SparePartRequest> {
model?.installQty = num.tryParse(text ?? ''); model?.installQty = num.tryParse(text ?? '');
}, },
), ),
12.height,
AppTextFormField( AppTextFormField(
key: ValueKey('returnQty_${model?.returnQty}'), key: ValueKey('returnQty_${model?.returnQty}'),
initialValue: model?.returnQty?.round().toString() ?? '', initialValue: model?.returnQty?.round().toString() ?? '',
@ -291,7 +281,6 @@ class _SparePartRequestState extends State<SparePartRequest> {
model?.returnQty = num.tryParse(text ?? ''); model?.returnQty = num.tryParse(text ?? '');
}, },
), ),
12.height,
], ],
AppTextFormField( AppTextFormField(
key: ValueKey('oracle_${model?.sparePart?.oracleCode}'), key: ValueKey('oracle_${model?.sparePart?.oracleCode}'),
@ -302,8 +291,6 @@ class _SparePartRequestState extends State<SparePartRequest> {
backgroundColor: AppColor.disableFieldBackground(context), backgroundColor: AppColor.disableFieldBackground(context),
enable: false, enable: false,
), ),
12.height,
AppTextFormField( AppTextFormField(
key: ValueKey('comment_${model?.comment}'), key: ValueKey('comment_${model?.comment}'),
initialValue: model?.comment ?? '', initialValue: model?.comment ?? '',
@ -319,8 +306,6 @@ class _SparePartRequestState extends State<SparePartRequest> {
model?.comment = value; model?.comment = value;
}, },
), ),
12.height,
AttachmentPicker( AttachmentPicker(
label: context.translation.attachQuotation, label: context.translation.attachQuotation,
attachment: _attachments, attachment: _attachments,
@ -384,8 +369,7 @@ class _SparePartRequestState extends State<SparePartRequest> {
provider.getWorkOrderById( provider.getWorkOrderById(
id: provider.currentWorkOrder!.data!.requestId!, id: provider.currentWorkOrder!.data!.requestId!,
); );
} } else {
else{
provider.getPlanPreventiveVisitById( provider.getPlanPreventiveVisitById(
int.tryParse(provider.planPreventiveVisit?.id ?? ''), int.tryParse(provider.planPreventiveVisit?.id ?? ''),
); );
@ -394,10 +378,7 @@ class _SparePartRequestState extends State<SparePartRequest> {
if (mounted) Navigator.pop(context); // Close form if (mounted) Navigator.pop(context); // Close form
if (model?.id == 0) { if (model?.id == 0) {
ServiceRequestBottomSheet.addAnotherSpareRequestBottomSheet( ServiceRequestBottomSheet.addAnotherSpareRequestBottomSheet(context: context, fromCm: widget.fromCm);
context: context,
fromCm: widget.fromCm
);
const SizedBox().flushBar( const SizedBox().flushBar(
context: context, context: context,
title: context.translation.sparePartActivitySuccess, title: context.translation.sparePartActivitySuccess,
@ -426,8 +407,8 @@ class PartDetailBottomSheetSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
8.height, 12.height,
'Parts Availability'.heading6(context).paddingOnly(top: 12, start: 12), 'Parts Availability'.heading4(context),
Expanded( Expanded(
child: ListenableBuilder( child: ListenableBuilder(
listenable: provider, listenable: provider,
@ -444,10 +425,7 @@ class PartDetailBottomSheetSheet extends StatelessWidget {
separatorBuilder: (czt, index) => 12.height, separatorBuilder: (czt, index) => 12.height,
itemBuilder: (context, index) { itemBuilder: (context, index) {
StoreAvailability model = provider.storeAvailability[index]; StoreAvailability model = provider.storeAvailability[index];
return _partAvailableQuantityCard( return _partAvailableQuantityCard(context: context, model: model);
context: context,
model: model,
);
}, },
); );
}, },
@ -458,31 +436,24 @@ class PartDetailBottomSheetSheet extends StatelessWidget {
); );
} }
Widget _partAvailableQuantityCard({ Widget _partAvailableQuantityCard({required StoreAvailability model, required BuildContext context}) {
required StoreAvailability model,
required BuildContext context,
}) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
InfoTextWidget( InfoTextWidget(
label: "Site Name:".addTranslation, label: "Site Name".addTranslation,
value: model.siteName ?? '', value: model.siteName ?? '',
), ),
InfoTextWidget( InfoTextWidget(
label: "Store Name:".addTranslation, label: "Store Name".addTranslation,
value: model.storeName ?? '', value: model.storeName ?? '',
), ),
InfoTextWidget( InfoTextWidget(
label: "Available Quantity:".addTranslation, label: "Available Quantity".addTranslation,
value: model.availablityQty?.toString() ?? '', value: model.availablityQty?.toString() ?? '',
), ),
], ],
).toShadowContainer( ).toShadowContainer(context);
context,
padding: 12,
showShadow: false,
);
} }
} }

@ -45,7 +45,6 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
TabController? _tabController; TabController? _tabController;
late PpmProvider ppmProvider; late PpmProvider ppmProvider;
_onSubmit({required int status}) async { _onSubmit({required int status}) async {
if (ppmProvider.validate()) { if (ppmProvider.validate()) {
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
@ -105,9 +104,6 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
}); });
} }
void initTabs(typeOfService) { void initTabs(typeOfService) {
if (typeOfService == null) { if (typeOfService == null) {
return; return;
@ -286,15 +282,13 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
] ]
], ],
), ),
12.height, 12.height,
AppFilledButton( AppFilledButton(
onPressed: () async { onPressed: () async {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const PmActivitiesListView())); Navigator.of(context).push(MaterialPageRoute(builder: (_) => const PmActivitiesListView()));
// getVisitData();
}, },
buttonColor: AppColor.neutral50, buttonColor: AppColor.neutral50,
label: context.translation.activities, label: "View Spare Parts",
), ),
], ],
), ),

@ -106,6 +106,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
IgnorePointer( IgnorePointer(
ignoring: ppmProvider.isReadOnly, ignoring: ppmProvider.isReadOnly,
child: Column( child: Column(
spacing: 12,
children: [ children: [
Column( Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -147,7 +148,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
// '${context.translation.executionTimeFrame}: ${widget.planPreventiveVisit.executionTimeFrame ?? ""} days'.bodyText2(context).custom(color: AppColor.neutral120), // '${context.translation.executionTimeFrame}: ${widget.planPreventiveVisit.executionTimeFrame ?? ""} days'.bodyText2(context).custom(color: AppColor.neutral120),
], ],
).toShadowContainer(context), ).toShadowContainer(context),
12.height,
Column( Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -221,9 +221,10 @@ class _WoInfoFormState extends State<WoInfoForm> {
// } // }
// }, // },
// ), // ),
8.height, // 8.height,//
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
spacing: 12,
children: [ children: [
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>( SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
context: context, context: context,
@ -238,7 +239,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
} }
}, },
), ),
8.height,
ADatePicker( ADatePicker(
label: context.translation.actualVisit, label: context.translation.actualVisit,
hideShadow: true, hideShadow: true,
@ -285,8 +285,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
// } // }
// }, // },
// ), // ),
8.height,
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>( SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
context: context, context: context,
backgroundColor: AppColor.fieldBgColor(context), backgroundColor: AppColor.fieldBgColor(context),
@ -299,7 +297,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
} }
}, },
), ),
8.height,
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>( SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
context: context, context: context,
backgroundColor: AppColor.fieldBgColor(context), backgroundColor: AppColor.fieldBgColor(context),
@ -314,7 +311,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
} }
}, },
), ),
8.height,
SingleItemDropDownMenu<Lookup, PpmServiceProvider>( SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
context: context, context: context,
backgroundColor: AppColor.fieldBgColor(context), backgroundColor: AppColor.fieldBgColor(context),
@ -335,9 +331,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
} }
}, },
), ),
8.height,
_timerWidget(context, totalWorkingHours), _timerWidget(context, totalWorkingHours),
8.height,
AppTextFormField( AppTextFormField(
labelText: context.translation.comment, labelText: context.translation.comment,
backgroundColor: AppColor.fieldBgColor(context), backgroundColor: AppColor.fieldBgColor(context),
@ -349,7 +343,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
widget.planPreventiveVisit.comments = value; widget.planPreventiveVisit.comments = value;
}, },
), ),
16.height,
AttachmentPicker( AttachmentPicker(
label: context.translation.attachments, label: context.translation.attachments,
attachment: ppmProvider.ppmPlanAttachments, attachment: ppmProvider.ppmPlanAttachments,
@ -359,7 +352,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
), ),
], ],
).toShadowContainer(context), ).toShadowContainer(context),
16.height,
costCard(context, ppmProvider), costCard(context, ppmProvider),
], ],
), ),
@ -417,6 +409,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
Widget _timerWidget(BuildContext context, double totalWorkingHours) { Widget _timerWidget(BuildContext context, double totalWorkingHours) {
return Column( return Column(
spacing: 12,
children: [ children: [
AppTimer( AppTimer(
label: context.translation.workingHours, label: context.translation.workingHours,
@ -438,7 +431,6 @@ class _WoInfoFormState extends State<WoInfoForm> {
return true; return true;
}, },
), ),
11.height,
if (totalWorkingHours > 0.0) ...[ if (totalWorkingHours > 0.0) ...[
WorkingTimeTile( WorkingTimeTile(
timerList: timerList, timerList: timerList,

@ -158,6 +158,7 @@ class _AppTimerState extends State<AppTimer> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
spacing: 12,
children: [ children: [
if (canPickTime) ...[ if (canPickTime) ...[
Row( Row(
@ -228,7 +229,6 @@ class _AppTimerState extends State<AppTimer> {
], ],
), ),
if (_tempPickerTimer != null) ...[ if (_tempPickerTimer != null) ...[
8.height,
Row( Row(
children: [ children: [
Column( Column(
@ -248,7 +248,7 @@ class _AppTimerState extends State<AppTimer> {
], ],
).toShadowContainer(context) ).toShadowContainer(context)
], ],
8.height, // 8.height,
], ],
if (widget.showTimer) if (widget.showTimer)
Container( Container(

Loading…
Cancel
Save