Completata gestione allegati e riepilogo commessa
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
@page "/commessa/{CodJcom}"
|
||||
@page "/commessa/{CodJcom}/{RagSoc}"
|
||||
@attribute [Authorize]
|
||||
@using AutoMapper
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.JobProgress
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@inject JobSteps JobSteps
|
||||
@inject IManageDataService ManageData
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IMapper Mapper
|
||||
|
||||
<HeaderLayout Title="@CodJcom" ShowProfile="false" Back="true" BackTo="Indietro"/>
|
||||
|
||||
@@ -62,8 +66,48 @@ else
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="tab-content">Contenuto 2</div>
|
||||
<div class="tab-content">Contenuto 3</div>
|
||||
<div class="tab-content">
|
||||
@if (ActivityIsLoading)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (ActivityList is { Count: > 0 })
|
||||
{
|
||||
<div class="contentFlex">
|
||||
<Virtualize Items="ActivityList" Context="activity">
|
||||
<ActivityCard Activity="activity" />
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna attività trovata" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
@if (AttachedIsLoading)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (ListAttached != null)
|
||||
{
|
||||
<div class="contentFlex">
|
||||
<Virtualize Items="ListAttached" Context="attached">
|
||||
<AttachCard Attached="attached" />
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NoDataAvailable Text="Nessun allegato presente" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -74,9 +118,13 @@ else
|
||||
[Parameter] public string RagSoc { get; set; } = "";
|
||||
|
||||
private List<CRMJobStepDTO>? Steps { get; set; }
|
||||
private List<ActivityDTO> ActivityList { get; set; } = [];
|
||||
private List<CRMAttachedResponseDTO>? ListAttached { get; set; }
|
||||
private JtbComt? CommessaModel { get; set; }
|
||||
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool ActivityIsLoading { get; set; } = true;
|
||||
private bool AttachedIsLoading { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -88,8 +136,34 @@ else
|
||||
CommessaModel = (await ManageData.GetTable<JtbComt>(x => x.CodJcom.Equals(CodJcom))).LastOrDefault();
|
||||
Steps = JobSteps.Steps;
|
||||
|
||||
_ = LoadActivity();
|
||||
_ = LoadAttached();
|
||||
|
||||
IsLoading = false;
|
||||
}
|
||||
|
||||
private async Task LoadActivity()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom });
|
||||
ActivityList = Mapper.Map<List<ActivityDTO>>(activities);
|
||||
});
|
||||
|
||||
ActivityIsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task LoadAttached()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
ListAttached = await IntegryApiService.RetrieveAttached(CodJcom);
|
||||
});
|
||||
|
||||
AttachedIsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,21 @@
|
||||
padding: .5rem;
|
||||
}
|
||||
|
||||
.contentFlex {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.tab-content::-webkit-scrollbar { width: 6px; }
|
||||
|
||||
.tab-content::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.contentFlex ::deep > div:first-child:not(.activity-card) { display: none; }
|
||||
|
||||
#tab1:checked ~ .tab-container .tab-content:nth-child(1),
|
||||
#tab2:checked ~ .tab-container .tab-content:nth-child(2),
|
||||
#tab3:checked ~ .tab-container .tab-content:nth-child(3) { display: block; }
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IAttachedService AttachedService
|
||||
|
||||
<div @onclick="OpenAttached" class="activity-card">
|
||||
<div class="activity-left-section">
|
||||
<div class="activity-body-section">
|
||||
<div class="title-section">
|
||||
<MudText Class="activity-title" Typo="Typo.body1" HtmlTag="h3">
|
||||
@(Attached.Description.IsNullOrEmpty() ? Attached.FileName : Attached.Description)
|
||||
</MudText>
|
||||
<div class="activity-hours-section">
|
||||
<span class="activity-hours">@($"{Attached.DateAttached:g}")</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="activity-info-section">
|
||||
@if (Attached.IsActivity)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Primary" Variant="Variant.Outlined" Icon="@IconConstants.Chip.Tag" Size="Size.Small">
|
||||
@Attached.RefAttached
|
||||
</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Warning" Variant="Variant.Outlined" Icon="@IconConstants.Chip.FileTextLine" Size="Size.Small">
|
||||
@Attached.RefAttached
|
||||
</MudChip>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public CRMAttachedResponseDTO Attached { get; set; } = new();
|
||||
|
||||
private async Task OpenAttached()
|
||||
{
|
||||
var bytes = await IntegryApiService.DownloadFileFromRefUuid(Attached.RefUuid, Attached.FileName);
|
||||
await AttachedService.OpenFile(bytes, Attached.FileName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
.activity-card {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: .5rem .5rem;
|
||||
border-radius: 12px;
|
||||
line-height: normal;
|
||||
box-shadow: var(--custom-box-shadow);
|
||||
}
|
||||
|
||||
.activity-card.memo { border-left: 5px solid var(--mud-palette-info-darken); }
|
||||
|
||||
.activity-card.interna { border-left: 5px solid var(--mud-palette-success-darken); }
|
||||
|
||||
.activity-card.commessa { border-left: 5px solid var(--mud-palette-warning); }
|
||||
|
||||
.activity-left-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.title-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.activity-hours {
|
||||
color: var(--mud-palette-gray-darker);
|
||||
font-weight: 600;
|
||||
font-size: .8rem;
|
||||
}
|
||||
|
||||
.activity-hours-section ::deep .mud-chip { margin: 5px 0 0 !important; }
|
||||
|
||||
.activity-body-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.title-section ::deep > .activity-title {
|
||||
font-weight: 700 !important;
|
||||
margin: 0 !important;
|
||||
line-height: normal !important;
|
||||
color: var(--mud-palette-text-primary);
|
||||
}
|
||||
|
||||
.activity-body-section ::deep > .activity-subtitle {
|
||||
color: var(--mud-palette-gray-darker);
|
||||
margin: .2rem 0 !important;
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
||||
.activity-info-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: .25rem;
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IMessenger Messenger
|
||||
@inject IDialogService Dialog
|
||||
@inject IAttachedService AttachedService
|
||||
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@@ -142,7 +143,7 @@
|
||||
{
|
||||
foreach (var file in ActivityFileList)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default">
|
||||
<MudChip T="string" OnClick="() => OpenAttached(file.Id, file.FileName)" Color="Color.Default">
|
||||
@file.FileName
|
||||
</MudChip>
|
||||
}
|
||||
@@ -315,7 +316,7 @@
|
||||
|
||||
await ManageData.InsertOrUpdate(newActivity);
|
||||
|
||||
await SaveAttached(newActivity.ActivityId);
|
||||
await SaveAttached(newActivity.ActivityId!);
|
||||
|
||||
SuccessAnimation = true;
|
||||
StateHasChanged();
|
||||
@@ -353,7 +354,7 @@
|
||||
{
|
||||
if (attached.FileContent is not null && attached.Type != AttachedDTO.TypeAttached.Position)
|
||||
{
|
||||
await IntegryApiService.UploadFile(activityId, attached.FileContent, attached.Name);
|
||||
await IntegryApiService.UploadFile(activityId, attached.FileBytes, attached.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,12 +542,26 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OpenAttached(string idAttached, string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bytes = await IntegryApiService.DownloadFile(ActivityModel.ActivityId!, fileName);
|
||||
await AttachedService.OpenFile(bytes, fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire il file", Severity.Error);
|
||||
Console.WriteLine($"Errore durante l'apertura del file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenAttached(AttachedDTO attached)
|
||||
{
|
||||
if (attached is { FileContent: not null, MimeType: not null })
|
||||
{
|
||||
var fileViewerUrl = $"data:{attached.MimeType};base64,{Convert.ToBase64String(attached.FileContent)}";
|
||||
await ModalHelpers.OpenViewAttach(Dialog, fileViewerUrl);
|
||||
await AttachedService.OpenFile(attached.FileContent!, attached.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@if (!string.IsNullOrEmpty(FileViewerUrl))
|
||||
{
|
||||
<iframe src="@FileViewerUrl" style="width:100%; height:80vh; border:none;"></iframe>
|
||||
}
|
||||
</DialogContent>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
|
||||
|
||||
[Parameter] public string? FileViewerUrl { get; set; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
.content.attached {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding: 1rem;
|
||||
height: unset;
|
||||
}
|
||||
Reference in New Issue
Block a user