@{
    CurrentUser user = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList((string)ViewBag.Table, action, user);
    string guid = Html.Guid();
}
<div class="main">
    <form method="post" id="_form" class=" form  form-lg" data-source="@Model">
        <div class="form-group">
            <label class="control-label">名称</label>
            <div class="controls">
                <input type="text" id="Name" name="Name" maxlength="50" class="form-control" data-validate="dataType:'*',checkUrl:'@Url.Action("CheckExists",new {id=Request.QueryString["id"],area="admin"})',checkError:'部门重复，请重写输入！'" />
                <span class="help-block"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label radio">是否最终节点</label>
            <div class="controls">
                <label class="radio-inline"><input name="IsFinal" id="IsFinal" checked value="1" type="radio">是</label>
                <label class="radio-inline"><input name="IsFinal" id="IsFinal" value="0" type="radio">否</label>
                <span class="help-block">最终节点不能再继续增加子部门</span>
            </div>
        </div>


        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("from", "admin");
            data.Add("guid", guid);
            data.Add("currentUser", ViewBag.CurrentUser);
            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++;
                }
            }
        }
        <script type="text/javascript">
            function BeforeSubmit() {
               @Html.Raw(beforeSubmitJs)
                return true;
            }
        </script>

        <div class="form-group">
            <label class="control-label">序号</label>
            <div class="controls">
                <input type="text" id="Xuhao" name="Xuhao" value="1" maxlength="5" data-validate="dataType:'numeric',errorMsg:'请填写数字！'" class="form-control form-control-xs ui-queryString" />
                <span class="help-block"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label"></label>
            <div class="controls">
                @Html.AntiForgeryToken()
                <input type="hidden" id="Id" name="Id" value="0" />
                <input type="hidden" id="Level" name="Level" value="0" />
                <input type="hidden" id="Guid" name="Guid" value="@guid" />
                <input type="hidden" id="ParentId" name="ParentId" value="@Request.QueryString["parentId"]" />
                <button type="button" class="btn btn-sm btn-primary ui-pagePost" id="bt_submit" data-custom-params="url:'@Url.ActionUrl()',callBack:'PostRefreshBack'">提交</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    //绑定数据
    var id = Request("id");
    if (id != "") {
        $("#_form").FormBind({ dataSourceFrom: "attr" });
        $("[name='IsFinal']").attr("disabled", "disabled")
    }
</script>
