@{
    CurrentUser user = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList((string)ViewBag.Table, action, user,PageAdmin.Common.FromEnum.Member);
    string guid = Html.Guid();
}
<form method="post" id="_form" class=" form" data-validate-params="beforeSubmit:'BeforeSubmit'" data-source="@Model">
    <div class="main">

        <div><b>基本信息</b></div>
        <ul class="clearfix">
            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">用户名：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" name="Username" id="Username" readonly class="form-control" maxlength="50">
                        <span class="help-block"></span>
                    </div>
                </div>
            </li>

            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">密码：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" class="form-control" maxlength="30" name="Password" id="Password" placeholder="不修改密码则留空">
                        <input type="hidden" class="form-control"  name="oldPassword" id="oldPassword">
                        <span class="help-block"></span>
                    </div>
                </div>
            </li>


            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">会员组：</label>
                    <div class="controls  form-group-sm">
                        <select class="form-control" name="MemberGroupId" id="MemberGroupId" data-source="@Html.GetCanAdminMemberGroupListJson()" data-custom-params="dataSourceFrom:'attr'"></select>

                        <span class="help-block"></span>
                    </div>
                </div>
            </li>

            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">部门：</label>
                    <div class="controls  form-group-sm">
                        <select class="form-control" name="DepartmentId" id="DepartmentId" data-source="@Html.GetDepartmentListJson()" data-custom-params="dataSourceFrom:'attr',isTree:true,onlySelectFinal:true">
                            <option value="0">无</option>
                        </select>

                        <span class="help-block"></span>
                    </div>
                </div>
            </li>

            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">邮箱：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" class="form-control" name="Email" value="" id="Email" maxlength="50" data-validate="dataType:'email',ignoreEmpty:true,errorMsg:'邮箱地址格式错误！'">
                        <span class="help-block"></span>
                    </div>
                </div>

            </li>

            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">手机：</label>
                    <div class="controls form-group-sm">
                        <input type="text" class="form-control" name="Mobile" id="Mobile" data-validate="dataType:'mobile',ignoreEmpty:true,errorMsg:'手机号码格式错误！'" maxlength="15">
                        <span class="help-block"></span>
                    </div>
                </div>
            </li>

            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">注册时间：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" class="form-control" readonly name="RegDate" value="" id="RegDate">
                        <span class="help-block"></span>
                    </div>
                </div>

            </li>
            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">注册IP：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" class="form-control" readonly name="RegIp" id="RegIp">
                        <span class="help-block"></span>
                    </div>
                </div>
            </li>

            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">最后登陆时间：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" class="form-control" readonly name="LastDate" value="" id="LastDate">
                        <span class="help-block"></span>
                    </div>
                </div>

            </li>
            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">最后登陆IP：</label>
                    <div class="controls form-group-sm">
                        <input type="text" class="form-control" name="LastIp" readonly value="" id="LastIp">
                        <span class="help-block"></span>
                    </div>
                </div>
            </li>
            <li class="left" style="width:50%;">
                <div class="form-group">
                    <label class="control-label">登录次数：</label>
                    <div class="controls  form-group-sm">
                        <input type="text" class="form-control" readonly name="Logins" id="Logins">
                        <span class="help-block"></span>
                    </div>
                </div>
            </li>
        </ul>
    </div>


    <div class="main" style="margin-top:15px" id="customField">

        <div><b>会员信息</b></div>
        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("from", "member");
            data.Add("guid", guid);
            data.Add("currentUser", ViewBag.CurrentUser);
            data.Add("memberGroupId", ViewBag.MemberGroupId);
            data.Add("i", 0);
            int i = 0;
            if (fieldData != null)
            {
                foreach (var row in fieldData)
                {
                    data["i"] = i;
                    beforeSubmitJs += row.BeforeSubmitJs;
                    Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                    i++;
                }
            }

        }
        @if (i == 0)
        {
            <text>
                <script>    $("#customField").hide();</script></text>
        }
    </div>

    <div class="form-group postarea" style="text-align:center">
        @Html.AntiForgeryToken()
        <input type="hidden" id="IsAdmin" name="IsAdmin" value="0" />
        <input type="hidden" id="State" name="State" value="1" />
        <input type="hidden" id="Logins" name="Logins" value="0" />
        <input type="hidden" id="Id" name="Id" value="0" />
        <input type="hidden" id="Guid" name="Guid" value="@guid" />
        <input type="hidden" id="_AttachmentFields" name="_AttachmentFields" value="@Html.GetAttachmentFields("pa_member")" />
        <button type="button" class="btn btn-sm btn-primary ui-pagePost" data-custom-params="url:'@Url.Action()',callBack:'PostRefreshBack'">提交</button>
        <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
        <span class="help-block"></span>
    </div>
</form>

<script type="text/javascript">
    function BeforeSubmit() {
         @Html.Raw(beforeSubmitJs)
        return true;
    }

    var id = Request("id");
    if (id != "") {
        $("#MemberGroupId").SelectBind();
        $("#DepartmentId").SelectBind();
        $("#_form").FormBind({ dataSourceFrom: "attr" });
        $("#oldPassword").val($("#Password").val());
        $("#Password").val("");
    }
</script>
