Form persone di riferimento e clienti
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Components.Layout.Overlay
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@inject IManageDataService ManageData
|
||||
@inject INetworkService NetworkService
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IDialogService Dialog
|
||||
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@@ -12,8 +14,8 @@
|
||||
|
||||
<div class="content">
|
||||
<div class="input-card">
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Placeholder="Azienda"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
@@ -23,87 +25,34 @@
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="input-card">
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Placeholder="Partita IVA"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.PartIva"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue" />
|
||||
</div>
|
||||
|
||||
<div class="input-card">
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Indirizzo</span>
|
||||
<span class="disable-full-width">P. IVA</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Indirizzo"
|
||||
@bind-Value="ContactModel.PartIva"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">CAP</span>
|
||||
<span class="disable-full-width">Cod. Fiscale</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Cap"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Città</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Citta"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Provincia</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Prov"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Nazione</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Nazione"
|
||||
@bind-Value="ContactModel.CodFisc"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
@@ -114,24 +63,172 @@
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Tipo cliente</span>
|
||||
|
||||
@* @if (Commesse.IsNullOrEmpty())
|
||||
@if (VtbTipi.IsNullOrEmpty())
|
||||
{
|
||||
<span class="warning-text">Nessuna commessa presente</span>
|
||||
<span class="warning-text">Nessun tipo cliente trovato</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || Commesse.IsNullOrEmpty())" T="string?" Variant="Variant.Text" @bind-Value="UserModel.CodJcom" @bind-Value:after="OnCommessaChanged" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||
@foreach (var com in Commesse)
|
||||
<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="@com.CodJcom">@($"{com.CodJcom} - {com.Descrizione}")</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Value="@tipo.CodVtip">@($"{tipo.CodVtip} - {tipo.Descrizione}")</MudSelectItemExtended>
|
||||
}
|
||||
</MudSelectExtended>
|
||||
} *@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="input-card">
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Indirizzo</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
@bind-Value="ContactModel.Indirizzo"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">CAP</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Cap"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Città</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Citta"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Provincia</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Prov"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Nazione</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Nazione"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-card">
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">PEC</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.EMailPec"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">E-Mail</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.EMail"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Telefono</span>
|
||||
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="ContactModel.Telefono"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
DebounceInterval="500"
|
||||
OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (IsNew)
|
||||
{
|
||||
<div class="container-chip-persrif">
|
||||
@if (!PersRifList.IsNullOrEmpty())
|
||||
{
|
||||
foreach (var item in PersRifList!.Select((p, index) => new { p, index }))
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default" OnClick="() => OpenPersRifForm(item.index, item.p)" OnClose="() => OnRemovePersRif(item.index)">
|
||||
@item.p.PersonaRif
|
||||
</MudChip>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="container-button">
|
||||
<MudButton Class="button-settings gray-icon"
|
||||
FullWidth="true"
|
||||
@@ -155,6 +252,9 @@
|
||||
[Parameter] public ContactDTO? OriginalModel { get; set; }
|
||||
private ContactDTO ContactModel { get; set; } = new();
|
||||
|
||||
private List<VtbTipi>? VtbTipi { get; set; }
|
||||
private List<PersRifDTO>? PersRifList { get; set; }
|
||||
|
||||
private bool IsNew => OriginalModel is null;
|
||||
private bool IsView => !NetworkService.IsNetworkAvailable();
|
||||
|
||||
@@ -168,13 +268,25 @@
|
||||
{
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
|
||||
_ = LoadData();
|
||||
await LoadData();
|
||||
|
||||
LabelSave = IsNew ? "Aggiungi" : null;
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
var requestDto = new CRMCreateContactRequestDTO
|
||||
{
|
||||
TipoAnag = ContactModel.IsContact ? "C" : "P",
|
||||
Cliente = ContactModel,
|
||||
PersRif = PersRifList
|
||||
};
|
||||
|
||||
await IntegryApiService.SaveContact(requestDto);
|
||||
|
||||
SuccessAnimation = true;
|
||||
StateHasChanged();
|
||||
|
||||
@@ -185,8 +297,16 @@
|
||||
|
||||
private async Task LoadData()
|
||||
{
|
||||
if (!IsNew)
|
||||
if (IsNew)
|
||||
{
|
||||
ContactModel.IsContact = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContactModel = OriginalModel!.Clone();
|
||||
}
|
||||
|
||||
VtbTipi = await ManageData.GetTable<VtbTipi>();
|
||||
}
|
||||
|
||||
private void OnAfterChangeValue()
|
||||
@@ -197,8 +317,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void NewPersRif()
|
||||
{
|
||||
private Task NewPersRif() => OpenPersRifForm(null, null);
|
||||
|
||||
private async Task OpenPersRifForm(int? index, PersRifDTO? persRif)
|
||||
{
|
||||
var result = await ModalHelpers.OpenPersRifForm(Dialog, persRif);
|
||||
|
||||
if (result is { Canceled: false, Data: not null } && result.Data.GetType() == typeof(PersRifDTO))
|
||||
{
|
||||
if (index != null)
|
||||
OnRemovePersRif(index.Value);
|
||||
|
||||
PersRifList ??= [];
|
||||
|
||||
PersRifList.Add((PersRifDTO)result.Data);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRemovePersRif(int index)
|
||||
{
|
||||
if (PersRifList is null || index < 0 || index >= PersRifList.Count)
|
||||
return;
|
||||
|
||||
PersRifList.RemoveAt(index);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,3 +2,8 @@
|
||||
background: var(--mud-palette-background-gray) !important;
|
||||
box-shadow: unset;
|
||||
}
|
||||
|
||||
.container-chip-persrif {
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
<HeaderLayout ShowProfile="false" Cancel="true" OnCancel="() => MudDialog.Cancel()" LabelSave="@LabelSave" OnSave="Save" Title="@(IsNew ? "Nuovo" : $"{PersRifModel.CodPersRif}")" />
|
||||
<HeaderLayout ShowProfile="false" Cancel="true" OnCancel="() => MudDialog.Cancel()" LabelSave="@LabelSave" OnSave="Save" Title="@(IsNew ? "Nuovo" : "Persona di riferimento")" />
|
||||
|
||||
<div class="content">
|
||||
<div class="input-card">
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Placeholder="Persona di riferimento"
|
||||
Placeholder="Cognome e Nome"
|
||||
Variant="Variant.Text"
|
||||
Lines="1"
|
||||
@bind-Value="PersRifModel.PersonaRif"
|
||||
@@ -42,6 +42,8 @@
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="PersRifModel.EMail"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
@@ -57,6 +59,8 @@
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="PersRifModel.Fax"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
@@ -72,6 +76,8 @@
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="PersRifModel.NumCellulare"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
@@ -87,6 +93,8 @@
|
||||
<MudTextField ReadOnly="IsView"
|
||||
T="string?"
|
||||
Variant="Variant.Text"
|
||||
FullWidth="true"
|
||||
Class="customIcon-select"
|
||||
Lines="1"
|
||||
@bind-Value="PersRifModel.Telefono"
|
||||
@bind-Value:after="OnAfterChangeValue"
|
||||
@@ -126,12 +134,15 @@
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
SuccessAnimation = true;
|
||||
StateHasChanged();
|
||||
|
||||
await Task.Delay(1250);
|
||||
|
||||
MudDialog.Close();
|
||||
MudDialog.Close(PersRifModel);
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
@@ -147,9 +158,4 @@
|
||||
LabelSave = !OriginalModel.Equals(PersRifModel) ? "Aggiorna" : null;
|
||||
}
|
||||
}
|
||||
|
||||
private void NewPersRif()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user