|
|
|
@ -150,92 +150,11 @@ class AssetTransferProvider extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<int> updateRequest({
|
|
|
|
Future<int> updateRequest({
|
|
|
|
@required String host,
|
|
|
|
@required AssetTransfer assetTransfer,
|
|
|
|
@required User user,
|
|
|
|
|
|
|
|
@required bool isSender,
|
|
|
|
|
|
|
|
@required int requestId,
|
|
|
|
|
|
|
|
@required AssetTransfer oldModel,
|
|
|
|
|
|
|
|
@required AssetTransfer newModel,
|
|
|
|
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
Map<String, dynamic> body = {
|
|
|
|
|
|
|
|
"id": oldModel.id,
|
|
|
|
|
|
|
|
// "assetId": oldModel.device.id ?? "",
|
|
|
|
|
|
|
|
// "senderSiteId": oldModel.sender.client.id,
|
|
|
|
|
|
|
|
// "destSiteId": oldModel.receiver.client.id,
|
|
|
|
|
|
|
|
// "destDepartmentId": oldModel.receiver.department.id,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isSender) {
|
|
|
|
|
|
|
|
body.addAll({
|
|
|
|
|
|
|
|
// "senderSiteId": newModel.client.id,
|
|
|
|
|
|
|
|
// "senderDepartmentId": newModel.department.id,
|
|
|
|
|
|
|
|
// "senderAssignedEmployeeId": newModel.userId,
|
|
|
|
|
|
|
|
// "senderMachineStatusId": newModel.status.id,
|
|
|
|
|
|
|
|
// "senderComment": newModel.comment,
|
|
|
|
|
|
|
|
// "senderWorkingHours": newModel.workingHours,
|
|
|
|
|
|
|
|
// "senderStartDate": newModel.timer?.startAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "senderEndDate": newModel.timer?.endAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "senderTravelingHours": newModel.travelingHours,
|
|
|
|
|
|
|
|
// "senderEngSignature": newModel.engSignature,
|
|
|
|
|
|
|
|
// if (newModel?.attachments?.isNotEmpty ?? false)
|
|
|
|
|
|
|
|
// "senderAttachments":
|
|
|
|
|
|
|
|
// newModel?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
|
|
|
|
|
|
|
|
// "destSiteId": oldModel.receiver.client?.id,
|
|
|
|
|
|
|
|
// "destDepartmentId": oldModel.receiver.department?.id,
|
|
|
|
|
|
|
|
// "destBuildingId": oldModel.device?.destBuildingId,
|
|
|
|
|
|
|
|
// "destFloorId": oldModel.device?.destFloorId,
|
|
|
|
|
|
|
|
// "destRoom": oldModel.device?.destRoom,
|
|
|
|
|
|
|
|
// "receiverAssignedEmployeeId": oldModel.receiver.userId,
|
|
|
|
|
|
|
|
// "receiverMachineStatusId": oldModel.receiver.status.id ?? "",
|
|
|
|
|
|
|
|
// "receiverComment": oldModel.receiver.comment,
|
|
|
|
|
|
|
|
// "receiverWorkingHours": oldModel.receiver.workingHours,
|
|
|
|
|
|
|
|
// "receiverStartDate": oldModel.receiver.timer?.startAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "receiverEndDate": oldModel.receiver.timer?.endAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "receiverTravelingHours": oldModel.receiver?.travelingHours,
|
|
|
|
|
|
|
|
// "receiverEngSignature": oldModel.receiver?.engSignature,
|
|
|
|
|
|
|
|
// if (oldModel.receiver?.attachments?.isNotEmpty ?? false)
|
|
|
|
|
|
|
|
// "receiverAttachments": oldModel.receiver?.attachments
|
|
|
|
|
|
|
|
// ?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})
|
|
|
|
|
|
|
|
// ?.toList(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
body.addAll({
|
|
|
|
|
|
|
|
// "senderSiteId": oldModel.sender.client.id,
|
|
|
|
|
|
|
|
// "senderDepartmentId": oldModel.sender.department.id,
|
|
|
|
|
|
|
|
// "senderAssignedEmployeeId": oldModel.sender.userId,
|
|
|
|
|
|
|
|
// "senderMachineStatusId": oldModel.sender.status.id,
|
|
|
|
|
|
|
|
// "senderComment": oldModel.sender.comment,
|
|
|
|
|
|
|
|
// "senderWorkingHours": oldModel.sender.workingHours,
|
|
|
|
|
|
|
|
// "senderStartDate": oldModel.sender.timer?.startAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "senderEndDate": oldModel.sender.timer?.endAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "senderTravelingHours": oldModel.sender?.travelingHours,
|
|
|
|
|
|
|
|
// "senderEngSignature": oldModel.sender?.engSignature,
|
|
|
|
|
|
|
|
// if (oldModel.sender?.attachments?.isNotEmpty ?? false)
|
|
|
|
|
|
|
|
// "senderAttachments":
|
|
|
|
|
|
|
|
// oldModel.sender?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
|
|
|
|
|
|
|
|
// "destSiteId": newModel.client?.id,
|
|
|
|
|
|
|
|
// "destDepartmentId": newModel.department?.id,
|
|
|
|
|
|
|
|
// "destBuildingId": oldModel.device?.destBuildingId,
|
|
|
|
|
|
|
|
// "destFloorId": oldModel.device?.destFloorId,
|
|
|
|
|
|
|
|
// "destRoom": oldModel.device?.destRoom,
|
|
|
|
|
|
|
|
// "receiverAssignedEmployeeId": newModel.userId,
|
|
|
|
|
|
|
|
// "receiverMachineStatusId": newModel.status?.id ?? "",
|
|
|
|
|
|
|
|
// "receiverComment": newModel.comment,
|
|
|
|
|
|
|
|
// "receiverWorkingHours": newModel.workingHours,
|
|
|
|
|
|
|
|
// "receiverStartDate": newModel.timer?.startAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "receiverEndDate": newModel.timer?.endAt?.toIso8601String(),
|
|
|
|
|
|
|
|
// "receiverTravelingHours": newModel.travelingHours,
|
|
|
|
|
|
|
|
// "receiverEngSignature": newModel.engSignature,
|
|
|
|
|
|
|
|
// if (newModel?.attachments?.isNotEmpty ?? false)
|
|
|
|
|
|
|
|
// "receiverAttachments":
|
|
|
|
|
|
|
|
// newModel?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//body.addAll(newModel.toJson(isSender));
|
|
|
|
|
|
|
|
log(body?.toString());
|
|
|
|
|
|
|
|
Response response;
|
|
|
|
Response response;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: body);
|
|
|
|
response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: assetTransfer.toJson());
|
|
|
|
|
|
|
|
|
|
|
|
print(response.body);
|
|
|
|
print(response.body);
|
|
|
|
// print("${newModel.engSignature}.png");
|
|
|
|
// print("${newModel.engSignature}.png");
|
|
|
|
|