@using static HotelPms.Client.Blazor.Util.SystemEnum
|
<MudDialog Style="width: 360px;">
|
<TitleContent>
|
<MudText Typo="Typo.h6">
|
<MudIcon Icon="@Icons.Material.Filled.DateRange" Class="mr-3 mb-n1"/>
|
@Title
|
</MudText>
|
</TitleContent>
|
<DialogContent>
|
<MudDatePicker @ref="_picker" PickerVariant="PickerVariant.Static" TitleDateFormat = "MM月dd日" @bind-Date="Data"/>
|
</DialogContent>
|
<DialogActions>
|
<MudGrid Spacing="2" Justify="Justify.Center" Class="my-3">
|
<MudItem>
|
<MudButton Variant="Variant.Filled" Color="MudBlazor.Color.Primary" OnClick="ToDate" StartIcon="@Icons.Filled.Done" Style="width: 100px; height: 40px;">本日</MudButton>
|
</MudItem>
|
<MudItem>
|
<MudButton Variant="Variant.Filled" Color="MudBlazor.Color.Error" OnClick="Close" StartIcon="@Icons.Filled.Close" Style="width: 100px; height: 40px;">戻る</MudButton>
|
</MudItem>
|
</MudGrid>
|
</DialogActions>
|
</MudDialog>
|
|
@code {
|
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
|
[Parameter] public string Title { get; set; }
|
MudDatePicker _picker;
|
private bool isFirst = true;
|
private DateTime? m_Data;
|
|
[Parameter] public DateTime? Data
|
{
|
get { return m_Data; }
|
set
|
{
|
m_Data = value;
|
if (!isFirst) { Save(); }
|
}
|
}
|
|
protected override void OnAfterRender(bool firstRender)
|
{
|
if (firstRender)
|
{
|
isFirst = false;
|
_picker.GoToDate();
|
}
|
}
|
|
private void ToDate()
|
{
|
_picker.GoToDate(DateTime.Today);
|
}
|
|
private void Close()
|
{
|
MudDialog.Cancel();
|
}
|
|
private void Save()
|
{
|
MudDialog.Close(DialogResult.Ok(CConvert.ToDateString(Data)));
|
}
|
}
|