From 29f243f40750f85d4848bd3d9dd23c3534c813f6 Mon Sep 17 00:00:00 2001 From: Lambert Lee <33386249+azlis@users.noreply.github.com> Date: Fri, 27 Jan 2023 23:49:48 +0800 Subject: [PATCH] update the table component excel dmos (#403) Co-authored-by: Argo --- .../TablesExcel/TablesExcelCellRender.razor | 52 ++++++++++ .../TablesExcel/TablesExcelOnQuery.razor} | 50 +++++----- src/BootstrapBlazor.Shared/Locales/en.json | 60 +++++------ src/BootstrapBlazor.Shared/Locales/zh.json | 60 +++++------ .../Samples/Table/TablesExcel.razor | 99 ++++++------------- 5 files changed, 172 insertions(+), 149 deletions(-) create mode 100644 src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelCellRender.razor rename src/BootstrapBlazor.Shared/{Samples/Table/TablesExcel.razor.cs => Demos/Table/TablesExcel/TablesExcelOnQuery.razor} (64%) diff --git a/src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelCellRender.razor b/src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelCellRender.razor new file mode 100644 index 000000000..90d914b59 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelCellRender.razor @@ -0,0 +1,52 @@ +@inject IStringLocalizer LocalizerFoo + +
+ + + + +
+
+ +
+
+
@row.Name
+
@Foo.GetTitle(row!.Id)
+
+
+
+
+ + + + +
+
@row!.Count %
+ +
+
+
+ +
+
+
+ +@code { + /// + /// Foo 类为Demo测试用,如有需要请自行下载源码查阅 + /// Foo class is used for Demo test, please download the source code if necessary + /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs + /// + [NotNull] + private List? Items { get; set; } + + /// + /// OnInitialized 方法 + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = Foo.GenerateFoo(LocalizerFoo); + } +} diff --git a/src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor.cs b/src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelOnQuery.razor similarity index 64% rename from src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor.cs rename to src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelOnQuery.razor index 8f4a0b9de..2691fe8b4 100644 --- a/src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor.cs +++ b/src/BootstrapBlazor.Shared/Demos/Table/TablesExcel/TablesExcelOnQuery.razor @@ -1,27 +1,39 @@ -// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ +@inject IStringLocalizer LocalizerFoo -using System.Data; +
+ + + + + + + + + +
-namespace BootstrapBlazor.Shared.Samples.Table; + +
-/// -/// -/// -partial class TablesExcel -{ - [Inject] +@code { + /// + /// Foo 类为Demo测试用,如有需要请自行下载源码查阅 + /// Foo class is used for Demo test, please download the source code if necessary + /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs + /// [NotNull] - private IStringLocalizer? LocalizerFoo { get; set; } - - [Inject] - [NotNull] - private IStringLocalizer? Localizer { get; set; } + private List? Items { get; set; } [NotNull] private BlockLogger? Trace { get; set; } + /// + /// 绑定数据源代码 + /// + private static IEnumerable PageItemsSource => new int[] { 10, 20, 40 }; + /// /// OnInitialized 方法 /// @@ -32,12 +44,6 @@ partial class TablesExcel Items = Foo.GenerateFoo(LocalizerFoo); } - // 绑定数据源代码 - private static IEnumerable PageItemsSource => new int[] { 10, 20, 40 }; - - [NotNull] - private List? Items { get; set; } - private Task> OnQueryAsync(QueryPageOptions options) { IEnumerable items = Items; diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index 92bdc7277..ea0ba81cb 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -5449,36 +5449,36 @@ "TablesSelectionNormalButtonText": "clear selection" }, "BootstrapBlazor.Shared.Samples.Table.TablesExcel": { - "H1": "Table Excel", - "H2": "Commonly used for large data sheet maintenance", - "P1": "binding collection", - "P2": "Get data collection through OnQueryAsync callback", - "P3": "When using the List<TItem> generic collection as a data source, you need to follow the steps below to set", - "P4": "1. Set the data source", - "P5": "Set the Items property of the Table component or the OnQueryAsync callback delegate method", - "P6": "2. Handle the new logic", - "P7": "Set the OnAddAsync callback delegate function to handle the New logic", - "P8": "The code here is sample code", - "P8A": "custom address", - "P9": "output log information", - "P10": "Collection value change notification column", - "P11": "Type", - "P12": "3. Handle delete logic", - "P13": "Set the OnDeleteAsync callback delegate function to handle the delete logic", - "P14": "The code here is sample code", - "P15": "output log information", - "P16": "Collection value change notification column", - "P17": "Type", - "P18": "4. Handle the update logic", - "P19": "Set the OnSaveAsync callback delegate function to handle the cell update logic", - "P20": "After all cells in the component are edited and updated, the OnSaveAsync callback delegate will be automatically triggered, and the parameter is the current update model TItem", - "P21": "The code here is sample code", - "P22": "Cell Change Notification Class: Foo", - "P23": "value: cell", - "P24": "Individually control how cells are rendered by editing the template", - "P25": "Advanced usage", - "P26": "IsFixedHeader fixed header height is set to Height='500px'", - "P27": "Name is not editable display avatar" + "TablesExcel": "Table Excel", + "TablesExcelDescription": "Commonly used for large data sheet maintenance", + "TablesExcelOnQueryTitle": "binding collection", + "TablesExcelOnQueryIntro": "Get data collection through OnQueryAsync callback", + "TablesExcelTips": "When using the List<TItem> generic collection as a data source, you need to follow the steps below to set", + "TablesExcelSetDataSourceTitle": "1. Set the data source", + "TablesExcelSetDataSourceDescription": "Set the Items property of the Table component or the OnQueryAsync callback delegate method", + "TablesExcelNewLogicTitle": "2. Handle the new logic", + "TablesExcelNewLogicDescription": "Set the OnAddAsync callback delegate function to handle the New logic", + "TablesExcelNewLogicNote1": "The code here is sample code", + "TablesExcelNewLogicNote1Address": "custom address", + "TablesExcelNewLogicNote2": "output log information", + "TablesExcelNewLogicNote2Log1": "Collection value change notification column", + "TablesExcelNewLogicNote2Log2": "Type", + "TablesExcelDeleteLogicTitle": "3. Handle delete logic", + "TablesExcelDeleteLogicDescription": "Set the OnDeleteAsync callback delegate function to handle the delete logic", + "TablesExcelDeleteLogicNote1": "The code here is sample code", + "TablesExcelDeleteLogicNote2": "output log information", + "TablesExcelDeleteLogicNote2Log1": "Collection value change notification column", + "TablesExcelDeleteLogicNote2Log2": "Type", + "TablesExcelUpdateLogicTitle": "4. Handle the update logic", + "TablesExcelUpdateLogicDescription1": "Set the OnSaveAsync callback delegate function to handle the cell update logic", + "TablesExcelUpdateLogicDescription2": "After all cells in the component are edited and updated, the OnSaveAsync callback delegate will be automatically triggered, and the parameter is the current update model TItem", + "TablesExcelUpdateLogicNote": "The code here is sample code", + "TablesExcelUpdateLogicLog1": "Cell Change Notification Class: Foo", + "TablesExcelUpdateLogicLog2": "value: cell", + "TablesExcelCellRenderTitle": "Individually control how cells are rendered by editing the template", + "TablesExcelCellRenderIntro": "Advanced usage", + "TablesExcelCellRenderTips1": "IsFixedHeader fixed header height is set to Height='500px'", + "TablesExcelCellRenderTips2": "Name is not editable display avatar" }, "BootstrapBlazor.Shared.Samples.Table.TablesDynamicExcel": { "H1": "Excel-DataTable", diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json index f4613e2e1..56a300c61 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh.json +++ b/src/BootstrapBlazor.Shared/Locales/zh.json @@ -5465,36 +5465,36 @@ "TablesSelectionNormalButtonText": "清除选择" }, "BootstrapBlazor.Shared.Samples.Table.TablesExcel": { - "H1": "Table 表格", - "H2": "常用于大数据单表维护", - "P1": "绑定集合", - "P2": "通过 OnQueryAsync 回调获得数据集合", - "P3": "使用 List<TItem> 泛型集合作为数据源时,需要按照下面的步骤进行设置", - "P4": "1. 设置数据源", - "P5": "设置 Table 组件的 Items 属性或者 OnQueryAsync 回调委托方法", - "P6": "2. 处理新建逻辑", - "P7": "设置 OnAddAsync 回调委托函数处理 新建 逻辑", - "P8": "此处代码为示例代码", - "P8A": "自定义地址", - "P9": "输出日志信息", - "P10": "集合值变化通知 列", - "P11": "类型", - "P12": "3. 处理删除逻辑", - "P13": "设置 OnDeleteAsync 回调委托函数处理 删除 逻辑", - "P14": "此处代码为示例代码", - "P15": "输出日志信息", - "P16": "集合值变化通知 列", - "P17": "类型", - "P18": "4. 处理更新逻辑", - "P19": "设置 OnSaveAsync 回调委托函数处理单元格 更新 逻辑", - "P20": "组件内部所有单元格编辑更新后会自动触发 OnSaveAsync 回调委托,参数是当前更新模型 TItem", - "P21": "此处代码为示例代码", - "P22": "单元格变化通知 类: Foo ", - "P23": "值: 单元格", - "P24": "通过编辑模板单独控制单元格渲染方式", - "P25": "高级用法", - "P26": "IsFixedHeader 固定表头 高度设定为 Height='500px'", - "P27": "Name 不可编辑显示头像" + "TablesExcel": "Table 表格", + "TablesExcelDescription": "常用于大数据单表维护", + "TablesExcelOnQueryTitle": "绑定集合", + "TablesExcelOnQueryIntro": "通过 OnQueryAsync 回调获得数据集合", + "TablesExcelTips": "使用 List<TItem> 泛型集合作为数据源时,需要按照下面的步骤进行设置", + "TablesExcelSetDataSourceTitle": "1. 设置数据源", + "TablesExcelSetDataSourceDescription": "设置 Table 组件的 Items 属性或者 OnQueryAsync 回调委托方法", + "TablesExcelNewLogicTitle": "2. 处理新建逻辑", + "TablesExcelNewLogicDescription": "设置 OnAddAsync 回调委托函数处理 新建 逻辑", + "TablesExcelNewLogicNote1": "此处代码为示例代码", + "TablesExcelNewLogicNote1Address": "自定义地址", + "TablesExcelNewLogicNote2": "输出日志信息", + "TablesExcelNewLogicNote2Log1": "集合值变化通知 列", + "TablesExcelNewLogicNote2Log2": "类型", + "TablesExcelDeleteLogicTitle": "3. 处理删除逻辑", + "TablesExcelDeleteLogicDescription": "设置 OnDeleteAsync 回调委托函数处理 删除 逻辑", + "TablesExcelDeleteLogicNote1": "此处代码为示例代码", + "TablesExcelDeleteLogicNote2": "输出日志信息", + "TablesExcelDeleteLogicNote2Log1": "集合值变化通知 列", + "TablesExcelDeleteLogicNote2Log2": "类型", + "TablesExcelUpdateLogicTitle": "4. 处理更新逻辑", + "TablesExcelUpdateLogicDescription1": "设置 OnSaveAsync 回调委托函数处理单元格 更新 逻辑", + "TablesExcelUpdateLogicDescription2": "组件内部所有单元格编辑更新后会自动触发 OnSaveAsync 回调委托,参数是当前更新模型 TItem", + "TablesExcelUpdateLogicNote": "此处代码为示例代码", + "TablesExcelUpdateLogicLog1": "单元格变化通知 类: Foo ", + "TablesExcelUpdateLogicLog2": "值: 单元格", + "TablesExcelCellRenderTitle": "通过编辑模板单独控制单元格渲染方式", + "TablesExcelCellRenderIntro": "高级用法", + "TablesExcelCellRenderTips1": "IsFixedHeader 固定表头 高度设定为 Height='500px'", + "TablesExcelCellRenderTips2": "Name 不可编辑显示头像" }, "BootstrapBlazor.Shared.Samples.Table.TablesDynamicExcel": { "H1": "Table 表格", diff --git a/src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor b/src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor index 9c6a9331d..bb10600c7 100644 --- a/src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor +++ b/src/BootstrapBlazor.Shared/Samples/Table/TablesExcel.razor @@ -1,30 +1,20 @@ @page "/tables/excel" +@inject IStringLocalizer Localizer -

@Localizer["H1"]

-

@Localizer["H2"]

+

@Localizer["TablesExcelTitle"]

+

@Localizer["TablesExcelDescription"]

- - - - - - - - - - -
- - + -

@((MarkupString)Localizer["P3"].Value)

+

@((MarkupString)Localizer["TablesExcelTips"].Value)

-

@((MarkupString)Localizer["P4"].Value)
-
@((MarkupString)Localizer["P5"].Value)
+
@((MarkupString)Localizer["TablesExcelSetDataSourceTitle"].Value)
+
@((MarkupString)Localizer["TablesExcelSetDataSourceDescription"].Value)

protected override void OnInitialized()
@@ -35,80 +25,55 @@
 }

-

@((MarkupString)Localizer["P6"].Value)
-
@((MarkupString)Localizer["P7"].Value)
+
@((MarkupString)Localizer["TablesExcelNewLogicTitle"].Value)
+
@((MarkupString)Localizer["TablesExcelNewLogicDescription"].Value)

private Task<Foo> OnAddAsync()
 {
-    // @Localizer["P8"]
-    var foo = new Foo() { DateTime = DateTime.Now, Address = $"@Localizer["P8A"] {DateTime.Now.Second}" };
+    // @Localizer["TablesExcelNewLogicNote1"]
+    var foo = new Foo() { DateTime = DateTime.Now, Address = $"@Localizer["TablesExcelNewLogicNote1Address"] {DateTime.Now.Second}" };
     Items.Insert(0, foo);
 
-    // @Localizer["P9"]
-    Trace.Log($"@Localizer["P10"]: {Items.Count} - @Localizer["P11"]: Add");
+    // @Localizer["TablesExcelNewLogicNote2"]
+    Trace.Log($"@Localizer["TablesExcelNewLogicNote2Log1"]: {Items.Count} - @Localizer["TablesExcelNewLogicNote2Log2"]: Add");
     return Task.FromResult(foo);
 }

-

@((MarkupString)Localizer["P12"].Value)
-
@((MarkupString)Localizer["P13"].Value)
+
@((MarkupString)Localizer["TablesExcelDeleteLogicTitle"].Value)
+
@((MarkupString)Localizer["TablesExcelDeleteLogicDescription"].Value)

private Task<bool> OnDeleteAsync(IEnumerable<Foo> items)
 {
-    // @Localizer["P14"]
+    // @Localizer["TablesExcelDeleteLogicNote1"]
     Items.RemoveAll(i => items.Contains(i));
 
-    // @Localizer["P15"]
-    Trace.Log($"@Localizer["P16"]: {Items.Count} - @Localizer["P17"]: Delete");
+    // @Localizer["TablesExcelDeleteLogicNote2"]
+    Trace.Log($"@Localizer["TablesExcelDeleteLogicNote2Log1"]: {Items.Count} - @Localizer["TablesExcelDeleteLogicNote2Log2"]: Delete");
     return Task.FromResult(true);
 }

-

@((MarkupString)Localizer["P18"].Value)
-
@((MarkupString)Localizer["P19"].Value)
-
@((MarkupString)Localizer["P20"].Value)
+
@((MarkupString)Localizer["TablesExcelUpdateLogicTitle"].Value)
+
@((MarkupString)Localizer["TablesExcelUpdateLogicDescription1"].Value)
+
@((MarkupString)Localizer["TablesExcelUpdateLogicDescription2"].Value)

private Task<bool> OnDeleteAsync(Foo item, ItemChangedType changedType)
 {
-    // @Localizer["P21"]
-    Trace.Log($"@Localizer["P22"] - @Localizer["P23"]");
+    // @Localizer["TablesExcelUpdateLogicNote"]
+    Trace.Log($"@Localizer["TablesExcelUpdateLogicLog1"] - @Localizer["TablesExcelUpdateLogicLog2"]");
     return Task.FromResult(true);
 }
- +
    -
  • @((MarkupString)Localizer["P26"].Value)
  • -
  • @((MarkupString)Localizer["P27"].Value)
  • +
  • @((MarkupString)Localizer["TablesExcelCellRenderTips1"].Value)
  • +
  • @((MarkupString)Localizer["TablesExcelCellRenderTips2"].Value)
- - - - -
-
- -
-
-
@row.Name
-
@Foo.GetTitle(row!.Id)
-
-
-
-
- - - - -
-
@row!.Count %
- -
-
-
- -
-