2020-05-30 01:46:41 +08:00
|
|
|
@namespace AntDesign
|
|
|
|
@inherits AntDomComponentBase
|
|
|
|
@typeparam TItem
|
|
|
|
|
2020-06-02 19:15:15 +08:00
|
|
|
<div class="ant-table-wrapper">
|
|
|
|
<Spin Spinning="Loading">
|
2020-06-16 14:44:21 +08:00
|
|
|
@if (!HidePagination && PaginationPosition.Contains("top"))
|
2020-06-02 19:15:15 +08:00
|
|
|
{
|
2020-06-03 00:22:10 +08:00
|
|
|
<Pagination Class="@PaginationClass"
|
|
|
|
Total="Total"
|
|
|
|
PageSize="PageSize"
|
|
|
|
Current="PageIndex"
|
|
|
|
OnPageIndexChange="HandlePageIndexChange"
|
|
|
|
OnPageSizeChange="HandlePageSizeChange" />
|
2020-06-02 19:15:15 +08:00
|
|
|
}
|
2020-06-05 16:06:23 +08:00
|
|
|
<CascadingValue Value="@this" TValue="ITable">
|
2020-06-19 23:06:33 +08:00
|
|
|
<div class="@ClassMapper.Class">
|
2020-06-29 15:52:28 +08:00
|
|
|
@if (@Title.IsT0 && !string.IsNullOrEmpty(Title.AsT0) || @Title.IsT1 && Title.AsT1 != null) {
|
|
|
|
<div class="ant-table-title">
|
|
|
|
@if(Title.IsT0) {@Title.AsT0} else {@Title.AsT1}
|
|
|
|
</div>
|
|
|
|
}
|
2020-06-05 16:06:23 +08:00
|
|
|
<div class="ant-table-container">
|
2020-06-19 23:06:33 +08:00
|
|
|
@if (ScrollY != null)
|
|
|
|
{
|
|
|
|
<div class="ant-table-header" style="overflow: hidden;">
|
|
|
|
<table style="table-layout: fixed;">
|
|
|
|
@colGroup(this)
|
|
|
|
@header(this)
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="ant-table-body" style="overflow-y: scroll; max-height: @ScrollY;">
|
|
|
|
<table style="table-layout: fixed;">
|
|
|
|
@colGroup(this)
|
|
|
|
<tbody class="ant-table-tbody">
|
|
|
|
<tr aria-hidden="true" class="ant-table-measure-row" style="height: 0px;">
|
|
|
|
@for (var i = 0; i < ColumnContext.Columns.Count; i++)
|
2020-06-02 19:15:15 +08:00
|
|
|
{
|
2020-06-19 23:06:33 +08:00
|
|
|
<td style="padding: 0px; border: 0px; height: 0px;"></td>
|
2020-06-02 19:15:15 +08:00
|
|
|
}
|
2020-06-03 00:22:10 +08:00
|
|
|
</tr>
|
2020-06-19 23:06:33 +08:00
|
|
|
@body(this)
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="ant-table-content">
|
|
|
|
<table style="table-layout: auto;">
|
|
|
|
@colGroup(this)
|
|
|
|
@header(this)
|
|
|
|
<tbody class="ant-table-tbody">
|
2020-06-29 15:52:28 +08:00
|
|
|
@body(this)
|
2020-06-19 23:06:33 +08:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
}
|
2020-06-02 19:15:15 +08:00
|
|
|
</div>
|
2020-06-29 15:52:28 +08:00
|
|
|
@if (@Footer.IsT0 && !string.IsNullOrEmpty(Footer.AsT0) || @Footer.IsT1 && Footer.AsT1 != null) {
|
|
|
|
<div class="ant-table-footer">
|
|
|
|
@if(Footer.IsT0) {@Footer.AsT0} else {@Footer.AsT1}
|
|
|
|
</div>
|
|
|
|
}
|
2020-05-30 01:46:41 +08:00
|
|
|
</div>
|
2020-06-05 16:06:23 +08:00
|
|
|
</CascadingValue>
|
2020-06-16 14:44:21 +08:00
|
|
|
@if (!HidePagination && PaginationPosition.Contains("bottom"))
|
2020-06-02 19:15:15 +08:00
|
|
|
{
|
2020-06-03 00:22:10 +08:00
|
|
|
<Pagination Class="@PaginationClass"
|
|
|
|
Total="Total"
|
|
|
|
PageSize="PageSize"
|
|
|
|
Current="PageIndex"
|
|
|
|
OnPageIndexChange="HandlePageIndexChange"
|
|
|
|
OnPageSizeChange="HandlePageSizeChange" />
|
2020-06-02 19:15:15 +08:00
|
|
|
}
|
|
|
|
</Spin>
|
2020-06-19 23:06:33 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
@code
|
|
|
|
{
|
|
|
|
RenderFragment<Table<TItem>> header = table =>
|
|
|
|
@<Template>
|
|
|
|
<thead class="ant-table-thead">
|
|
|
|
<tr>
|
|
|
|
<CascadingValue Name="IsHeader" Value="true">
|
|
|
|
<CascadingValue Value="@table.ColumnContext">
|
|
|
|
@if (_fieldModel != null)
|
|
|
|
{
|
|
|
|
@table.ChildContent(_fieldModel)
|
|
|
|
}
|
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>
|
|
|
|
@if (table.ScrollY != null)
|
|
|
|
{
|
|
|
|
<th class="ant-table-cell ant-table-cell-scrollbar"></th>
|
|
|
|
}
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</Template>;
|
|
|
|
|
|
|
|
RenderFragment<Table<TItem>> colGroup = table =>
|
|
|
|
@<Template>
|
|
|
|
<CascadingValue Name="IsColGroup" Value="true">
|
|
|
|
<colgroup>
|
|
|
|
@if (_fieldModel != null)
|
|
|
|
{
|
|
|
|
@table.ChildContent(Table<TItem>._fieldModel)
|
|
|
|
}
|
|
|
|
@if (table.ScrollY != null)
|
|
|
|
{
|
|
|
|
<col style="width: @(table.ScrollBarWidth)px; min-width: @(table.ScrollBarWidth)px;" />
|
|
|
|
}
|
|
|
|
</colgroup>
|
|
|
|
</CascadingValue>
|
|
|
|
</Template>;
|
|
|
|
|
|
|
|
RenderFragment<Table<TItem>> body = table =>
|
|
|
|
@<Template>
|
|
|
|
|
|
|
|
@if (table.ActualTotal <= 0)
|
|
|
|
{
|
|
|
|
<tr class="ant-table-placeholder">
|
|
|
|
<td colspan="6" class="ant-table-cell">
|
|
|
|
<Empty Simple />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
}
|
|
|
|
else if (table.ShowItems != null && table.ColumnContext.Columns.Count > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < table.ShowItems.Count(); i++)
|
|
|
|
{
|
|
|
|
var rowIndex = table.PageSize * (table.PageIndex - 1) + i + 1;
|
|
|
|
var data = table.ShowItems.ElementAt(i);
|
|
|
|
var @checked = table._headerSelection?.RowSelections.ElementAtOrDefault(i)?.Checked ?? false;
|
|
|
|
<CascadingValue Value="@rowIndex" Name="RowIndex">
|
|
|
|
<CascadingValue Value="table.ColumnContext">
|
|
|
|
<tr data-row-id="@rowIndex" class="ant-table-row ant-table-row-level-0 @(@checked ? "ant-table-row-selected" : "")">
|
|
|
|
@table.ChildContent(data)
|
|
|
|
</tr>
|
|
|
|
</CascadingValue>
|
|
|
|
</CascadingValue>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</Template>;
|
|
|
|
}
|