<%@ Page Language="C#" MasterPageFile="Main.Master" AutoEventWireup="true" CodeFile="Templates.aspx.cs" Inherits="eFrameWork.Manage.Templates" %>
<%@ Register Src="GroupMenu.ascx" TagPrefix="uc1" TagName="GroupMenu" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script>
var act = "<%=act%>";
window.onload=function()
{

};
function addRecord()
{
    var input = $("#json");
    var asname = $("#asname").val();
    var text = $("#f7_text").val();
    var id = $("#f7").val();
    if (id.length == 0)
    {
        layer.msg("请选择数据集!");
        return;
    }
    if (asname.length == 0) {
        layer.msg("请输入别名!");
        return;
    }
    if ($("#Items").find("a").length == 0) { $("#Items").html('');}
    var html = '<a href="javascript:;" class="esearchitem" style="margin-right:8px;"><span>' + text + ' (' + asname + ')</span><i onclick="removeRecord(this);"></i></a>';
    $("#Items").append(html);


    var data = new Object();
    data["asname"] = asname;
    data["text"] = text;
    data["id"] = id;

    var model = input.val().toJson();

    model.append(data);
    input.val(model.toJson());
    $("#asname").val('');


};
function removeRecord(obj)
{
    var input = $("#json");
    var index = $(obj).parent().index();
    var model = input.val().toJson();
    model.remove(index);
    input.val(model.toJson());

    $(obj).parent().remove();
};
function templateView(TemplateID) {
    var url = "templateView.aspx?TemplateID=" + TemplateID;
    layer.open({
        anim: 4,//设置出现的动画效果 4 1 2 0
        type: 2,
        skin: 'layui-layer-rim', //加上边框
        title: "查看模板",
        maxmin: false,
        shadeClose: true, //点击遮罩关闭层
        area: ['75%', '80%'],
        content: url,
        success: function (layero, index) { },
        cancel: function (index, layero) { },
        end: function (index) { }
    });
};
</script>
<uc1:GroupMenu runat="server" ID="GroupMenu" />

<div class="nav">您当前位置：<a href="Default.aspx">首页</a> -> 数据模板管理

<%if(act==""){%>

<a id="btn_add" class="button" href="<%=edt.getAddURL()%>"><span><i class="add">添加</i></span></a>



<%}%>
</div>

<%if (eRegisterInfo.Base == 0 && eRegisterInfo.Loaded)
  { %>
    <div style="margin:6px;line-height:25px;font-size:13px;">
<div class="tips" style="margin-bottom:6px;"><b>未授权提示</b><br><a href="http://frame.eketeam.com/getSerialNumber.html" style="color:#ff0000;" target="_blank">申请临时授权</a>,享更多功能。</div>
   </div>
 <%} %>

<%
    if (act == "edit" || act == "add")
{
%>
<div style="margin:10px;">
	<form name="frmaddoredit" id="frmaddoredit" method="post" action="<%=edt.getSaveURL()%>">
	<input name="id" type="hidden" id="id" value="<%=edt.ID%>">
    <input name="act" type="hidden" id="act" value="save">
	<input type="hidden" id="fromurl" name="fromurl" value="<%=edt.FromURL%>">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="eDataView">
<colgroup>
<col width="126" />
<col />
</colgroup>
      <tr>
        <td class="title"><ins>*</ins>模板名称：</td>
        <td class="content"><span class="eform"><ev:eFormControl ID="f1" FieldName="模板名称" field="Name" notnull="true" Width="200" runat="server" /></span></td>
      </tr>



     <tr>
	     <td class="title">数据集：</td>
	     <td class="content"><input name="json" type="hidden" id="json" value="<%=jsonstr.HtmlEncode() %>" />
             <div id="Items" style="height:30px;margin-bottom:8px;"><%=jsonitems %></div>
             <table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="210">
        <span class="filterSelect" onclick="show_filterText(this);" style="width:200px;min-width:200px;z-index: 1;" title="<%=f7.Text%>">
        <span title="<%=f7.Text%>"><%= f7.Text.Length == 0 ? "请选择" : f7.Text%></span>
        <input id="f7" name="f7" type="hidden" value="<%=f7.Value%>">
        <input id="f7_text" name="f7_text" type="hidden" value="<%=f7.Text%>">
        <div style="width: 260px; display: none;">
<input type="text" onkeyup="filterKeyUp(this);" placeholder="输入筛选..." style="width: 100%;">
<ul>
	<asp:Literal id="LitParent" runat="server" />
</ul>
</div>
    </span>
    </td>
    <td width="90">别名：<input type="text" class="text" id="asname" name="asname" style="padding:3px;width:30px;" /></td>
    <td width="80"><button type="button" class="button" onclick="addRecord();">添加</button></td>
  </tr>
</table>



         

 </td>
	     </tr>



	   <tr>
	     <td class="title">说明：</td>
	     <td class="content"><span class="eform"><ev:eFormControl ID="f3" controltype="textarea" FieldName="说明" field="remark" notnull="false" htmlTag="true" runat="server" /></span></td>
	     </tr>
 		<tr>		
		<td colspan="2" class="title"  style="text-align:left;padding-left:100px;padding-top:10px;padding-bottom:10px;">		
		<a class="button" href="javascript:;" onclick="if(frmaddoredit.onsubmit()!=false){frmaddoredit.submit();}"><span><i class="save">保存</i></span></a>
		<a class="button" href="javascript:;" style="margin-left:30px;" onclick="history.back();"><span><i class="back">返回</i></span></a>
		</td>
	   </tr>	 
    </table>
    </form>
</div>
<%}else{%>

<div style="margin:6px;">
<dl id="eSearchBox" class="ePanel">
<dt><h1 onclick="showPanel(this);" class="search"><a href="javascript:;" class="cur" onfocus="this.blur();"></a>搜索</h1></dt>
<dd style="display:none;">
<asp:PlaceHolder ID="eSearchControlGroup" runat="server">
<form id="frmsearch" name="frmsearch" method="post" onsubmit="return goSearch(this);" action="<%=elist.getSearchURL()%>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="eDataView">
<colgroup>
<col width="120" />
<col />
</colgroup>
<tr>
<td class="title">模板名称：</td>
<td class="content"><span class="eform"><ev:eSearchControl ID="s1" Name="s1" ControlType="text" Field="Name" Operator="like" FieldName="模板名称" DataType="string" Width="300px" runat="server" /></span></td>
</tr>
<tr>
<td colspan="2" class="title" style="text-align:left;padding-left:125px;"><a class="button" href="javascript:;" onclick="if(frmsearch.onsubmit()!=false){frmsearch.submit();}"><span><i class="search">搜索</i></span></a></td>
</tr>
</table>
</form>
</asp:PlaceHolder>
</dd>
</dl>
<%}%>


