@using System.Reflection @using System.Security.Claims @using Microsoft.AspNetCore.Mvc.Controllers @using System.ComponentModel.DataAnnotations @using Infrastructure.Domain @using Infrastructure.Web.Mvc @{ var descriptor = Url.ActionContext.ActionDescriptor as ControllerActionDescriptor; var entityType = descriptor.ControllerTypeInfo.GetBaseTypes().FirstOrDefault(o => o.Name.Contains("CrudController"))?.GenericTypeArguments.FirstOrDefault(); var modelType = descriptor.ControllerTypeInfo.GetBaseTypes().FirstOrDefault(o => o.Name.Contains("CrudController"))?.GenericTypeArguments.LastOrDefault(); var scope = descriptor.ControllerTypeInfo.GetCustomAttribute()?.Scope.ToString(); var isSoftDeleteEntity = typeof(ISoftDeleteEntity).IsAssignableFrom(entityType); HtmlTitle = modelType.GetDisplayName() + "列表"; var entityName = entityType.Name; var hasPermissions = (User.Identity as ClaimsIdentity).Claims.Any(o => o.Value.EndsWith($"-{entityName}")); var start = (Model.PageIndex - 1) * Model.PageSize; var prefix = new ViewDataDictionary(this.ViewData); prefix.TemplateInfo.HtmlFieldPrefix = "Query"; }
@(await Html.PartialAsync("Search",Model.Query as object,prefix))
新建 @if (isSoftDeleteEntity && User.IsInRole($"Edit-{scope}-{entityName}")) { } @if (isSoftDeleteEntity && User.IsInRole($"Edit-{scope}-{entityName}")) { }
@foreach (var item in modelType.GetProperties().Where(o => !typeof(BaseEntity).IsAssignableFrom(o.PropertyType) && o.Name != "Id" && !o.CustomAttributes.Any(t => t.AttributeType == typeof(ScaffoldColumnAttribute)))) { if (item.PropertyType.IsGenericType && item.PropertyType.GetInterfaces().Contains(typeof(System.Collections.IEnumerable))) { continue; } if (item.CustomAttributes.Any(o => o.AttributeType == typeof(SkipListAttribute))) { continue; } if (scope == "Organ" && item.Name == "OrganId") { continue; } } @foreach (var item in Model.List) { var id = modelType.GetProperty("Id").GetValue(item); @await Html.PartialAsync("_Index_Row", item as object) }
行号@item.GetDisplayName()查看 编辑
@(++start) 查看 编辑
@if (!HidePaged) { }
@section scripts{ @(await Html.PartialAsync("_Script")) }