2020-04-28 15:56:56 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
public partial class DatePicker : DatePickerBase<DateTime>
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
|
|
|
|
protected void OnInput(ChangeEventArgs args, int index = 0)
|
|
|
|
|
{
|
|
|
|
|
if (args == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse(args.Value.ToString(), out DateTime changeValue))
|
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
Value = changeValue;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
_pickerValues[index] = changeValue;
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-01 14:09:28 +08:00
|
|
|
|
UpdateCurrentValueAsString();
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get value by picker index
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
/// <returns></returns>
|
2020-06-01 14:09:28 +08:00
|
|
|
|
public override DateTime? GetIndexValue(int index)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-05-10 17:33:09 +08:00
|
|
|
|
if (_pickerStatus[index]._hadSelectValue)
|
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
return Value;
|
2020-05-10 17:33:09 +08:00
|
|
|
|
}
|
|
|
|
|
else if (_defaultValues[index] != null)
|
|
|
|
|
{
|
|
|
|
|
return (DateTime)_defaultValues[index];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-01 14:09:28 +08:00
|
|
|
|
public override void ChangeValue(DateTime value, int index = 0)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
Value = value;
|
|
|
|
|
|
|
|
|
|
_pickerStatus[index]._hadSelectValue = true;
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-01 14:09:28 +08:00
|
|
|
|
UpdateCurrentValueAsString();
|
2020-04-28 15:56:56 +08:00
|
|
|
|
|
2020-06-01 14:09:28 +08:00
|
|
|
|
if (IsRange && !IsShowTime && Picker != DatePickerType.Time)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
if (_pickerStatus[0]._hadSelectValue && _pickerStatus[1]._hadSelectValue)
|
2020-04-28 15:56:56 +08:00
|
|
|
|
{
|
2020-06-01 14:09:28 +08:00
|
|
|
|
Close();
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-01 14:09:28 +08:00
|
|
|
|
else if (!IsShowTime && Picker != DatePickerType.Time)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
2020-04-28 15:56:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|