2020-05-29 00:33:49 +08:00
|
|
|
|
@namespace AntDesign.Internal
|
2020-06-01 14:09:28 +08:00
|
|
|
|
@typeparam TValue
|
|
|
|
|
@inherits DatePickerPanelBase<TValue>
|
2020-07-05 00:06:34 +08:00
|
|
|
|
@using AntDesign
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2021-01-21 17:20:10 +08:00
|
|
|
|
<div class="@(PrefixCls)-@(Picker)-panel" @ref="Ref">
|
2020-06-03 10:24:16 +08:00
|
|
|
|
@if (IsShowHeader)
|
|
|
|
|
{
|
|
|
|
|
@RenderPickerHeader
|
|
|
|
|
}
|
|
|
|
|
<div class="@(PrefixCls)-body">
|
|
|
|
|
<table class="@(PrefixCls)-content">
|
2020-04-28 15:56:56 +08:00
|
|
|
|
<thead>
|
|
|
|
|
@RenderTableHeader
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
2021-05-07 15:31:13 +08:00
|
|
|
|
@{
|
2021-01-14 10:40:34 +08:00
|
|
|
|
var startDate = ViewStartDate;
|
|
|
|
|
bool shouldStopRender = false;
|
2021-05-07 15:31:13 +08:00
|
|
|
|
DateTime monthFirstDayDate = new DateTime(PickerValue.Year, PickerValue.Month, 1, 0, 0, 0);
|
|
|
|
|
bool firstWeekNotInMonth = ViewStartDate.AddDays(7).Equals(monthFirstDayDate);
|
2021-01-14 10:40:34 +08:00
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
@for (int row = 1; row <= MaxRow; row++)
|
|
|
|
|
{
|
2021-01-14 10:40:34 +08:00
|
|
|
|
if (shouldStopRender)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
var startColDate = startDate;
|
2021-01-14 10:40:34 +08:00
|
|
|
|
|
2021-06-27 09:53:01 +08:00
|
|
|
|
<tr class="@(GetRowClass?.Invoke(startColDate))"
|
|
|
|
|
@onclick="e => OnRowSelect?.Invoke(startColDate.CompareTo(monthFirstDayDate) < 0 && !firstWeekNotInMonth ? monthFirstDayDate: startColDate)">
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2021-06-27 09:53:01 +08:00
|
|
|
|
@RenderFirstCol?.Invoke(startColDate.CompareTo(monthFirstDayDate) < 0 && !firstWeekNotInMonth ? monthFirstDayDate : startColDate)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2021-06-27 09:53:01 +08:00
|
|
|
|
|
|
|
|
|
@for (int col = 1; col <= MaxCol; col++)
|
|
|
|
|
{
|
|
|
|
|
if (shouldStopRender)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2021-06-27 09:53:01 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-01-14 10:40:34 +08:00
|
|
|
|
|
2021-06-27 09:53:01 +08:00
|
|
|
|
if (Picker == DatePickerType.Date && row == 1 && col <= SkipDays)
|
|
|
|
|
{
|
|
|
|
|
<td>
|
|
|
|
|
</td>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-28 15:56:56 +08:00
|
|
|
|
var currentColDate = startDate;
|
|
|
|
|
|
2020-07-05 00:06:34 +08:00
|
|
|
|
string cellCls = GetCellCls(currentColDate);
|
|
|
|
|
string innerCellCls = GetInnerCellCls(currentColDate);
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
|
|
|
|
<td title="@GetColTitle?.Invoke(currentColDate)"
|
2020-07-05 00:06:34 +08:00
|
|
|
|
class="@cellCls"
|
|
|
|
|
@onmouseenter="e => DateOnMouseEnter(currentColDate)"
|
|
|
|
|
@onmouseleave="e => DateOnMouseLeave()">
|
|
|
|
|
<div class="@innerCellCls"
|
2021-06-28 11:28:18 +08:00
|
|
|
|
@onclick="e => OnValueSelect?.Invoke(currentColDate)" @onclick:stopPropagation="true">
|
2020-06-03 10:24:16 +08:00
|
|
|
|
@if (IsCalendar)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<div class="@(PrefixCls)-calendar-date-value">
|
|
|
|
|
@if (Picker == DatePickerType.Date && DateRender != null)
|
|
|
|
|
{
|
|
|
|
|
@(DateRender(currentColDate, DatePicker.CurrentDate))
|
|
|
|
|
}
|
|
|
|
|
else if (Picker == DatePickerType.Month && MonthCellRender != null)
|
|
|
|
|
{
|
|
|
|
|
@(MonthCellRender(currentColDate))
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@RenderColValue(currentColDate)
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="@(PrefixCls)-calendar-date-content">
|
|
|
|
|
@if (Picker == DatePickerType.Date && CalendarDateRender != null)
|
|
|
|
|
{
|
|
|
|
|
@(CalendarDateRender(currentColDate))
|
|
|
|
|
}
|
|
|
|
|
else if (Picker == DatePickerType.Month && CalendarMonthCellRender != null)
|
|
|
|
|
{
|
|
|
|
|
@(CalendarMonthCellRender(currentColDate))
|
|
|
|
|
}
|
|
|
|
|
</div>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
@if (Picker == DatePickerType.Date && DateRender != null)
|
|
|
|
|
{
|
|
|
|
|
@(DateRender(currentColDate, DatePicker.CurrentDate))
|
|
|
|
|
}
|
|
|
|
|
else if (Picker == DatePickerType.Month && MonthCellRender != null)
|
|
|
|
|
{
|
|
|
|
|
@(MonthCellRender(currentColDate))
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@RenderColValue(currentColDate)
|
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
startDate = @GetNextColValue(currentColDate);
|
2021-01-14 10:40:34 +08:00
|
|
|
|
|
|
|
|
|
if (ShouldStopRenderDate(currentColDate, startDate))
|
|
|
|
|
{
|
|
|
|
|
shouldStopRender = true;
|
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-27 09:53:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@{ var endColDate = startDate;}
|
|
|
|
|
@RenderLastCol?.Invoke(endColDate)
|
|
|
|
|
</tr>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
2021-01-14 10:40:34 +08:00
|
|
|
|
</div>
|