Gestiti salvataggi rest
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using SteUp.Shared.Core.Entities
|
||||
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||
@using SteUp.Shared.Core.Interface.System.Network
|
||||
@using SteUp.Shared.Core.Messages.Ispezione
|
||||
@using SteUp.Shared.Core.Messages.Scheda
|
||||
@inject INetworkService NetworkService
|
||||
@inject IDialogService Dialog
|
||||
@@ -31,17 +34,24 @@
|
||||
|
||||
@if (PlusVisible)
|
||||
{
|
||||
<MudFabMenu ButtonClass="custom-plus-button" MenuClass="custom-menu-fab" OnClick="@OnOpenMenu" StartIcon="@Icons.Material.Filled.Add"
|
||||
IconColor="Color.Primary" Color="Color.Surface" AlignItems="AlignItems.End"
|
||||
<MudFabMenu ButtonClass="custom-plus-button" MenuClass="custom-menu-fab" OnClick="@OnOpenMenu"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
IconColor="Color.Primary" Color="Color.Surface" AlignItems="AlignItems.End"
|
||||
Size="Size.Medium" IconSize="Size.Medium">
|
||||
@if (SchedaVisible)
|
||||
{
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||
if (ShowCompleteInspection)
|
||||
{
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@CompleteInspection"
|
||||
Label="Concludi ispezione" Color="Color.Surface"/>
|
||||
}
|
||||
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||
Label="Nuova scheda" Color="Color.Surface"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewActivity"
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewActivity"
|
||||
Label="Nuova ispezione" Color="Color.Surface"/>
|
||||
}
|
||||
</MudFabMenu>
|
||||
@@ -53,6 +63,7 @@
|
||||
{
|
||||
private bool IsVisible { get; set; } = true;
|
||||
private bool PlusVisible { get; set; } = true;
|
||||
private bool ShowCompleteInspection { get; set; }
|
||||
private bool SchedaVisible { get; set; }
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
@@ -81,6 +92,9 @@
|
||||
_ = ModalHelper.OpenSelectShop(Dialog);
|
||||
}
|
||||
|
||||
private void CompleteInspection() =>
|
||||
Messenger.Send(new CompleteInspectionMessage());
|
||||
|
||||
private async Task NewScheda()
|
||||
{
|
||||
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||
@@ -95,6 +109,7 @@
|
||||
var location = NavigationManager.Uri.Remove(0, NavigationManager.BaseUri.Length);
|
||||
|
||||
SchedaVisible = new List<string> { "ispezione" }.Contains(location);
|
||||
ShowCompleteInspection = !SteupDataService.InspectionPageState.Ispezione.ActivityId.IsNullOrEmpty();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
@page "/ispezione"
|
||||
@using SteUp.Shared.Components.Layout
|
||||
@using SteUp.Shared.Components.Layout.Overlay
|
||||
@using SteUp.Shared.Components.SingleElements.Card
|
||||
@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.Messages.Ispezione
|
||||
@using SteUp.Shared.Core.Messages.Scheda
|
||||
@inject NewSchedaService NewScheda
|
||||
@inject CompleteInspectionService CompleteInspection
|
||||
@inject IIspezioniService IspezioniService
|
||||
@inject IDialogService Dialog
|
||||
@inject IIntegrySteupService IntegrySteupService
|
||||
@implements IDisposable
|
||||
|
||||
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
|
||||
@@ -30,9 +36,23 @@
|
||||
</MudChip>
|
||||
</div>
|
||||
<div class="action-scheda-group">
|
||||
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Rounded.Add"
|
||||
Color="Color.Warning" Size="Size.Medium"
|
||||
OnClick="@(() => CreateNewScheda(group.Key))"/>
|
||||
@if (NetworkService.IsNetworkAvailable())
|
||||
{
|
||||
<MudFab StartIcon="@Icons.Material.Rounded.Add"
|
||||
Color="Color.Warning" Size="Size.Small"
|
||||
OnClick="@(() => CreateNewScheda(group.Key))"/>
|
||||
|
||||
<MudFab StartIcon="@Icons.Material.Rounded.CloudSync" Label="Esporta reparto"
|
||||
Color="Color.Success" Size="Size.Small"
|
||||
OnClick="@(() => ExportReparto(group.Key))"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudFab StartIcon="@Icons.Material.Rounded.Add"
|
||||
Label="@($"Nuova scheda su {group.Key.Descrizione}")"
|
||||
Color="Color.Warning" Size="Size.Medium"
|
||||
OnClick="@(() => CreateNewScheda(group.Key))"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</TitleContent>
|
||||
@@ -51,13 +71,18 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
||||
|
||||
@code {
|
||||
private List<Scheda> SchedeList { get; set; } = [];
|
||||
private Dictionary<JtbFasiDto, List<Scheda>> SchedeGrouped { get; set; } = [];
|
||||
|
||||
private bool VisibleOverlay { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
NewScheda.OnNewScheda += LoadSchede;
|
||||
CompleteInspection.OnComplete += HandleCompleteInspection;
|
||||
|
||||
LoadSchede();
|
||||
}
|
||||
@@ -77,6 +102,48 @@
|
||||
});
|
||||
}
|
||||
|
||||
private async void HandleCompleteInspection()
|
||||
{
|
||||
try
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||
|
||||
SteupDataService.InspectionPageState.Ispezione.Stato = StatusEnum.Completata;
|
||||
|
||||
await IntegrySteupService.CompleteInspection(ispezione.ActivityId!);
|
||||
await IspezioniService.UpdateStatoIspezioneAsync(
|
||||
ispezione.CodMdep,
|
||||
ispezione.Data,
|
||||
ispezione.Rilevatore,
|
||||
StatusEnum.Completata
|
||||
);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
OnError(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void GroupSchede()
|
||||
{
|
||||
SchedeGrouped = SchedeList
|
||||
@@ -114,12 +181,76 @@
|
||||
new Scheda { Reparto = jtbFasi }
|
||||
);
|
||||
|
||||
if (modal is {Canceled: false}) LoadSchede();
|
||||
if (modal is { Canceled: false }) LoadSchede();
|
||||
}
|
||||
|
||||
private async Task ExportReparto(JtbFasiDto jtbFasi)
|
||||
{
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||
|
||||
var saveRequest = SchedeGrouped[jtbFasi].ConvertAll(x =>
|
||||
{
|
||||
return new SaveRequestDto
|
||||
{
|
||||
LocalIdScheda = x.Id,
|
||||
ActivityTypeId = x.ActivityTypeId,
|
||||
CodJfas = x.CodJfas,
|
||||
CodMdep = ispezione.CodMdep,
|
||||
DataCreazione = ispezione.Data,
|
||||
Note = x.Note,
|
||||
PersonaRif = x.Responsabile,
|
||||
Barcodes = x.Articoli.ConvertAll(y => y.Barcode),
|
||||
Scandeza = (ScadenzaEnum)x.Scadenza,
|
||||
ParentActivityId = x.Ispezione?.ActivityId
|
||||
};
|
||||
});
|
||||
|
||||
var apiResponse = await IntegrySteupService.SaveMultipleSchede(saveRequest);
|
||||
|
||||
if (apiResponse != null)
|
||||
{
|
||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(ispezione.CodMdep, ispezione.Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
|
||||
if (apiResponse.ActivityIdSchedaList.IsNullOrEmpty()) return;
|
||||
|
||||
foreach (var scheda in SchedeGrouped[jtbFasi])
|
||||
{
|
||||
scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||
|
||||
var activityId = apiResponse.ActivityIdSchedaList!.Find(x =>
|
||||
x.LocalId != null && x.LocalId == scheda.Id
|
||||
)?.ActivityId;
|
||||
|
||||
if (activityId == null) return;
|
||||
|
||||
scheda.ActivityId = activityId;
|
||||
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||
}
|
||||
}
|
||||
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void OnError(string? errorMessage)
|
||||
{
|
||||
if (errorMessage == null) return;
|
||||
|
||||
_ = ModalHelper.ShowError(Dialog, errorMessage);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
NewScheda.OnNewScheda -= LoadSchede;
|
||||
CompleteInspection.OnComplete -= HandleCompleteInspection;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,4 +2,10 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.action-scheda-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
}
|
||||
@@ -100,6 +100,8 @@ else
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
Spinner = false;
|
||||
StateHasChanged();
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@using SteUp.Shared.Components.Layout.Spinner
|
||||
<SpinnerLayout FullScreen="true"/>
|
||||
@@ -1,3 +1,4 @@
|
||||
@using SteUp.Shared.Components.Pages.Utility
|
||||
@using SteUp.Shared.Components.SingleElements.Modal.ExceptionModal
|
||||
@using SteUp.Shared.Core.BarcodeReader.Contracts
|
||||
@inject NavigationManager NavigationManager
|
||||
@@ -8,21 +9,29 @@
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="@typeof(Routes).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
|
||||
<Authorizing>
|
||||
<p>Authorizing page</p>
|
||||
</Authorizing>
|
||||
<NotAuthorized>
|
||||
@if (context.User.Identity?.IsAuthenticated != true)
|
||||
{
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
else
|
||||
{
|
||||
<p role="alert">You are not authorized to access this resource.</p>
|
||||
}
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
@if (!LoadData)
|
||||
{
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
|
||||
<Authorizing>
|
||||
<AuthorizingPage/>
|
||||
</Authorizing>
|
||||
<NotAuthorized>
|
||||
@if (context.User.Identity?.IsAuthenticated != true)
|
||||
{
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
else
|
||||
{
|
||||
<p role="alert">You are not authorized to access this resource.</p>
|
||||
}
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
}
|
||||
else
|
||||
{
|
||||
<AuthorizingPage/>
|
||||
}
|
||||
|
||||
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
|
||||
</Found>
|
||||
</Router>
|
||||
@@ -38,13 +47,21 @@
|
||||
</ErrorBoundary>
|
||||
|
||||
@code {
|
||||
private bool LoadData { get; set; }
|
||||
|
||||
private ErrorBoundary? ErrorBoundary { get; set; }
|
||||
private ExceptionModal ExceptionModal { get; set; } = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
LoadData = true;
|
||||
StateHasChanged();
|
||||
|
||||
await SteupDataService.Init();
|
||||
BarcodeManager.Init();
|
||||
|
||||
LoadData = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
@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">
|
||||
@@ -14,36 +18,48 @@
|
||||
|
||||
<div class="sub-info-section">
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
|
||||
0
|
||||
@Scheda.ImageNames.Count()
|
||||
</MudChip>
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
|
||||
0
|
||||
@Scheda.Articoli.Count
|
||||
</MudChip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="scheda-card-action">
|
||||
<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>
|
||||
@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 DateOnly Data { get; set; }
|
||||
[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()
|
||||
@@ -63,4 +79,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
SteupDataService.InspectionPageState.Ispezione = await IspezioniService.GetOrCreateIspezioneAsync(
|
||||
PuntoVendita.CodMdep!,
|
||||
DateOnly.FromDateTime(DateTime.Today),
|
||||
DateTime.Now,
|
||||
UserSession.User.Username
|
||||
);
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
@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
|
||||
@using SteUp.Shared.Core.Interface.System.Network
|
||||
@using SteUp.Shared.Core.Messages.Scanner
|
||||
@inject INetworkService NetworkService
|
||||
@inject IDialogService Dialog
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="content">
|
||||
|
||||
<CardFormModal Title="Reparto" Loading="SteupDataService.Reparti.IsNullOrEmpty()">
|
||||
<MudSelectExtended ReadOnly="IsView" T="JtbFasiDto?" Variant="Variant.Text"
|
||||
<MudSelectExtended T="JtbFasiDto?" Variant="Variant.Text"
|
||||
@bind-Value="Scheda.Reparto" ToStringFunc="@(x => x?.Descrizione)"
|
||||
@bind-Value:after="OnAfterChangeReparto" Required="true"
|
||||
RequiredError="Reparto obbligatorio">
|
||||
@@ -41,7 +41,7 @@
|
||||
</CardFormModal>
|
||||
|
||||
<CardFormModal Title="Motivo" Loading="SteupDataService.TipiAttività.IsNullOrEmpty()">
|
||||
<MudSelectExtended ReadOnly="@(IsView || Scheda.CodJfas.IsNullOrEmpty())" T="string?"
|
||||
<MudSelectExtended ReadOnly="@Scheda.CodJfas.IsNullOrEmpty()" T="string?"
|
||||
Variant="Variant.Text"
|
||||
@bind-Value="Scheda.ActivityTypeId" @bind-Value:after="OnAfterChangeValue"
|
||||
Required="true" RequiredError="Motivo obbligatorio">
|
||||
@@ -75,10 +75,13 @@
|
||||
}
|
||||
<MudCardContent Class="image_card">
|
||||
<MudText Typo="Typo.subtitle1"><b>@item.p.Name</b></MudText>
|
||||
<MudIconButton Variant="Variant.Outlined"
|
||||
Icon="@Icons.Material.Rounded.Close"
|
||||
Size="Size.Small" Color="Color.Error"
|
||||
OnClick="@(() => OnRemoveAttached(item.index))"/>
|
||||
@if (IsNew)
|
||||
{
|
||||
<MudIconButton Variant="Variant.Outlined"
|
||||
Icon="@Icons.Material.Rounded.Close"
|
||||
Size="Size.Small" Color="Color.Error"
|
||||
OnClick="@(() => OnRemoveAttached(item.index))"/>
|
||||
}
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
}
|
||||
@@ -87,19 +90,16 @@
|
||||
</CardFormModal>
|
||||
}
|
||||
|
||||
@if (!IsView)
|
||||
{
|
||||
<div class="container-button ripple-container">
|
||||
<MudButton Class="button-settings green-icon"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Rounded.AttachFile"
|
||||
Size="Size.Medium"
|
||||
OnClick="@OpenAddAttached"
|
||||
Variant="Variant.Outlined">
|
||||
Aggiungi foto
|
||||
</MudButton>
|
||||
</div>
|
||||
}
|
||||
<div class="container-button ripple-container">
|
||||
<MudButton Class="button-settings green-icon"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Rounded.AttachFile"
|
||||
Size="Size.Medium"
|
||||
OnClick="@OpenAddAttached"
|
||||
Variant="Variant.Outlined">
|
||||
Aggiungi foto
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
<CardFormModal Title="Articoli">
|
||||
<div class="input-manual-barcode">
|
||||
@@ -113,7 +113,8 @@
|
||||
<div class="art-list">
|
||||
@foreach (var articolo in Scheda.Articoli)
|
||||
{
|
||||
<MudChip T="string" OnClose="@(() => RemoveArt(articolo.Barcode))" style="height: auto;">
|
||||
<MudChip T="string" OnClose="@(() => RemoveArt(articolo.Barcode))"
|
||||
style="height: auto;">
|
||||
<MudStack Direction="Column" Spacing="0" class="py-1">
|
||||
<MudText Typo="Typo.subtitle2" Style="line-height: 1.1; font-weight: 700;">
|
||||
@articolo.Descrizione
|
||||
@@ -143,23 +144,23 @@
|
||||
}
|
||||
|
||||
<CardFormModal Title="Scadenza">
|
||||
<MudSelectExtended FullWidth="true" ReadOnly="@IsView" T="int" Variant="Variant.Text"
|
||||
<MudSelectExtended FullWidth="true" T="int" Variant="Variant.Text"
|
||||
@bind-Value="@Scheda.Scadenza" @bind-Value:after="OnAfterChangeValue">
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="24"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="168"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="730"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="1460"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="3"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="2"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="1"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="0"/>
|
||||
</MudSelectExtended>
|
||||
</CardFormModal>
|
||||
|
||||
<CardFormModal Title="Responsabile">
|
||||
<MudTextField FullWidth="true" ReadOnly="IsView" T="string?" Variant="Variant.Text"
|
||||
<MudTextField FullWidth="true" T="string?" Variant="Variant.Text"
|
||||
@bind-Value="Scheda.Responsabile" @bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</CardFormModal>
|
||||
|
||||
<CardFormModal Title="Note">
|
||||
<MudTextField ReadOnly="IsView" T="string?" Variant="Variant.Text" Lines="3"
|
||||
<MudTextField T="string?" Variant="Variant.Text" Lines="3"
|
||||
@bind-Value="Scheda.Note" @bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</CardFormModal>
|
||||
@@ -187,7 +188,7 @@
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
[Parameter] public required string CodMdep { get; set; }
|
||||
[Parameter] public required DateOnly Data { get; set; }
|
||||
[Parameter] public required DateTime Data { get; set; }
|
||||
[Parameter] public bool IsNew { get; set; }
|
||||
[Parameter] public Scheda Scheda { get; set; } = new();
|
||||
|
||||
@@ -214,7 +215,7 @@
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
|
||||
|
||||
OnScannerService.OnNewScanSuccessful += HandleNewScanSuccessful;
|
||||
OnScannerService.OnErrorScan += OnErrorScan;
|
||||
|
||||
@@ -226,6 +227,8 @@
|
||||
|
||||
private void LoadAttached()
|
||||
{
|
||||
if (Scheda.ImageNames == null) return;
|
||||
|
||||
FileLoading = true;
|
||||
StateHasChanged();
|
||||
|
||||
@@ -237,7 +240,8 @@
|
||||
CodMdep = CodMdep,
|
||||
Data = Data,
|
||||
Rilevatore = UserSession.User.Username
|
||||
}
|
||||
},
|
||||
Scheda.ImageNames
|
||||
);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
@@ -254,9 +258,40 @@
|
||||
{
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
SaveSchedaResponseDto? apiResponse = null;
|
||||
try
|
||||
{
|
||||
if (!IsView)
|
||||
{
|
||||
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 = IsNew ? null : Scheda.Ispezione?.ActivityId
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
await ModalHelper.ShowError(Dialog, e.Message);
|
||||
}
|
||||
|
||||
if (IsNew) await NewSave();
|
||||
else await Update();
|
||||
if (IsNew) await NewSave(apiResponse);
|
||||
else await Update(apiResponse);
|
||||
|
||||
if (Scheda.ActivityId.IsValorized()) await UploadFile(Scheda.ActivityId!);
|
||||
|
||||
await AttachedService.CleanTempStorageAsync();
|
||||
|
||||
@@ -268,7 +303,7 @@
|
||||
MudDialog.Close(Scheda);
|
||||
}
|
||||
|
||||
private async Task NewSave()
|
||||
private async Task NewSave(SaveSchedaResponseDto? apiResponse)
|
||||
{
|
||||
if (!AttachedList.IsNullOrEmpty())
|
||||
{
|
||||
@@ -291,10 +326,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (apiResponse != null)
|
||||
{
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||
}
|
||||
|
||||
await IspezioniService.AddSchedaAsync(CodMdep, Data, UserSession.User.Username, Scheda);
|
||||
}
|
||||
|
||||
private async Task Update()
|
||||
private async Task Update(SaveSchedaResponseDto? apiResponse)
|
||||
{
|
||||
if (!AttachedList.IsNullOrEmpty())
|
||||
{
|
||||
@@ -324,7 +367,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
Scheda.ActivityId = apiResponse?.ActivityIdScheda;
|
||||
await IspezioniService.UpdateSchedaAsync(Scheda);
|
||||
|
||||
if (apiResponse != null)
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
}
|
||||
|
||||
private async Task UploadFile(string activityId)
|
||||
{
|
||||
if (AttachedList.IsNullOrEmpty()) return;
|
||||
|
||||
var ispezione = new Ispezione
|
||||
{
|
||||
CodMdep = CodMdep,
|
||||
Data = Data,
|
||||
Rilevatore = UserSession.User.Username
|
||||
};
|
||||
|
||||
foreach (var file in AttachedList!.Where(x => x.ToUpload))
|
||||
{
|
||||
if (file.FileBytes == null || file.Name == null) continue;
|
||||
|
||||
await IntegrySteupService.UploadFile(activityId, file.FileBytes, file.Name);
|
||||
await AttachedService.MoveInspectionFileFromToUploadToFinal(ispezione, file.Name);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Cancel()
|
||||
@@ -436,6 +505,7 @@
|
||||
var target = AttachedList![AttachedList.Count - attachedList.Count + i];
|
||||
target.TempPath = origUrl;
|
||||
target.ThumbPath = thumbUrl;
|
||||
target.ToUpload = true;
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
@@ -456,7 +526,7 @@
|
||||
Snackbar.Add("Selezionare prima il reparto", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
OnLoading = true;
|
||||
TextLoading = "Download articoli in griglia";
|
||||
StateHasChanged();
|
||||
@@ -477,25 +547,27 @@
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
OnLoading = false;
|
||||
TextLoading = null;
|
||||
StateHasChanged();
|
||||
|
||||
|
||||
OnError(e.Message);
|
||||
});
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var modal = await ModalHelper.OpenSelectArt(Dialog, articoli);
|
||||
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
OnLoading = false;
|
||||
TextLoading = null;
|
||||
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
@@ -581,17 +653,17 @@
|
||||
{
|
||||
OnLoading = false;
|
||||
StateHasChanged();
|
||||
|
||||
|
||||
if (art != null)
|
||||
{
|
||||
RecalcDirty(true);
|
||||
|
||||
|
||||
Scheda.Articoli.Add(new SchedaArticolo
|
||||
{
|
||||
Barcode = art.Barcode,
|
||||
Descrizione = art.Descrizione
|
||||
});
|
||||
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
@@ -602,12 +674,14 @@
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
OnLoading = false;
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
|
||||
OnError(e.Message);
|
||||
}
|
||||
}
|
||||
@@ -627,7 +701,7 @@
|
||||
{
|
||||
var index = Scheda.Articoli.FindIndex(x => x.Barcode.Equals(barcode));
|
||||
if (index < 0) return;
|
||||
|
||||
|
||||
RecalcDirty(true);
|
||||
Scheda.Articoli.RemoveAt(index);
|
||||
StateHasChanged();
|
||||
|
||||
Reference in New Issue
Block a user