Upgrade Nuget
大石头 authored at 2024-11-20 14:22:34
2.99 KiB
YuQue
@using NewLife;
@using NewLife.Cube
@using NewLife.Reflection
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@{
    var fact = ViewBag.Factory as IEntityFactory;
    var page = ViewBag.Page as Pager;
    var fields = ViewBag.Fields as FieldCollection;
    var fk = fact.Unique;
    var set = ViewBag.PageSetting as PageSetting;
}
<table class="table table-bordered table-hover table-striped table-condensed table-data-list">
    <thead>
        <tr>
            @if (set.EnableSelect)
            {
                <th class="text-center" style="width:10px;"><input type="checkbox" id="chkAll" title="全选" /></th>
            }
            @foreach (var item in fields)
            {
                var sortUrl = !item.MapField.IsNullOrEmpty() ? page.GetSortUrl(item.MapField) : page.GetSortUrl(item.Name);
                <th class="text-center" title="@item.Description"><a href="@Html.Raw(sortUrl)">@item.DisplayName</a></th>
            }
            <th class="text-center">升</th>
            <th class="text-center">降</th>
            @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
            {
                <th class="text-center">操作</th>
            }
        </tr>
    </thead>
    <tbody>
        @foreach (IEntityTree entity in Model)
        {
            var p = entity.Parent as IEntityTree;
            if (p == null)
            {
                p = fact.EntityType.GetValue("Root") as IEntityTree;
            }
            var id = entity["Id"];
            <tr>
                @if (set.EnableSelect)
                {
                    <td class="text-center"><input type="checkbox" name="keys" value="@entity[fk.Name]" /></td>
                }
                @foreach (var item in fields)
                {
                    @await Html.PartialAsync("_List_Data_Item", new ValueTuple<IEntity, DataField>(entity, item))
                }
                <td class="text-center">
                    @if (p != null && p.Childs != null && p.Childs.Count > 0 && entity != p.Childs[0])
                    {
                        <a href="@Url.Action("Up", new { id })">
                            @await Html.PartialAsync("_Icon_Arrow", true)
                        </a>
                    }
                </td>
                <td class="text-center">
                    @if (p != null && p.Childs != null && p.Childs.Count > 0 && entity != p.Childs[p.Childs.Count - 1])
                    {
                        <a href="@Url.Action("Down", new { id })">
                            @await Html.PartialAsync("_Icon_Arrow", false)
                        </a>
                    }
                </td>
                @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                {
                    <td class="text-center">
                        @await Html.PartialAsync("_List_Data_Action", (Object)entity)
                    </td>
                }
            </tr>
        }
    </tbody>
</table>