<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Admin/AdminMain.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcEnterprise.Models.CustomForm.RowModel>>" %>

<asp:Content ID="Content0" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="../../Content/Skin/Pager.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/Admin.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    自定义表单
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="ajaxLoading">loading...</div>
<div id="requestAjaxText">
    <form method="post" id="MultiOperationForm" action="?action=MultiOperation&tablename=<%= Request.QueryString["tablename"] %>">
    <table>
        <tr>
            <th>
                字段名称
            </th>
            <th>
                填写规则
            </th>
            <th>
                字段类型
            </th>
            <th>
                可选内容
            </th>
            <th>
                显示顺序
            </th>
            <th>
                操作
            </th>
            <th>
                <input type="checkbox" id="cb_ReverseSelection" />
            </th>
        </tr>
        <%
			var i = 0;
            foreach (var item in Model)
            { %>
		<tr>
			<td>
				<input type="text" name="FieldName__<%= i %>" value="<%= item.FieldName %>" onchange="$(this).parents('tr').find(':checkbox').attr('checked','checked');" />
			</td>
			<td>
				<select name="Rule__<%= i %>" onchange="$(this).parents('tr').find(':checkbox').attr('checked','checked');">
					<option value="notes" <%= item.Rule=="notes" ? "selected='selected'":"" %>>不检查</option>
					<option value="txt" <%= item.Rule=="txt" ? "selected='selected'":"" %>>字符串</option>
					<option value="num" <%= item.Rule=="num" ? "selected='selected'":"" %>>数字</option>
					<option value="date" <%= item.Rule=="date" ? "selected='selected'":"" %>>日期</option>
					<option value="mail" <%= item.Rule=="mail" ? "selected='selected'":"" %>>邮箱</option>
					<option value="idnum" <%= item.Rule=="idnum" ? "selected='selected'":"" %>>身份证</option>
					<option value="cn" <%= item.Rule=="cn" ? "selected='selected'":"" %>>中文</option>
				</select>
			</td>
			<td>
				<select name="InputType__<%= i %>" onchange="$(this).parents('tr').find(':checkbox').attr('checked','checked');">
					<option value="1" <%= item.InputType==1 ? "selected='selected'":"" %>>文本框</option>
					<option value="2" <%= item.InputType==2 ? "selected='selected'":"" %>>文本域</option>
					<option value="3" <%= item.InputType==3 ? "selected='selected'":"" %>>单选项</option>
					<option value="4" <%= item.InputType==4 ? "selected='selected'":"" %>>多选项</option>
				</select>
			</td>
			<td><textarea rows="2" cols="15" style="width:200px;height:35px;" name="Content__<%= i %>" onchange="$(this).parents('tr').find(':checkbox').attr('checked','checked');"><%= item.Content %></textarea></td>
			<td>
				<input name="Sequence__<%= i %>" style="width: 28px;" onblur="if(!(/^(-|\+)?\d+$/.test(this.value))){alert('只能输入整数。');this.focus();this.select();}" type="text" maxlength="4" value="<%= item.Sequence %>" onchange="$(this).parents('tr').find(':checkbox').attr('checked','checked');" />
			</td>
			<td>
				<a href="javascript:;" onclick="deleteModel(this,'<%= item.ID %>__<%= i %>');">删除</a>
			</td>
			<td>
				<input type="checkbox" name="cb_id" value="<%=item.ID %>__<%= i %>" />
			</td>
		</tr>
        <% i++;
			} %>
        <tr>
            <td colspan="8" style="text-align: right">
                执行
                <select name="OpType">
                    <option value="1">保存</option>
                    <option value="2">删除</option>
                </select>
                <input type="submit" value="操作" />
            </td>
        </tr>
    </table>
    </form>
	说明：修改最后一条空白字段将添加为新字段。
</div>
<br class="clearfloat" />
<script src="../../Scripts/jquery.ReverseSelection.js" type="text/javascript"></script>
<script type="text/javascript">
	$.initReverseSelection(); //初始反选功能
	$(function () {
		$("#MultiOperationForm").submit(function () {
			if ($("select[name='OpType']").val() == 2) {
				if (!confirm("确认删除？")) {
					return false;
				}
			}
		});
	});
</script>
</asp:Content>

