171 lines
4.1 KiB
C#
171 lines
4.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.MONO.Data.DbModels;
|
|
|
|
namespace MP.MONO.UI.Components
|
|
{
|
|
public partial class MaintTaskSched
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> reqChangeMode { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int _MaxRecord = 200;
|
|
|
|
private bool doSetup = false;
|
|
|
|
private List<PrevMaintTaskModel>? ListRecords = null;
|
|
|
|
// FARE!!! filtro macchina
|
|
private int MachineId = 1;
|
|
|
|
private List<PrevMaintTaskModel>? SearchRecords = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int _currPage { get; set; } = 1;
|
|
|
|
private int _numRecord { get; set; } = 10;
|
|
|
|
private int currPage
|
|
{
|
|
get => _currPage;
|
|
set
|
|
{
|
|
if (_currPage != value)
|
|
{
|
|
currPMTaskId = 0;
|
|
_currPage = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
private int currPMTaskId { get; set; } = 0;
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private string mainCssClass
|
|
{
|
|
get => currPMTaskId == 0 ? "px-2 flex-fill" : "px-2 flex-grow-0";
|
|
}
|
|
|
|
private int MaxRecord
|
|
{
|
|
get
|
|
{
|
|
return _MaxRecord;
|
|
}
|
|
set
|
|
{
|
|
if (_MaxRecord != value)
|
|
{
|
|
_MaxRecord = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
private int numRecord
|
|
{
|
|
get => _numRecord;
|
|
set
|
|
{
|
|
if (_numRecord != value)
|
|
{
|
|
currPMTaskId = 0;
|
|
_numRecord = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
if (SearchRecords != null)
|
|
{
|
|
answ = SearchRecords.Count;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Solleva evento cambio modo (Pending/Scheduled)
|
|
/// </summary>
|
|
private void ChangeMode()
|
|
{
|
|
reqChangeMode.InvokeAsync(true);
|
|
}
|
|
|
|
private string checkSel(int PMTaskId)
|
|
{
|
|
return PMTaskId == currPMTaskId ? "table-primary" : "";
|
|
}
|
|
|
|
private void ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
}
|
|
|
|
private void ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
await Task.Delay(1);
|
|
SearchRecords = await MMDataService.PrevMaintTaskGetFilt(MachineId, 0, MaxRecord);
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
|
|
private PrevMaintTaskModel selRecord { get; set; }
|
|
|
|
private async Task ShowDetail(PrevMaintTaskModel currRec)
|
|
{
|
|
selRecord = currRec;
|
|
if (currRec != null)
|
|
{
|
|
currPMTaskId = currRec.PMTaskId;
|
|
}
|
|
else {
|
|
currPMTaskId = 0;
|
|
}
|
|
//await ReloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |