commit
f7be77741b
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
@ -6,7 +7,7 @@ using System.Collections.Concurrent;
|
|||
namespace Microsoft.AspNetCore.Builder
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 显示名称扩展方法类
|
||||
/// </summary>
|
||||
public static class DisplayNamesExtensions
|
||||
{
|
||||
|
@ -27,11 +28,15 @@ namespace Microsoft.AspNetCore.Builder
|
|||
|
||||
_displayNameCache.TryAdd((typeof(BootstrapUser), nameof(BootstrapUser.UserName)), "登录名称");
|
||||
_displayNameCache.TryAdd((typeof(BootstrapUser), nameof(BootstrapUser.DisplayName)), "显示名称");
|
||||
|
||||
_displayNameCache.TryAdd((typeof(Group), nameof(Group.GroupCode)), "部门编码");
|
||||
_displayNameCache.TryAdd((typeof(Group), nameof(Group.GroupName)), "部门名称");
|
||||
_displayNameCache.TryAdd((typeof(Group), nameof(Group.Description)), "部门描述");
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 尝试获取指定 Model 指定属性值的显示名称
|
||||
/// </summary>
|
||||
/// <param name="cacheKey"></param>
|
||||
/// <param name="displayName"></param>
|
||||
|
@ -39,7 +44,7 @@ namespace Microsoft.AspNetCore.Builder
|
|||
public static bool TryGetValue((Type ModelType, string FieldName) cacheKey, out string? displayName) => _displayNameCache.TryGetValue(cacheKey, out displayName);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 获得或者添加指定 Model 的指定属性值得显示名称
|
||||
/// </summary>
|
||||
/// <param name="cacheKey"></param>
|
||||
/// <param name="valueFactory"></param>
|
||||
|
|
|
@ -1,6 +1,34 @@
|
|||
<label class="control-label" for="groupName">部门名称</label>
|
||||
<input type="text" class="form-control" id="groupName" placeholder="不可为空,50字以内" maxlength="50" data-valid="true" />
|
||||
@inherits GroupsBase
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
<EditPage Id="dict" TItem="Bootstrap.DataAccess.Group" QueryModel="QueryModel" OnQuery="Query" OnAdd="Add" OnDelete="Delete" OnSave="Save">
|
||||
<QueryBody>
|
||||
<LgbInputText @bind-Value="@context.GroupName" maxlength="50" />
|
||||
<LgbInputText @bind-Value="@context.Description" maxlength="50" />
|
||||
</QueryBody>
|
||||
<TableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.GroupCode"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.GroupName"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Description"></LgbTableHeader>
|
||||
</TableHeader>
|
||||
<RowTemplate>
|
||||
<td>@context.GroupCode</td>
|
||||
<td>@context.GroupName</td>
|
||||
<td>@context.Description</td>
|
||||
</RowTemplate>
|
||||
<EditTemplate>
|
||||
<div class="row">
|
||||
<LgbInputText @bind-Value="@context.GroupName" placeholder="不可为空,50字以内" maxlength="50">
|
||||
<RequiredValidator />
|
||||
<StringLengthValidator Length="50" />
|
||||
</LgbInputText>
|
||||
<LgbInputText @bind-Value="@context.GroupCode" placeholder="不可为空,50字以内" maxlength="50">
|
||||
<RequiredValidator />
|
||||
<StringLengthValidator Length="50" />
|
||||
</LgbInputText>
|
||||
<LgbInputText @bind-Value="@context.Description" placeholder="不可为空,500字以内" maxlength="500">
|
||||
<RequiredValidator />
|
||||
<StringLengthValidator Length="500" />
|
||||
</LgbInputText>
|
||||
</div>
|
||||
</EditTemplate>
|
||||
</EditPage>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
using Bootstrap.Admin.Components;
|
||||
using Bootstrap.DataAccess;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.Pages.Admin.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门维护组件
|
||||
/// </summary>
|
||||
public class GroupsBase : QueryPageBase<Group>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询方法
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <param name="pageItems">每页显示数据条目数量</param>
|
||||
protected override QueryData<Group> Query(int pageIndex, int pageItems)
|
||||
{
|
||||
var data = GroupHelper.Retrieves();
|
||||
if (!string.IsNullOrEmpty(QueryModel.GroupName)) data = data.Where(d => d.GroupName.Equals(QueryModel.GroupName, StringComparison.OrdinalIgnoreCase));
|
||||
if (!string.IsNullOrEmpty(QueryModel.Description)) data = data.Where(d => d.Description != null && d.Description.Contains(QueryModel.Description, StringComparison.OrdinalIgnoreCase));
|
||||
var totalCount = data.Count();
|
||||
var items = data.Skip((pageIndex - 1) * pageItems).Take(pageItems);
|
||||
return new QueryData<Group>() { Items = items, TotalCount = totalCount, PageIndex = pageIndex, PageItems = pageItems };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存方法
|
||||
/// </summary>
|
||||
protected override bool Save(Group group) => GroupHelper.Save(group);
|
||||
|
||||
/// <summary>
|
||||
/// 删除方法
|
||||
/// </summary>
|
||||
protected override bool Delete(IEnumerable<Group> groups) => GroupHelper.Delete(groups.Select(item => item.Id ?? ""));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue