diff --git a/src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor b/src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor new file mode 100644 index 000000000..3d4f373a5 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor @@ -0,0 +1,17 @@ +
+
+ +
+
+ +
+
+ +@code { + /// + /// + /// + [Parameter] + [NotNull] + public Foo? Value { get; set; } +} diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor index ff8f6c17a..bbbd7c356 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor @@ -4,14 +4,6 @@

通过注入服务调用 Show 方法弹出窗口进行人机交互

- -

- 本组件使用注入服务的形式提供功能,使用时用户体验效果非常舒适,随时随地的调用,需要在使用本组件的页面中内置 Dialog 组件,或者在 MainLayout 主布局组件中内置,示例代码如下: -

-
- -
<Dialog />
-

通过设置 DialogOption IsKeyboard 参数,开启弹窗是否支持 ESC,请点击后面按钮设置后再点击 弹窗 按钮测试效果

@@ -100,6 +92,35 @@ + +

功能介绍

+
    +
  • 点击按钮弹出编辑弹窗
  • +
  • 通过 EditDialogOption 参数对弹窗进行设置
  • +
  • 设计出发点通过给定 Model 或者 Items 自动生成带客户端验证的表单窗口
  • +
+ +
+ + +

功能介绍

+
    +
  • 点击按钮弹出搜索弹窗
  • +
  • 通过 SearchDialogOption 参数对弹窗进行设置
  • +
  • 设计出发点通过给定 Model 或者 Items 自动生成搜索窗口
  • +
+ +
+ + +

功能介绍

+
    +
  • 点击按钮弹出保存弹窗
  • +
  • 设计出发点通过给定 TComponent 自动生成保存窗口,通过设置 saveCallback 在保存回调方法中进行数据处理,TComponent 泛型组件所需要参数可以通过 parameters 进行传递
  • +
+ +
+ diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs index 373fc65b0..a5e2de209 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs @@ -7,6 +7,7 @@ using BootstrapBlazor.Shared.Common; using BootstrapBlazor.Shared.Components; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.Localization; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -29,6 +30,10 @@ public sealed partial class Dialogs [NotNull] private DialogService? DialogService { get; set; } + [Inject] + [NotNull] + private IStringLocalizer? Localizer { get; set; } + private bool IsKeyboard { get; set; } private void OnClickKeyboard() @@ -224,6 +229,44 @@ public sealed partial class Dialogs }); } + private async Task OnEditDialogClick() + { + var option = new EditDialogOption() + { + Title = "编辑弹窗", + Model = new Foo(), + RowType = RowType.Inline, + ItemsPerRow = 2, + ItemChangedType = ItemChangedType.Update + }; + await DialogService.ShowEditDialog(option); + } + + private async Task OnSearchDialogClick() + { + var option = new SearchDialogOption() + { + Title = "搜索弹窗", + Model = new Foo(), + RowType = RowType.Inline, + ItemsPerRow = 2, + }; + await DialogService.ShowSearchDialog(option); + } + + private async Task OnSaveDialogClick() + { + var foo = Foo.Generate(Localizer); + await DialogService.ShowSaveDialog("保存", () => + { + // 此处可以访问 foo 实例进行入库操作等 + return Task.FromResult(true); + }, new Dictionary + { + ["Value"] = foo + }); + } + /// /// 获得属性方法 ///