2020-04-28 15:56:56 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-06-03 10:24:16 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign.Internal
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
public partial class DatePickerDatetimePanel<TValue> : DatePickerPanelBase<TValue>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-03 10:24:16 +08:00
|
|
|
|
[Parameter]
|
|
|
|
|
public bool ShowToday { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public bool IsShowTime { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string ShowTimeFormat { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Format { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public Func<DateTime, int[]> DisabledHours { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public Func<DateTime, int[]> DisabledMinutes { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public Func<DateTime, int[]> DisabledSeconds { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public Func<DateTime, DatePickerDisabledTime> DisabledTime { get; set; } = null;
|
|
|
|
|
|
2020-05-18 14:46:42 +08:00
|
|
|
|
private DatePickerDisabledTime GetDisabledTime()
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
|
|
|
|
List<int> disabledHours = new List<int>();
|
|
|
|
|
List<int> disabledMinutes = new List<int>();
|
|
|
|
|
List<int> disabledSeconds = new List<int>();
|
2021-05-07 15:31:13 +08:00
|
|
|
|
DatePickerDisabledTime userDisabledTime = null;
|
|
|
|
|
if (Value is not null)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2021-05-07 15:31:13 +08:00
|
|
|
|
if (DisabledHours is not null)
|
|
|
|
|
{
|
|
|
|
|
disabledHours.AddRange(DisabledHours(Value.Value));
|
|
|
|
|
}
|
|
|
|
|
if (DisabledMinutes is not null)
|
|
|
|
|
{
|
|
|
|
|
disabledMinutes.AddRange(DisabledMinutes(Value.Value));
|
|
|
|
|
}
|
|
|
|
|
if (DisabledSeconds is not null)
|
|
|
|
|
{
|
|
|
|
|
disabledSeconds.AddRange(DisabledSeconds(Value.Value));
|
|
|
|
|
}
|
|
|
|
|
userDisabledTime = DisabledTime?.Invoke(Value ?? DateTime.Now);
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userDisabledTime != null)
|
|
|
|
|
{
|
|
|
|
|
if (userDisabledTime._disabledHours != null)
|
|
|
|
|
{
|
|
|
|
|
disabledHours.AddRange(userDisabledTime._disabledHours);
|
|
|
|
|
}
|
|
|
|
|
if (userDisabledTime._disabledMinutes != null)
|
|
|
|
|
{
|
|
|
|
|
disabledMinutes.AddRange(userDisabledTime._disabledMinutes);
|
|
|
|
|
}
|
|
|
|
|
if (userDisabledTime._disabledSeconds != null)
|
|
|
|
|
{
|
|
|
|
|
disabledSeconds.AddRange(userDisabledTime._disabledSeconds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 14:46:42 +08:00
|
|
|
|
return new DatePickerDisabledTime(disabledHours.ToArray(), disabledMinutes.ToArray(), disabledSeconds.ToArray());
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|