Creata pagina step della commessa
This commit is contained in:
@@ -7,12 +7,15 @@
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto.JobProgress
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@inject IManageDataService ManageData
|
||||
@inject IMapper Mapper
|
||||
@inject IDialogService Dialog
|
||||
@inject INetworkService NetworkService
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject UserPageState UserState
|
||||
|
||||
<HeaderLayout BackTo="Indietro" LabelSave="Modifica" OnSave="() => OpenUserForm(Anag)" Back="true" BackOnTop="true" Title="" ShowProfile="false" />
|
||||
<HeaderLayout BackTo="Indietro" LabelSave="Modifica" OnSave="() => OpenUserForm(Anag)" Back="true" BackOnTop="true" Title="" ShowProfile="false"/>
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
@@ -89,11 +92,27 @@ else
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MudTabs TabPanelClass="custom-tab-panel" Elevation="2" Rounded="true" PanelClass="pt-2" Centered="true">
|
||||
<MudTabPanel Text="Contatti">
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab1" checked>
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab2">
|
||||
|
||||
<div class="box">
|
||||
<ul class="tab-list">
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab1">Contatti</label>
|
||||
</li>
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab2">Commesse</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- contenuti -->
|
||||
<div class="tab-container">
|
||||
<div class="tab-content">
|
||||
<!-- Contatti -->
|
||||
@if (PersRif is { Count: > 0 })
|
||||
{
|
||||
<div style="margin-top: 1rem;" class="container-pers-rif">
|
||||
<div class="container-pers-rif">
|
||||
<Virtualize Items="PersRif" Context="person">
|
||||
@{
|
||||
var index = PersRif.IndexOf(person);
|
||||
@@ -117,20 +136,30 @@ else
|
||||
Aggiungi contatto
|
||||
</MudButton>
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="Commesse">
|
||||
@if (Commesse.IsNullOrEmpty())
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<!-- Commesse -->
|
||||
@if (LoadCommessa)
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna commessa presente"/>
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Virtualize Items="Commesse" Context="commessa">
|
||||
<CommessaCard Commessa="commessa"/>
|
||||
</Virtualize>
|
||||
@if (Commesse.IsNullOrEmpty())
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna commessa presente"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="commesse-container">
|
||||
<Virtualize Items="Commesse" Context="commessa">
|
||||
<CommessaCard Steps="@Steps[commessa.CodJcom]" RagSoc="@Anag.RagSoc" Commessa="commessa"/>
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -140,14 +169,26 @@ else
|
||||
|
||||
private ContactDTO Anag { get; set; } = new();
|
||||
private List<PersRifDTO>? PersRif { get; set; }
|
||||
private List<JtbComt> Commesse { get; set; }
|
||||
private List<JtbComt>? Commesse { get; set; }
|
||||
private StbUser? Agente { get; set; }
|
||||
private Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } = [];
|
||||
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool LoadCommessa { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadData();
|
||||
if (UserState.CodUser != null && UserState.CodUser.Equals(CodContact))
|
||||
{
|
||||
LoadDataFromSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
@@ -164,18 +205,64 @@ else
|
||||
}
|
||||
|
||||
await LoadPersRif();
|
||||
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
_ = LoadCommesse();
|
||||
|
||||
if (Anag.CodVage != null)
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage))).LastOrDefault();
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
SetDataSession();
|
||||
}
|
||||
|
||||
private void LoadDataFromSession()
|
||||
{
|
||||
Anag = UserState.Anag;
|
||||
PersRif = UserState.PersRif;
|
||||
Commesse = UserState.Commesse;
|
||||
Agente = UserState.Agente;
|
||||
Steps = UserState.Steps;
|
||||
|
||||
SortCommesse();
|
||||
|
||||
LoadCommessa = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SetDataSession()
|
||||
{
|
||||
UserState.CodUser = CodContact;
|
||||
UserState.Anag = Anag;
|
||||
UserState.PersRif = PersRif;
|
||||
UserState.Agente = Agente;
|
||||
UserState.Steps = Steps;
|
||||
}
|
||||
|
||||
private async Task LoadCommesse()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
UserState.Commesse = Commesse;
|
||||
|
||||
foreach (var commessa in Commesse)
|
||||
{
|
||||
var steps = (await IntegryApiService.RetrieveJobProgress(commessa.CodJcom)).Steps;
|
||||
Steps.Add(commessa.CodJcom, steps);
|
||||
}
|
||||
|
||||
LoadCommessa = false;
|
||||
});
|
||||
|
||||
SortCommesse();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SortCommesse()
|
||||
{
|
||||
Commesse = Commesse?.OrderBy(x => x.LastUpd.HasValue).ThenBy(x => x.LastUpd).ToList();
|
||||
}
|
||||
|
||||
private async Task LoadPersRif()
|
||||
{
|
||||
if (IsContact)
|
||||
|
||||
Reference in New Issue
Block a user