gas refill attachment and device transfer assistant employee issue fixes

design_3.0_task_module_new
WaseemAbbasi22 7 months ago
parent 5963a27213
commit 71ee34c658

@ -28,7 +28,6 @@ class GasRefillProvider extends ChangeNotifier {
building = null;
floor = null;
department = null;
gasRefillAttachments.clear();
}
// state code of current request to defied error message
@ -46,14 +45,6 @@ class GasRefillProvider extends ChangeNotifier {
// done _loading = true
// failed _loading = false
bool isLoading = false;
List<File> _gasRefillAttachments = [];
List<File> get gasRefillAttachments => _gasRefillAttachments;
set gasRefillAttachments(List<File> value) {
_gasRefillAttachments = value;
notifyListeners();
}

@ -267,7 +267,10 @@ class GasRefillModel {
employeeId = model.employeeId;
name = model.name;
techComment = model.techComment;
gasRefillAttachments = model.gasRefillAttachments;
createdDate = model.createdDate;
workingHours = model.workingHours;
gasRefillTimers=model.gasRefillTimers;
}
GasRefillModel copyWith({

@ -1,5 +1,6 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -45,6 +46,7 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
Lookup? _requestedQuantity;
final TextEditingController _commentController = TextEditingController();
GasRefillProvider? _gasRefillProvider;
List<File> _files = [];
static List<Lookup> gasQuantity = [
Lookup(name: "1", id: 1, value: 1),
@ -61,13 +63,11 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
_gasModel =GasRefillModel();
_currentDetails = GasRefillDetails();
_gasModel = GasRefillModel(gasRefillDetails: []);
_gasRefillProvider!.gasRefillAttachments.clear();
}
@override
void dispose() {
super.dispose();
_gasRefillProvider!.gasRefillAttachments.clear();
}
@override
@ -220,7 +220,7 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
8.height,
MultiFilesPicker(
label: context.translation.attachFiles,
files: _gasRefillProvider!.gasRefillAttachments,
files:_files,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
@ -243,7 +243,7 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
_gasModel.gasRefillDetails=[];
_gasModel.gasRefillDetails?.add(_currentDetails);
_gasModel.gasRefillAttachments = [];
for (var item in _gasRefillProvider!.gasRefillAttachments) {
for (var item in _files) {
_gasModel.gasRefillAttachments?.add(GasRefillAttachments(
id: 0, gasRefillId: _gasModel.id ?? 0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path));
}

@ -687,6 +687,7 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
if (employee == null) {
widget.formModel?.assistantEmployees = [];
} else {
selectedEmployee = employee;
widget.formModel?.assistantEmployees = [employee.copyWith(id: 0)];
widget.formModel?.modelAssistantEmployees?.employeeId = employee.user?.id;
}

@ -69,6 +69,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
bool _firstTime = true;
Lookup? _deliveredQuantity;
List<File> _attachments = [];
static List<Lookup> deliveredQuantity = [
Lookup(name: "1", id: 1, value: 1),
@ -86,9 +87,8 @@ class _GasRefillFormState extends State<GasRefillForm> {
if (widget.gasRefillModel != null) {
_formModel.fromGasRefillModel(widget.gasRefillModel!);
// totalWorkingHours =
// _formModel?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0;
totalWorkingHours =
_formModel.gasRefillTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDate!).difference(DateTime.parse(item.startDate!)).inSeconds) ?? 0;
_commentController.text = _formModel.techComment ?? "";
try {
_deliveredQuantity = deliveredQuantity.singleWhere((element) => element.value == _formModel.gasRefillDetails![0].deliverdQty);
@ -96,8 +96,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
} catch (ex) {}
}
if (_formModel.gasRefillAttachments != null && _formModel.gasRefillAttachments!.isNotEmpty) {
_gasRefillProvider?.gasRefillAttachments = [];
_gasRefillProvider?.gasRefillAttachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList());
_attachments.addAll(_formModel.gasRefillAttachments!.map((e) => File(e.attachmentName!)).toList());
}
}
@ -138,7 +137,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
);
});
_formModel.gasRefillAttachments = [];
for (var item in _gasRefillProvider!.gasRefillAttachments) {
for (var item in _attachments) {
_formModel.gasRefillAttachments
?.add(GasRefillAttachments(id: 0,gasRefillId: _formModel.id??0, attachmentName: ServiceRequestUtils.isLocalUrl(item.path) ? "${item.path.split("/").last}|${base64Encode(item.readAsBytesSync())}" : item.path));
}
@ -263,7 +262,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
// : context.translation.onlyNumbers,
// ),
// 8.height,
_timerWidget(context, _formModel.workingHours ?? 0),
_timerWidget(context, totalWorkingHours ?? 0),
8.height,
// SingleItemDropDownMenu<Lookup, GasStatusProvider>(
// context: context,
@ -301,7 +300,7 @@ class _GasRefillFormState extends State<GasRefillForm> {
16.height,
MultiFilesPicker(
label: context.translation.attachFiles,
files: _gasRefillProvider!.gasRefillAttachments,
files: _attachments,
buttonColor: AppColor.black10,
onlyImages: false,
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),

Loading…
Cancel
Save