|
|
|
|
@ -17,7 +17,6 @@ import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/request_detail_provider.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/new_multi_image_picker.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../../../models/service_request/spare_parts.dart';
|
|
|
|
|
import '../../../../../../new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
@ -104,142 +103,134 @@ class _SparePartRequestState extends State<SparePartRequest> with TickerProvider
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.sparePartRequest),
|
|
|
|
|
body: Consumer<RequestDetailProvider>(builder: (context, RequestDetailProvider requestDetailProvider, child) {
|
|
|
|
|
return SafeArea(
|
|
|
|
|
child: LoadingManager(
|
|
|
|
|
isLoading: _isLoading,
|
|
|
|
|
isFailedLoading: false,
|
|
|
|
|
stateCode: 200,
|
|
|
|
|
onRefresh: () async {},
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
context.translation.sparePartDetails.heading5(context),
|
|
|
|
|
12.height,
|
|
|
|
|
SingleItemDropDownMenu<SparePart, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.partNo,
|
|
|
|
|
staticData: _spareParts,
|
|
|
|
|
showShadow: false,
|
|
|
|
|
initialValue: requestDetailProvider.sparePartHelperModel?.sparePart,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
onSelect: (part) {
|
|
|
|
|
if (part != null) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePart = part;
|
|
|
|
|
_oracleNoController.text = part.oracleCode ?? '';
|
|
|
|
|
requestDetailProvider.updateSparePartHelperModel(_requestDetailProvider?.sparePartHelperModel);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
controller: _partQtyController,
|
|
|
|
|
labelText: context.translation.quantity,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
showWithoutDecoration: true,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
enable: requestDetailProvider.sparePartHelperModel?.sparePart?.id != null,
|
|
|
|
|
validator: (value) => value == null || value.isEmpty
|
|
|
|
|
? context.translation.requiredField
|
|
|
|
|
: Validator.isNumeric(value)
|
|
|
|
|
? null
|
|
|
|
|
: context.translation.onlyNumbers,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.quantity = num.tryParse(value ?? "");
|
|
|
|
|
},
|
|
|
|
|
onSaved: (text) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.quantity = num.tryParse(text ?? "");
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
controller: _oracleNoController,
|
|
|
|
|
labelText: context.translation.oracleNo,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
showWithoutDecoration: true,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
enable: false,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: requestDetailProvider.sparePartHelperModel?.comment,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
controller: _descriptionController,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
labelText: context.translation.description,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
showWithoutDecoration: true,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.comment = value;
|
|
|
|
|
},
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.comment = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
NewMultiFilesPicker(
|
|
|
|
|
label: context.translation.attachQuotation,
|
|
|
|
|
files: _files,
|
|
|
|
|
buttonIcon: 'quotation_icon'.toSvgAsset(),
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
onChange: (List<MultiFilesPickerModel> list) {
|
|
|
|
|
for (var element in list) {
|
|
|
|
|
print('path is ${element.file.path}');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(16),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
Card(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
context.translation.sparePartDetails.heading5(context),
|
|
|
|
|
12.height,
|
|
|
|
|
SingleItemDropDownMenu<SparePart, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.partNo,
|
|
|
|
|
staticData: _spareParts,
|
|
|
|
|
showShadow: false,loading: _isLoading,
|
|
|
|
|
initialValue: requestDetailProvider.sparePartHelperModel?.sparePart,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
onSelect: (part) {
|
|
|
|
|
if (part != null) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePart = part;
|
|
|
|
|
_oracleNoController.text = part.oracleCode ?? '';
|
|
|
|
|
requestDetailProvider.updateSparePartHelperModel(_requestDetailProvider?.sparePartHelperModel);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
controller: _partQtyController,
|
|
|
|
|
labelText: context.translation.quantity,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
showWithoutDecoration: true,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
enable: requestDetailProvider.sparePartHelperModel?.sparePart?.id != null,
|
|
|
|
|
validator: (value) => value == null || value.isEmpty
|
|
|
|
|
? context.translation.requiredField
|
|
|
|
|
: Validator.isNumeric(value)
|
|
|
|
|
? null
|
|
|
|
|
: context.translation.onlyNumbers,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.quantity = num.tryParse(value ?? "");
|
|
|
|
|
},
|
|
|
|
|
onSaved: (text) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.quantity = num.tryParse(text ?? "");
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
controller: _oracleNoController,
|
|
|
|
|
labelText: context.translation.oracleNo,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
showWithoutDecoration: true,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
enable: false,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
initialValue: requestDetailProvider.sparePartHelperModel?.comment,
|
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
controller: _descriptionController,
|
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
|
|
|
|
|
labelText: context.translation.description,
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
showWithoutDecoration: true,
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.comment = value;
|
|
|
|
|
},
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.comment = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
NewMultiFilesPicker(
|
|
|
|
|
label: context.translation.attachQuotation,
|
|
|
|
|
files: _files,
|
|
|
|
|
buttonIcon: 'quotation_icon'.toSvgAsset(),
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
onChange: (List<MultiFilesPickerModel> list) {
|
|
|
|
|
for (var element in list) {
|
|
|
|
|
print('path is ${element.file.path}');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(16),
|
|
|
|
|
),
|
|
|
|
|
).paddingAll(12).expanded,
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
label: _requestDetailProvider?.sparePartHelperModel?.id == 0 ? context.translation.addSparePartActivity : context.translation.updateSparePartActivity,
|
|
|
|
|
buttonColor: AppColor.green70,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePartAttachments?.clear();
|
|
|
|
|
for (var pickerObject in _files) {
|
|
|
|
|
String fileData = _isLocalUrl(pickerObject.file.path)
|
|
|
|
|
? ("${pickerObject.file.path.split("/").last}|${base64Encode(File(pickerObject.file.path).readAsBytesSync())}")
|
|
|
|
|
: pickerObject.file.path;
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePartAttachments?.add(SparePartAttachments(id: pickerObject.id, name: fileData));
|
|
|
|
|
}
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).paddingAll(12).expanded,
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
child: AppFilledButton(
|
|
|
|
|
label: _requestDetailProvider?.sparePartHelperModel?.id == 0 ? context.translation.addSparePartActivity : context.translation.updateSparePartActivity,
|
|
|
|
|
buttonColor: AppColor.green70,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePartAttachments?.clear();
|
|
|
|
|
for (var pickerObject in _files) {
|
|
|
|
|
String fileData =
|
|
|
|
|
_isLocalUrl(pickerObject.file.path) ? ("${pickerObject.file.path.split("/").last}|${base64Encode(File(pickerObject.file.path).readAsBytesSync())}") : pickerObject.file.path;
|
|
|
|
|
requestDetailProvider.sparePartHelperModel?.sparePartAttachments?.add(SparePartAttachments(id: pickerObject.id, name: fileData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
int status = -1;
|
|
|
|
|
if (_requestDetailProvider?.sparePartHelperModel?.id == 0) {
|
|
|
|
|
status = await requestDetailProvider.createActivitySparePart();
|
|
|
|
|
} else {
|
|
|
|
|
status = await requestDetailProvider.updateActivitySparePart();
|
|
|
|
|
}
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
await requestDetailProvider.getWorkOrderById(id: requestDetailProvider.currentWorkOrder!.data!.requestId!);
|
|
|
|
|
//this is for hide the dialoge...
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
int status = -1;
|
|
|
|
|
if (_requestDetailProvider?.sparePartHelperModel?.id == 0) {
|
|
|
|
|
status = await requestDetailProvider.createActivitySparePart();
|
|
|
|
|
} else {
|
|
|
|
|
status = await requestDetailProvider.updateActivitySparePart();
|
|
|
|
|
}
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
await requestDetailProvider.getWorkOrderById(id: requestDetailProvider.currentWorkOrder!.data!.requestId!);
|
|
|
|
|
//this is for hide the dialoge...
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
));
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|