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-04-28 15:56:56 +08:00
|
|
|
|
@using System.Globalization;
|
|
|
|
|
|
|
|
|
|
@{
|
2020-06-16 12:31:46 +08:00
|
|
|
|
var calendar = this.DatePicker.CultureInfo.Calendar;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
|
|
|
|
DateTime monthFirstDayDate = new DateTime(PickerValue.Year, PickerValue.Month, 1, 0, 0, 0);
|
|
|
|
|
DayOfWeek monthFirstDayOfWeek = calendar.GetDayOfWeek(monthFirstDayDate);
|
|
|
|
|
|
2020-06-16 12:31:46 +08:00
|
|
|
|
int diffDay = (int)this.DatePicker.CultureInfo.DateTimeFormat.FirstDayOfWeek - (int)monthFirstDayOfWeek;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
DateTime startDate = monthFirstDayDate.AddDays(diffDay);
|
2020-06-16 12:31:46 +08:00
|
|
|
|
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<div class='@($"{PrefixCls}-datetime-panel")'>
|
|
|
|
|
@if (IsShowTime)
|
2020-05-10 17:33:09 +08:00
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
<DatePickerTemplate TValue="TValue"
|
2020-06-03 10:24:16 +08:00
|
|
|
|
@attributes="GetAttritubes()"
|
2020-06-01 14:09:28 +08:00
|
|
|
|
MaxRow="6"
|
|
|
|
|
MaxCol="7"
|
|
|
|
|
ViewStartDate="startDate"
|
2020-06-03 10:24:16 +08:00
|
|
|
|
ShowFooter="@ShowToday"
|
2020-06-01 14:09:28 +08:00
|
|
|
|
IsInView="date => DateHelper.IsSameMonth(date, PickerValue)"
|
|
|
|
|
IsToday="date => DateHelper.IsSameDay(date, DatePicker.CurrentDate)"
|
|
|
|
|
IsSelected="date => DateHelper.IsSameDay(date, Value)"
|
2020-06-16 12:31:46 +08:00
|
|
|
|
GetColTitle='date => date.ToString(this.DatePicker.CultureInfo.GetDateLocale().DateFormat, this.DatePicker.CultureInfo)'
|
2020-06-01 14:09:28 +08:00
|
|
|
|
OnValueSelect="OnSelectDate"
|
|
|
|
|
GetNextColValue="date => date.AddDays(1)">
|
2020-05-10 17:33:09 +08:00
|
|
|
|
<RenderPickerHeader>
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<DatePickerHeader TValue="TValue"
|
|
|
|
|
@attributes="GetAttritubes()" />
|
2020-05-10 17:33:09 +08:00
|
|
|
|
</RenderPickerHeader>
|
|
|
|
|
<RenderTableHeader>
|
|
|
|
|
<tr>
|
2020-06-16 12:31:46 +08:00
|
|
|
|
@foreach(string weekDay in this.DatePicker.CultureInfo.GetDateLocale().ShortWeekDays)
|
|
|
|
|
{
|
|
|
|
|
<th>@weekDay</th>
|
|
|
|
|
}
|
2020-05-10 17:33:09 +08:00
|
|
|
|
</tr>
|
|
|
|
|
</RenderTableHeader>
|
|
|
|
|
<RenderColValue Context="currentColDate">
|
|
|
|
|
@currentColDate.Day
|
|
|
|
|
</RenderColValue>
|
2020-05-18 14:46:42 +08:00
|
|
|
|
</DatePickerTemplate>
|
2020-05-10 17:33:09 +08:00
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@{
|
|
|
|
|
var startTime = new DateTime(2020, 1, 1, 0, 0, 0);
|
2020-06-03 10:24:16 +08:00
|
|
|
|
var timeFormat = ShowTimeFormat;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
if (Picker == DatePickerType.Time && !string.IsNullOrEmpty(Format))
|
2020-05-10 17:33:09 +08:00
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
timeFormat = Format;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
2020-05-10 17:33:09 +08:00
|
|
|
|
|
2020-05-18 14:46:42 +08:00
|
|
|
|
DatePickerDisabledTime disabledTime = GetDisabledTime();
|
2020-05-10 17:33:09 +08:00
|
|
|
|
}
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<div class="@(PrefixCls)-time-panel">
|
|
|
|
|
@if(Picker == DatePickerType.Date)
|
|
|
|
|
{
|
|
|
|
|
<div class="@(PrefixCls)-header">
|
|
|
|
|
<div class="@(PrefixCls)-header-view">
|
|
|
|
|
@Value.ToString(timeFormat) <br />
|
|
|
|
|
</div>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
</div>
|
2020-06-03 10:24:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<div class="@(PrefixCls)-content">
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@if (timeFormat.ToLower().Contains("hh"))
|
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<ul class="@(PrefixCls)-time-panel-column" style="position: relative;">
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@for (int hour = 0; hour < 24; hour++)
|
|
|
|
|
{
|
|
|
|
|
var viewTime = startTime;
|
|
|
|
|
bool disabled = disabledTime._disabledHours.Contains(hour);
|
2020-06-03 10:24:16 +08:00
|
|
|
|
string isSelectedCls = viewTime.Hour == Value.Hour ? $"{PrefixCls}-time-panel-cell-selected" : "";
|
|
|
|
|
string disabledCls = disabled ? $"{PrefixCls}-time-panel-cell-disabled" : "";
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<li class="@(PrefixCls)-time-panel-cell @isSelectedCls @disabledCls">
|
|
|
|
|
<div class="@(PrefixCls)-time-panel-cell-inner"
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@onclick="e => { if (!disabled) OnSelectHour(viewTime); }">
|
|
|
|
|
@hour
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-05-10 17:33:09 +08:00
|
|
|
|
startTime = startTime.AddHours(1);
|
|
|
|
|
}
|
|
|
|
|
</ul>
|
|
|
|
|
}
|
|
|
|
|
@if (timeFormat.ToLower().Contains("mm"))
|
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<ul class="@(PrefixCls)-time-panel-column" style="position: relative;">
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@for (int minute = 0; minute < 60; minute++)
|
|
|
|
|
{
|
|
|
|
|
var viewTime = startTime;
|
|
|
|
|
bool disabled = disabledTime._disabledMinutes.Contains(minute);
|
2020-06-03 10:24:16 +08:00
|
|
|
|
string isSelectedCls = viewTime.Minute == Value.Minute ? $"{PrefixCls}-time-panel-cell-selected" : "";
|
|
|
|
|
string disabledCls = disabled ? $"{PrefixCls}-time-panel-cell-disabled" : "";
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<li class="@(PrefixCls)-time-panel-cell @isSelectedCls @disabledCls">
|
|
|
|
|
<div class="@(PrefixCls)-time-panel-cell-inner"
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@onclick="e => { if (!disabled) OnSelectMinute(viewTime); }">
|
|
|
|
|
@minute
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-05-10 17:33:09 +08:00
|
|
|
|
startTime = startTime.AddMinutes(1);
|
|
|
|
|
}
|
|
|
|
|
</ul>
|
|
|
|
|
}
|
|
|
|
|
@if (timeFormat.ToLower().Contains("ss"))
|
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<ul class="@(PrefixCls)-time-panel-column" style="position: relative;">
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@for (int second = 0; second < 60; second++)
|
|
|
|
|
{
|
|
|
|
|
var viewTime = startTime;
|
|
|
|
|
bool disabled = disabledTime._disabledSeconds.Contains(second);
|
2020-06-03 10:24:16 +08:00
|
|
|
|
string isSelectedCls = viewTime.Second == Value.Second ? $"{PrefixCls}-time-panel-cell-selected" : "";
|
|
|
|
|
string disabledCls = disabled ? $"{PrefixCls}-time-panel-cell-disabled" : "";
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<li class="@(PrefixCls)-time-panel-cell @isSelectedCls @disabledCls">
|
|
|
|
|
<div class="@(PrefixCls)-time-panel-cell-inner"
|
2020-05-10 17:33:09 +08:00
|
|
|
|
@onclick="e => { if (!disabled) OnSelectSecond(viewTime); }">
|
|
|
|
|
@second
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-05-10 17:33:09 +08:00
|
|
|
|
startTime = startTime.AddSeconds(1);
|
|
|
|
|
}
|
|
|
|
|
</ul>
|
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-05-10 17:33:09 +08:00
|
|
|
|
</div>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
@if (RenderExtraFooter != null)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<div class="@(PrefixCls)-footer">
|
|
|
|
|
<div class="@(PrefixCls)-footer-extra">
|
|
|
|
|
@RenderExtraFooter
|
2020-04-28 15:56:56 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<div class="@(PrefixCls)-footer">
|
|
|
|
|
<ul class="@(PrefixCls)-ranges">
|
|
|
|
|
<li class="@(PrefixCls)-now">
|
|
|
|
|
<a class="@(PrefixCls)-now-btn"
|
|
|
|
|
@onclick="e => { OnSelectTime(DateTime.Now); Close(); }">
|
2020-06-16 12:31:46 +08:00
|
|
|
|
@this.DatePicker.CultureInfo.GetDateLocale().Now
|
2020-04-28 15:56:56 +08:00
|
|
|
|
</a>
|
|
|
|
|
</li>
|
2020-06-03 10:24:16 +08:00
|
|
|
|
<li class="@(PrefixCls)-ok">
|
2020-05-29 12:55:15 +08:00
|
|
|
|
<Button Type="@ButtonType.Primary"
|
2020-05-18 14:46:42 +08:00
|
|
|
|
OnClick="e => DatePicker.Close()">
|
2020-06-16 12:31:46 +08:00
|
|
|
|
@this.DatePicker.CultureInfo.GetDateLocale().Ok
|
2020-05-29 12:55:15 +08:00
|
|
|
|
</Button>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|