v3.1.2020.0115   X组件内部目录统一使用BasePath,支持命令行参数与环境变量,便于函数计算
大石头 编写于 2020-01-15 01:22:07
NewLife.Cube
@using NewLife;
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@{
    var fact = ViewBag.Factory as IEntityOperate;
    var page = ViewBag.Page as Pager;
    var fields = ViewBag.Fields as IList<FieldItem>;
    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.OriField != null ? page.GetSortUrl(item.OriField.Name) : 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 FirstFlag = 0;
            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)
                {
                    if (FirstFlag == 0)
                    {
                        @Html.Partial("_List_Data_Item_First", new Pair(entity, item))
                    }
                    else
                    {
                        @Html.Partial("_List_Data_Item", new Pair(entity, item))
                    }

                    FirstFlag++;
                }
                <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 })"><span class="glyphicon glyphicon-arrow-up" style="color: green;"></span></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 })"><span class="glyphicon glyphicon-arrow-down" style="color: red;"></span></a>
                    }
                </td>
                @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                {
                    <td class="text-center">
                        @Html.Partial("_List_Data_Action", (Object)entity)
                    </td>
                }
            </tr>
        }
    </tbody>
</table>