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