In Update gas refill : add expected Date field and enable the engineer to updated.

design_3.0_demo_module
zaid_daoud 3 years ago
parent 4b23db582a
commit 3e79091d7e

@ -104,7 +104,6 @@ class GasRefillProvider extends ChangeNotifier {
@required User user, @required User user,
@required GasRefillModel model, @required GasRefillModel model,
}) async { }) async {
print("ss");
Map<String, dynamic> body = { Map<String, dynamic> body = {
"uid": user.id.toString(), "uid": user.id.toString(),
"token": user.token ?? "", "token": user.token ?? "",
@ -121,7 +120,6 @@ class GasRefillProvider extends ChangeNotifier {
"GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}", "GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
"status": model.status.toMap(), "status": model.status.toMap(),
}; };
print("ss1");
body["gazRefillDetails"] = model.details body["gazRefillDetails"] = model.details
.map((model) => { .map((model) => {
"gasType": model.type.toMap(), "gasType": model.type.toMap(),
@ -134,7 +132,6 @@ class GasRefillProvider extends ChangeNotifier {
Response response; Response response;
try { try {
response = await ApiManager.instance.post(URLs.requestGasRefill, body: body); response = await ApiManager.instance.post(URLs.requestGasRefill, body: body);
print("ss2");
stateCode = response.statusCode; stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
if (items != null) { if (items != null) {
@ -159,8 +156,8 @@ class GasRefillProvider extends ChangeNotifier {
"id": newModel.id, "id": newModel.id,
"gazRefillNo": newModel.title ?? "", "gazRefillNo": newModel.title ?? "",
"status": newModel.status.toMap(), "status": newModel.status.toMap(),
"expectedDate": oldModel.expectedDate?.toIso8601String(), "expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": oldModel.expectedDate?.toIso8601String(), "expectedTime": newModel.expectedDate?.toIso8601String(),
"startDate": startDate?.toIso8601String(), "startDate": startDate?.toIso8601String(),
"startTime": startDate?.toIso8601String(), "startTime": startDate?.toIso8601String(),
"endDate": endDate?.toIso8601String(), "endDate": endDate?.toIso8601String(),

@ -153,8 +153,8 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
} }
if (_firstTime) { if (_firstTime) {
if (widget.gasRefillModel != null) { if (widget.gasRefillModel != null) {
_formModel = widget.gasRefillModel;
_formModel.status = const Lookup(value: 0); _formModel.status = const Lookup(value: 0);
_gasRefillProvider.expectedDateTime = _formModel.expectedDate;
} }
HospitalsProvider().getHospitalsListByVal(searchVal: _userProvider.user?.clientName).then((value) { HospitalsProvider().getHospitalsListByVal(searchVal: _userProvider.user?.clientName).then((value) {
_gasRefillProvider.hospital = value?.firstWhere((element) => element.name == _userProvider.user?.clientName, orElse: () => null); _gasRefillProvider.hospital = value?.firstWhere((element) => element.name == _userProvider.user?.clientName, orElse: () => null);
@ -275,7 +275,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}, },
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
if (_userProvider.user?.type == UsersTypes.normal_user) if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
Column( Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
@ -289,6 +289,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
to: DateTime.now().add(const Duration(days: 365)), to: DateTime.now().add(const Duration(days: 365)),
onDateTimePicker: (date) { onDateTimePicker: (date) {
_gasRefillProvider.expectedDateTime = date; _gasRefillProvider.expectedDateTime = date;
_formModel.expectedDate = _gasRefillProvider.expectedDateTime;
setState(() {}); setState(() {});
}, },
), ),

Loading…
Cancel
Save