127 lines
4.8 KiB
Plaintext
127 lines
4.8 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
|
|
@inject IIspezioniService IspezioniService
|
|
@inject IIntegrySteupService IntegrySteupService
|
|
@inject IDialogService Dialog
|
|
|
|
<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 (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>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
|
<ConfirmDeleteMessageBox @ref="_deleteMessageBox" Message="Confermi la cancellazione della scheda corrente?"/>
|
|
|
|
@code{
|
|
[Parameter] public string CodMdep { get; set; } = string.Empty;
|
|
[Parameter] public DateTime Data { get; set; }
|
|
[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 ConfirmDeleteMessageBox _deleteMessageBox = null!;
|
|
|
|
private async Task UpdateScheda()
|
|
{
|
|
var modal = await Dialog.OpenFormScheda(CodMdep, Data, false, Scheda);
|
|
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
|
|
}
|
|
|
|
private async Task DeleteScheda()
|
|
{
|
|
var result = await _deleteMessageBox.ShowAsync();
|
|
|
|
if (result is true)
|
|
{
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
if (Scheda.ActivityId != null)
|
|
await IntegrySteupService.DeleteScheda(Scheda.ActivityId);
|
|
|
|
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
|
|
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
|
|
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private async Task ExportScheda()
|
|
{
|
|
VisibleOverlay = true;
|
|
StateHasChanged();
|
|
|
|
var apiResponse = await IntegrySteupService.SaveScheda(
|
|
new SaveRequestDto
|
|
{
|
|
LocalIdScheda = Scheda.Id,
|
|
ActivityTypeId = Scheda.ActivityTypeId,
|
|
CodJfas = Scheda.CodJfas,
|
|
CodMdep = CodMdep,
|
|
DataCreazione = 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(CodMdep, Data,
|
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
|
);
|
|
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
|
}
|
|
|
|
VisibleOverlay = false;
|
|
StateHasChanged();
|
|
}
|
|
|
|
} |