<asp:Repeater id="Rep" runat="server">
<headertemplate>
<%#
"<table id=\"eDataTable\" class=\"eDataTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\" style=\"min-width:1400px;\">\r\n"+
"<thead>\r\n"+
  "<tr bgcolor=\"#f2f2f2\">\r\n"+
  "<td width=\"35\"><input type=\"checkbox\" name=\"selallitem\" value=\"0\" onclick=\"selectAllItems(this);\"></td>\r\n"+
  	"<td width=\"260\">编号</td>\r\n"+
	"<td>模板名称</td>\r\n"+
    "<td>数据集</td>\r\n"+
    "<td>查看</td>\r\n"+
	"<td>说明</td>\r\n"+
	"<td width=\"100\">添加时间</td>\r\n"+
	"<td width=\"150\">操作</td>\r\n"+
  "</tr>\r\n"+
"</thead>\r\n" %></headertemplate><itemtemplate><%# "<tr erowid=\"" + Eval("TemplateID").ToString() + "\" " + ((Container.ItemIndex+1) % 2 == 0 ? " class=\"alternating\" eclass=\"alternating\"" : " eclass=\"\"") + ">\r\n"+
    "<td height=\"32\"><input type=\"checkbox\" name=\"selitem\" value=\"" + Eval("TemplateID").ToString() + "\"></td>\r\n"+
    "<td><a class=\"copy\" href=\"javascript:;\" data-clipboard-action=\"copy\" data-clipboard-text=\"" + Eval("TemplateID") + "\"></a>"+ Eval("TemplateID") + "</td>\r\n"+
	"<td><a href=\"templateDesign.aspx?TemplateID=" + Eval("TemplateID") + "\">"+ Eval("Name") + "</a></td>\r\n"+
    "<td>"+ getRecords(Eval("RecordIDS").ToString()) + "</td>\r\n"+
    "<td><a href=\"javascript:;\" onclick=\"templateView('"+ Eval("TemplateID")+"');\">查看</a></td>\r\n"+
    "<td>"+ Eval("remark") + "</td>\r\n"+
	"<td>"+ Eval("addTime","{0:yyyy-MM-dd}") + "</td>\r\n"+
	"<td>"+
	"<a href=\"" + edt.getActionURL("edit",Eval("TemplateID").ToString())  + "\">修改</a>"+
    "<a href=\"" + edt.getActionURL("copy",Eval("TemplateID").ToString())  + "\" onclick=\"javascript:return confirm('确认要复制吗？');\">复制</a>"+
	"<a href=\""+ edt.getActionURL("del",Eval("TemplateID").ToString()) +"\" onclick=\"javascript:return confirm('确认要删除吗？');\">删除</a>"+
	"</td>\r\n"+
"</tr>\r\n"%></itemtemplate>
<footertemplate><%#"</table>\r\n"%></footertemplate>
</asp:Repeater>
</div>
<div style="margin:6px;"><ev:ePageControl ID="ePageControl1" PageSize="20" PageNum="9" runat="server" /></div>

</asp:Content>