172 lines
6.4 KiB
Plaintext
172 lines
6.4 KiB
Plaintext
@using SteUp.Shared.Components.Layout.Overlay
|
|
@using SteUp.Shared.Components.SingleElements.MessageBox
|
|
@using SteUp.Shared.Core.Dto
|
|
@using SteUp.Shared.Core.Entities
|
|
@using SteUp.Shared.Core.Enum
|
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
|
@using SteUp.Shared.Core.Interface.LocalDb
|
|
@using SteUp.Shared.Core.Interface.System
|
|
@inject IIspezioniService IspezioniService
|
|
@inject IIntegrySteupService IntegrySteupService
|
|
@inject IDialogService Dialog
|
|
@inject IFileManager FileManager
|
|
|
|
<div class="scheda-card">
|
|
<div class="scheda-body-section">
|
|
<div class="title-section">
|
|
<MudText Class="scheda-title" Typo="Typo.subtitle1">
|
|
<b>@Scheda.ActivityTypeId</b>
|
|
</MudText>
|
|
|
|
<div class="sub-info-section">
|
|
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
|
|
@Scheda.ImageNames.Count()
|
|
</MudChip>
|
|
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
|
|
@Scheda.Articoli.Count
|
|
</MudChip>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="scheda-card-action">
|
|
@if (Ispezione.Stato != StatusEnum.Completata)
|
|
{
|
|
if (NetworkService.IsNetworkAvailable())
|
|
{
|
|
<MudFab Color="Color.Info" Size="Size.Small" StartIcon="@Icons.Material.Rounded.Edit"
|
|
OnClick="@UpdateScheda"/>
|
|
<MudFab Color="Color.Error" Size="Size.Small" StartIcon="@Icons.Material.Rounded.Delete"
|
|
OnClick="@DeleteScheda"/>
|
|
<MudFab Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Rounded.CloudSync"
|
|
OnClick="@ExportScheda"/>
|
|
}
|
|
else
|
|
{
|
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit"
|
|
Color="Color.Info" Size="Size.Small" OnClick="@UpdateScheda">
|
|
Modifica
|
|
</MudButton>
|
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Delete"
|
|
Color="Color.Error" Size="Size.Small" OnClick="@DeleteScheda">
|
|
Cancella
|
|
</MudButton>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.RemoveRedEye"
|
|
Color="Color.Info" Size="Size.Small" OnClick="@ViewScheda">
|
|
Visualizza
|
|
</MudButton>
|
|
|
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.CloudSync"
|
|
Color="Color.Success" Size="Size.Small" OnClick="@ExportImg">
|
|
Esporta immagini
|
|
</MudButton>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
|
<ConfirmMessageBox @ref="_messageBox" YesText="Cancella" YesColor="Color.Error"
|
|
Message="Confermi la cancellazione della scheda corrente?"/>
|
|
|
|
@code{
|
|
[Parameter] public Ispezione Ispezione { get; set; } = new();
|
|
[Parameter] public required Scheda Scheda { get; set; }
|
|
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
|
|
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
|
|
|
|
private bool VisibleOverlay { get; set; }
|
|
|
|
private ConfirmMessageBox _messageBox = null!;
|
|
|
|
private async Task UpdateScheda()
|
|
{
|
|
var modal = await Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda);
|
|
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
|
|
}
|
|
|
|
private async Task DeleteScheda()
|
|
{
|
|
var result = await _messageBox.ShowAsync();
|
|
|
|
if (result is true)
|
|
{
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
if (Scheda.ActivityId != null)
|
|
await IntegrySteupService.DeleteScheda(Scheda.ActivityId);
|
|
|
|
if (Scheda.ImageNames != null)
|
|
{
|
|
foreach (var fileName in Scheda.ImageNames)
|
|
{
|
|
FileManager.RemoveInspectionFile(Ispezione, fileName);
|
|
}
|
|
}
|
|
|
|
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
|
|
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
|
|
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private void ViewScheda() =>
|
|
_ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true);
|
|
|
|
private async Task ExportScheda()
|
|
{
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
var apiResponse = await IntegrySteupService.SaveScheda(
|
|
new SaveRequestDto
|
|
{
|
|
LocalIdScheda = Scheda.Id,
|
|
ActivityTypeId = Scheda.ActivityTypeId,
|
|
CodJfas = Scheda.CodJfas,
|
|
CodMdep = Ispezione.CodMdep,
|
|
DataCreazione = Ispezione.Data,
|
|
Note = Scheda.Note,
|
|
PersonaRif = Scheda.Responsabile,
|
|
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
|
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
|
ParentActivityId = Scheda.Ispezione?.ActivityId
|
|
}
|
|
);
|
|
|
|
if (apiResponse != null)
|
|
{
|
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
|
|
|
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
|
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
|
);
|
|
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
|
}
|
|
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
|
|
private async Task ExportImg()
|
|
{
|
|
if (Scheda.ImageNames == null) return;
|
|
|
|
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
|
|
.Where(x => x.ToUpload).ToList();
|
|
|
|
if (fileList == null) return;
|
|
|
|
foreach (var file in fileList)
|
|
{
|
|
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
|
|
}
|
|
}
|
|
} |