private async Task OnClickSidebarItem(DateTimeRangeSidebarItem item) { SelectedValue.Start = item.StartDateTime; SelectedValue.End = item.EndDateTime; StartValue = item.StartDateTime; EndValue = StartValue.AddMonths(1); await ClickConfirmButton(); }
/// <summary> /// OnParametersSet 方法 /// </summary> protected override void OnParametersSet() { base.OnParametersSet(); Value ??= new DateTimeRangeValue(); StartValue = Value.Start; EndValue = Value.End; if (StartValue == DateTime.MinValue) { StartValue = DateTime.Now; } if (EndValue == DateTime.MinValue) { EndValue = StartValue.AddMonths(1); } SelectedValue.Start = StartValue; SelectedValue.End = EndValue; StartPlaceHolderText ??= Localizer[nameof(StartPlaceHolderText)]; EndPlaceHolderText ??= Localizer[nameof(EndPlaceHolderText)]; SeparateText ??= Localizer[nameof(SeparateText)]; ClearButtonText ??= Localizer[nameof(ClearButtonText)]; ConfirmButtonText ??= Localizer[nameof(ConfirmButtonText)]; TodayButtonText ??= Localizer[nameof(TodayButtonText)]; DateFormat ??= Localizer[nameof(DateFormat)]; if (StartValue.ToString("yyyy-MM") == EndValue.ToString("yyyy-MM")) { StartValue = StartValue.AddMonths(-1); } if (SidebarItems == null) { SidebarItems = new DateTimeRangeSidebarItem[] { new DateTimeRangeSidebarItem { Text = Localizer["Last7Days"], StartDateTime = DateTime.Today.AddDays(-7), EndDateTime = DateTime.Today }, new DateTimeRangeSidebarItem { Text = Localizer["Last30Days"], StartDateTime = DateTime.Today.AddDays(-30), EndDateTime = DateTime.Today }, new DateTimeRangeSidebarItem { Text = Localizer["ThisMonth"], StartDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day), EndDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(1).AddDays(-1) }, new DateTimeRangeSidebarItem { Text = Localizer["LastMonth"], StartDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(-1), EndDateTime = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddDays(-1) }, }; } }