<%@ Page Title="模板列表" Language="C#" MasterPageFile="~/Masters/Sys.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="yueyaCMS.Admin.Page.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="/Plugins/Select2/select2.css" rel="stylesheet" />
<script src="/Plugins/Select2/select2.min.js"></script>
<script src="/Plugins/Select2/select2_locale_zh-CN.js"></script>
    <style type="text/css">
        #PageTable tbody tr td a.btn { margin-right:5px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<ul class="breadcrumb">
<li><i class="icon-tags"></i> 您当前的位置：<a href="/Admin/Site/Default.aspx">系统首页</a></li>
<li><span class="divider">/</span> 模板列表</li>
</ul>

    <div style="margin-bottom:10px;">
    <div class="btn-group">
    <a class="btn btn-warning" href="Default.aspx">查看全部</a>
    <button class="btn dropdown-toggle  btn-warning" data-toggle="dropdown">
    <span class="caret"></span>
    </button>
    <ul id="PageTypes" class="dropdown-menu">
    </ul>
    </div>      
        &nbsp;
        <a href="Add.aspx" class="btn btn-success">新建模版</a>
    </div>

<table id="PageTable" class="table table-bordered table-hover">
<thead>
<tr>
<th>编号</th>
<th>模版名称</th>
<th>模版类型</th>
<th>模版风格</th>
<th>集成一键生成</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div id="Pagination" class="bigPage vm" style="float:left;padding:0px;"></div>
<script type="text/javascript">
    $(function () {
        API.Page_Type_Get(function (result) {
            var PageTypes_Temp = '{@each dbList as d,index}<li><a href="Default.aspx?t=${d.ID}" >${d.Name}</a></li>{@/each}';
            $("#PageTypes").html(juicer(PageTypes_Temp, { dbList: result.dbList }));
            GetPages(0);
        }, "{pageIndex:0,showLength:9999}");
    });

    /*获取页面列表*/
    function GetPages(pageIndex)
    {
        var SelectedTypeID = <%=t%>;

        API.Page_Get(function (result) {
            var Page_Temp = '{@each dbList as d,index}<tr id="Page_${d.ID}"><td>${++index}</td><td><a href="Edit.aspx?id=${d.ID}">${d.PageName}</a></td><td>${d.PageKind|PageKind}</td><td class="typeNum">${d.TypeID}</td><td>{@if d.CanBuild==1}支持{@else}不支持{@/if}</td><td>${d.CreateDate|DateFormat}</td><td><a href="Builder.aspx?id=${d.ID}&dataid=1" class="btn btn-mini" target="_blank">生成</a> <a href="Edit.aspx?id=${d.ID}" class="btn btn-mini">编辑</a> <a href="javascript:void(0);" class="btn btn-mini" onclick="DelPage(${d.ID})">删除</a></td></tr>{@/each}';
            $("#PageTable tbody").html(juicer(Page_Temp, { dbList: result.dbList }));
            API.PageBuilder(result.pageCount, pageIndex, "#Pagination", "GetPages");
            $.each($("td.typeNum"), function (a, b) {
                $(b).text("<%=pageTypeName%>");
            });
        }, "{pageIndex:" + pageIndex + ",showLength:20,typeID:" + SelectedTypeID + "}");
    }

    /*删除指定页面*/
    function DelPage(pageID)
    {
        if (!confirm("是否确认删除？")) { return false;}
            API.Page_Delete(function (r) {
                if (r == "1") { $("#Page_" + pageID).remove(); }
                else { alert(r); }
            }, "{pageID:" + pageID + "}");
        }

   $(function () { GetPages(0); });
</script>
</asp:Content>