[성현모] Tra Overview 기능, 페이지 추가
This commit is contained in:
181
Projects/WebClient/Web.Tra/Components/Module/TraGrid.razor
Normal file
181
Projects/WebClient/Web.Tra/Components/Module/TraGrid.razor
Normal file
@ -0,0 +1,181 @@
|
||||
@typeparam TDataModel where TDataModel : IDataModel
|
||||
|
||||
@inject ContextMenuService ContextMenuService
|
||||
|
||||
<RadzenDataGrid TItem="TDataModel" Data="@DataList" AllowPaging PageSize="100"
|
||||
AllowFiltering FilterMode="FilterMode.Advanced" CellRender="@CellRender"
|
||||
SelectionMode="DataGridSelectionMode.Single" @bind-Value="@SelectedRow"
|
||||
CellContextMenu="@OnCellContextMenu" RowSelect="@SelectRow">
|
||||
<Columns>
|
||||
|
||||
@if (VisibleRowNo == true)
|
||||
{
|
||||
<RadzenDataGridColumn Title="No.">
|
||||
<Template>
|
||||
@(DataList.ToList().IndexOf(context) + 1)
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
}
|
||||
|
||||
@foreach (var col in typeof(TDataModel).GetProperties())
|
||||
{
|
||||
if (col.Name.ToLower().Equals("rn") || col.Name.ToLower().Equals("stepversion"))
|
||||
continue;
|
||||
|
||||
if (col.Name.ToLower().Equals("testdate"))
|
||||
{
|
||||
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
||||
<Template>
|
||||
@Convert.ToDateTime(col.GetValue(context)).ToString("yyyy-MM-dd")
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
}
|
||||
else if (col.Name.ToLower().Equals("ok"))
|
||||
{
|
||||
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
||||
<Template>
|
||||
<RadzenText Style="color: lime;">
|
||||
@col.GetValue(context)
|
||||
</RadzenText>
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
}
|
||||
else if (col.Name.ToLower().Equals("ng"))
|
||||
{
|
||||
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
||||
<Template>
|
||||
<RadzenText Style="color:red;">
|
||||
@col.GetValue(context)
|
||||
</RadzenText>
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
|
||||
</RadzenDataGridColumn>
|
||||
}
|
||||
}
|
||||
</Columns>
|
||||
</RadzenDataGrid>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public IEnumerable<TDataModel> DataList { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<TDataModel> OnSelectRow { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback OnClickContextMenu { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool VisibleRowNo { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool HostColumnMerge { get; set; }
|
||||
|
||||
private IList<TDataModel> SelectedRow;
|
||||
|
||||
private void CellRender(DataGridCellRenderEventArgs<TDataModel> args)
|
||||
{
|
||||
if (args.Column.Property == null)
|
||||
return;
|
||||
|
||||
//testdate 컬럼일때 날짜 병합
|
||||
if (args.Column.Property.ToLower().Equals("testdate"))
|
||||
{
|
||||
var properties = typeof(TDataModel).GetProperties().ToList();
|
||||
|
||||
var testDate = properties.Find(x => x.Name.ToLower() == "testdate");
|
||||
var host = properties.Find(x => x.Name.ToLower() == "host");
|
||||
var section = properties.Find(x => x.Name.ToLower() == "section");
|
||||
|
||||
if (testDate != null && host != null && section != null)
|
||||
{
|
||||
var rowTestDate = testDate.GetValue(args.Data);
|
||||
var rowHost = host.GetValue(args.Data);
|
||||
var rowSection = section.GetValue(args.Data);
|
||||
|
||||
var data = DataList.First(x => (DateTime?)testDate.GetValue(x) == (DateTime?)rowTestDate);
|
||||
if (data != null)
|
||||
{
|
||||
var dataTestDate = testDate.GetValue(data);
|
||||
var dataHost = host.GetValue(data);
|
||||
var dataSection = section.GetValue(data);
|
||||
|
||||
if (rowHost == dataHost && rowSection == dataSection)
|
||||
{
|
||||
int rowCount = DataList.Count(x => (DateTime?)testDate.GetValue(x) == (DateTime?)rowTestDate);
|
||||
|
||||
args.Attributes.Add("rowspan", rowCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//host merge 옵션
|
||||
if (HostColumnMerge == true)
|
||||
{
|
||||
if (args.Column.Property.ToLower().Equals("host"))
|
||||
{
|
||||
var properties = typeof(TDataModel).GetProperties().ToList();
|
||||
|
||||
var testDate = properties.Find(x => x.Name.ToLower() == "testdate");
|
||||
var host = properties.Find(x => x.Name.ToLower() == "host");
|
||||
var section = properties.Find(x => x.Name.ToLower() == "section");
|
||||
|
||||
if (testDate != null && host != null && section != null)
|
||||
{
|
||||
var rowTestDate = testDate.GetValue(args.Data);
|
||||
var rowHost = host.GetValue(args.Data);
|
||||
var rowSection = section.GetValue(args.Data);
|
||||
|
||||
var data = DataList.First(x => host.GetValue(x).ToString() == rowHost.ToString());
|
||||
if (data != null)
|
||||
{
|
||||
var dataTestDate = testDate.GetValue(data);
|
||||
var dataHost = host.GetValue(data);
|
||||
var dataSection = section.GetValue(data);
|
||||
|
||||
if (rowHost == dataHost && rowSection == dataSection)
|
||||
{
|
||||
int rowCount = DataList.Count(x => host.GetValue(x).ToString() == rowHost.ToString());
|
||||
|
||||
args.Attributes.Add("rowspan", rowCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnCellContextMenu(DataGridCellMouseEventArgs<TDataModel> args)
|
||||
{
|
||||
SelectedRow = new List<TDataModel>() { args.Data };
|
||||
|
||||
ContextMenuService.Open(args,
|
||||
new List<ContextMenuItem> {
|
||||
new ContextMenuItem(){ Text = "Overview", Value = 1, Icon = "home" },
|
||||
new ContextMenuItem(){ Text = "Detail Overview", Value =2 , Icon = "assessment" },
|
||||
new ContextMenuItem(){ Text = "Test History", Value = 3, Icon = "description" },
|
||||
new ContextMenuItem(){ Text = "Test Summary", Value = 4, Icon = "assignment_turned_in" },
|
||||
new ContextMenuItem(){ Text = "Detail Data", Value = 5, Icon = "list" },
|
||||
new ContextMenuItem(){ Text = "Test-Error/Extended Search", Value = 6, Icon = "search" },
|
||||
},
|
||||
(e) =>
|
||||
{
|
||||
ContextMenuService.Close();
|
||||
OnClickContextMenu.InvokeAsync();
|
||||
}
|
||||
);
|
||||
|
||||
await OnSelectRow.InvokeAsync(args.Data);
|
||||
}
|
||||
|
||||
private async Task SelectRow(TDataModel data)
|
||||
{
|
||||
await OnSelectRow.InvokeAsync(data);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user