Fix e migliorati caricamenti
This commit is contained in:
@@ -86,20 +86,19 @@
|
||||
<div class="input-card">
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Tipo cliente</span>
|
||||
|
||||
@if (VtbTipi.IsNullOrEmpty())
|
||||
{
|
||||
<span class="warning-text">Nessun tipo cliente trovato</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || VtbTipi.IsNullOrEmpty())" T="string?" Variant="Variant.Text" @bind-Value="ContactModel.CodVtip" @bind-Value:after="OnAfterChangeValue" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||
@foreach (var tipo in VtbTipi)
|
||||
{
|
||||
<MudSelectItemExtended Class="custom-item-select" Value="@tipo.CodVtip">@($"{tipo.CodVtip} - {tipo.Descrizione}")</MudSelectItemExtended>
|
||||
}
|
||||
</MudSelectExtended>
|
||||
}
|
||||
|
||||
<MudAutocomplete Disabled="VtbTipi.IsNullOrEmpty()" ReadOnly="IsView"
|
||||
T="VtbTipi"
|
||||
@bind-Value="SelectedType"
|
||||
@bind-Value:after="OnTypeSelectedAfter"
|
||||
SearchFunc="SearchTypeAsync"
|
||||
ToStringFunc="@(u => u == null ? string.Empty : $"{u.CodVtip} - {u.Descrizione}")"
|
||||
Clearable="true"
|
||||
ShowProgressIndicator="true"
|
||||
DebounceInterval="300"
|
||||
MaxItems="50"
|
||||
Class="customIcon-select"
|
||||
AdornmentIcon="@Icons.Material.Filled.Code" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -241,15 +240,19 @@
|
||||
<div class="input-card">
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Agente</span>
|
||||
|
||||
<MudSelectExtended FullWidth="true" T="string?" Variant="Variant.Text" NoWrap="true"
|
||||
@bind-Value="ContactModel.CodVage" @bind-Value:after="OnAfterChangeValue"
|
||||
Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||
@foreach (var user in Users)
|
||||
{
|
||||
<MudSelectItemExtended Class="custom-item-select" Value="@user.UserCode">@($"{user.UserCode} - {user.FullName}")</MudSelectItemExtended>
|
||||
}
|
||||
</MudSelectExtended>
|
||||
|
||||
<MudAutocomplete Disabled="Users.IsNullOrEmpty()" ReadOnly="IsView"
|
||||
T="StbUser"
|
||||
@bind-Value="SelectedUser"
|
||||
@bind-Value:after="OnUserSelectedAfter"
|
||||
SearchFunc="SearchUtentiAsync"
|
||||
ToStringFunc="@(u => u == null ? string.Empty : u.FullName)"
|
||||
Clearable="true"
|
||||
ShowProgressIndicator="true"
|
||||
DebounceInterval="300"
|
||||
MaxItems="50"
|
||||
Class="customIcon-select"
|
||||
AdornmentIcon="@Icons.Material.Filled.Code" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -268,9 +271,9 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="container-button">
|
||||
@if (IsNew)
|
||||
{
|
||||
@if (IsNew)
|
||||
{
|
||||
<div class="container-button">
|
||||
<MudButton Class="button-settings gray-icon"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Filled.PersonAddAlt1"
|
||||
@@ -279,11 +282,13 @@
|
||||
Variant="Variant.Outlined">
|
||||
Persona di riferimento
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (NetworkService.ConnectionAvailable && !ContactModel.IsContact)
|
||||
{
|
||||
@if (NetworkService.ConnectionAvailable && !ContactModel.IsContact)
|
||||
{
|
||||
<div class="container-button">
|
||||
<MudButton Class="button-settings blue-icon"
|
||||
FullWidth="true"
|
||||
StartIcon="@Icons.Material.Rounded.Sync"
|
||||
@@ -292,9 +297,9 @@
|
||||
Variant="Variant.Outlined">
|
||||
Converti in cliente
|
||||
</MudButton>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<MudMessageBox MarkupMessage="new MarkupString(VatMessage)" @ref="CheckVat" Class="c-messageBox" Title="Verifica partita iva" CancelText="@(VatAlreadyRegistered ? "" : "Annulla")">
|
||||
@@ -351,11 +356,17 @@
|
||||
private bool OpenSearchAddress { get; set; }
|
||||
private IndirizzoDTO Address { get; set; }
|
||||
|
||||
//Agente
|
||||
private StbUser? SelectedUser { get; set; }
|
||||
|
||||
//Type
|
||||
private VtbTipi? SelectedType { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
|
||||
await LoadData();
|
||||
_ = LoadData();
|
||||
|
||||
LabelSave = IsNew ? "Aggiungi" : null;
|
||||
}
|
||||
@@ -403,24 +414,27 @@
|
||||
MudDialog.Close(response);
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
private Task LoadData()
|
||||
{
|
||||
if (IsNew)
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var loggedUser = (await ManageData.GetTable<StbUser>(x => x.UserName.Equals(UserSession.User.Username))).Last();
|
||||
if (IsNew)
|
||||
{
|
||||
var loggedUser = (await ManageData.GetTable<StbUser>(x => x.UserName.Equals(UserSession.User.Username))).Last();
|
||||
|
||||
ContactModel.IsContact = false;
|
||||
ContactModel.Nazione = "IT";
|
||||
ContactModel.CodVage = loggedUser.UserCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContactModel = OriginalModel!.Clone();
|
||||
}
|
||||
ContactModel.IsContact = false;
|
||||
ContactModel.Nazione = "IT";
|
||||
ContactModel.CodVage = loggedUser.UserCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContactModel = OriginalModel!.Clone();
|
||||
}
|
||||
|
||||
Users = await ManageData.GetTable<StbUser>(x => x.KeyGroup == 5);
|
||||
Nazioni = await ManageData.GetTable<Nazioni>();
|
||||
VtbTipi = await ManageData.GetTable<VtbTipi>();
|
||||
Users = await ManageData.GetTable<StbUser>(x => x.KeyGroup == 5);
|
||||
Nazioni = await ManageData.GetTable<Nazioni>();
|
||||
VtbTipi = await ManageData.GetTable<VtbTipi>();
|
||||
});
|
||||
}
|
||||
|
||||
private void OnAfterChangeValue()
|
||||
@@ -562,9 +576,83 @@
|
||||
|
||||
private async Task ConvertProspectToContact()
|
||||
{
|
||||
await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
var response = await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO
|
||||
{
|
||||
CodPpro = ContactModel.CodContact
|
||||
});
|
||||
|
||||
await ManageData.DeleteProspect(ContactModel.CodContact);
|
||||
|
||||
if (response.AnagClie != null)
|
||||
await ManageData.InsertOrUpdate(response.AnagClie);
|
||||
|
||||
if (response.VtbCliePersRif != null)
|
||||
await ManageData.InsertOrUpdate(response.VtbCliePersRif);
|
||||
|
||||
if (response.VtbDest != null)
|
||||
await ManageData.InsertOrUpdate(response.VtbDest);
|
||||
|
||||
SuccessAnimation = true;
|
||||
StateHasChanged();
|
||||
|
||||
await Task.Delay(1250);
|
||||
MudDialog.Close(response.AnagClie);
|
||||
}
|
||||
|
||||
private async Task OnUserSelectedAfter()
|
||||
{
|
||||
ContactModel.CodVage = SelectedUser?.UserCode;
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private Task<IEnumerable<StbUser>> SearchUtentiAsync(string value, CancellationToken token)
|
||||
{
|
||||
IEnumerable<StbUser> list;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
list = Users.OrderBy(u => u.FullName).Take(50);
|
||||
}
|
||||
else
|
||||
{
|
||||
list = Users
|
||||
.Where(x => x.UserName.Contains(value, StringComparison.OrdinalIgnoreCase)
|
||||
|| x.FullName.Contains(value, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(u => u.FullName)
|
||||
.Take(50);
|
||||
}
|
||||
|
||||
return Task.FromResult(token.IsCancellationRequested ? [] : list);
|
||||
}
|
||||
|
||||
private async Task OnTypeSelectedAfter()
|
||||
{
|
||||
ContactModel.CodVtip = SelectedType?.CodVtip;
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private Task<IEnumerable<VtbTipi>> SearchTypeAsync(string value, CancellationToken token)
|
||||
{
|
||||
IEnumerable<VtbTipi> list = [];
|
||||
|
||||
if (VtbTipi == null) return Task.FromResult(token.IsCancellationRequested ? [] : list);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
list = VtbTipi.OrderBy(u => u.CodVtip);
|
||||
}
|
||||
else
|
||||
{
|
||||
list = VtbTipi
|
||||
.Where(x => x.CodVtip.Contains(value, StringComparison.OrdinalIgnoreCase)
|
||||
|| x.Descrizione.Contains(value, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(u => u.CodVtip)
|
||||
.Take(50);
|
||||
}
|
||||
|
||||
return Task.FromResult(token.IsCancellationRequested ? [] : list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user