@model EditTeacherModel @using System.ComponentModel @{ var url = Url.Action(null, null); var props = ViewData.ModelMetadata.Properties; var isEdit = Model.CheckStatus == "未提交" || Model.CheckStatus == "审核失败"; var isCheck = Model.CheckStatus == "待审核" && User.IsInRole("学校管理员"); isCheck = isCheck || Model.CheckStatus == "审核成功" && User.IsInRole("城中区教育局管理员"); var iframe = Context.Request.Query.ContainsKey("iframe") || (Context.Request.Method == "POST" && Context.Request.Form.ContainsKey("iframe")); var self = Context.Request.Query.ContainsKey("self") || (Context.Request.Method == "POST" && Context.Request.Form.ContainsKey("self")); }
@Html.AntiForgeryToken() @if (iframe) { @Html.Hidden("iframe", "") } @if (self) { @Html.Hidden("self", "") }
@Html.ValidationSummary(true, "错误:", new { @class = "text-danger col-sm-10" }, "div")
@foreach (var prop in props) { var metadata = prop as Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata; var isReadOnly = metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(ReadOnlyAttribute)); var isDisplayOnly = metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(DisplayOnlyAttribute)); var isHidden = metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(HiddenInputAttribute)); var desc = (metadata.Attributes.Attributes.OfType().FirstOrDefault() as DescriptionAttribute)?.Description; var isRequired = metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(RequiredAttribute)); var labelCalss = "col-sm-4 col-form-label" + (isRequired ? " required" : ""); if (prop.PropertyName.EndsWith("Checked") || prop.PropertyName.EndsWith("Comment")) { continue; } if (isHidden) { @Html.Hidden(prop.PropertyName) continue; } if (prop.HideSurroundingHtml || isDisplayOnly) { @Html.Hidden(prop.PropertyName) continue; } var uihit = prop.DataTypeName ?? prop.TemplateHint;
@Html.Label(prop.PropertyName, prop.GetDisplayName(), new { @class = labelCalss })
@if (isReadOnly) {
@Html.Hidden(prop.PropertyName)
@Html.Display(prop.PropertyName, uihit)
} else { if (self && (Model.CheckStatus == "未提交" || Model.CheckStatus == "审核失败")) { @Html.Editor(prop.PropertyName, uihit) } else { @Html.Hidden(prop.PropertyName)
@Html.Display(prop.PropertyName, uihit)
} } @Html.ValidationMessage(prop.PropertyName, new { @class = "text-danger" })
@{ var checkedProp = props.FirstOrDefault(o => o.PropertyName == prop.PropertyName + "Checked"); @if (checkedProp != null) { @if (!self && (Model.CheckStatus == "待审核" && User.IsInRole("学校管理员"))) { @Html.Editor(checkedProp.PropertyName) } else { @Html.Hidden(checkedProp.PropertyName) @Html.Display(checkedProp.PropertyName, "Bool") } } }
}
@Html.LabelFor(o => o.Comment, new { @class = "col-sm-2 col-form-label" })
@if (!self && isCheck) { @Html.TextAreaFor(o => o.Comment, new { @class = "form-control" }) } else {
@Html.HiddenFor(o => o.Comment) @Html.DisplayFor(o => o.Comment)
}
@if (!iframe) { 返回 } @if (self) { @if (Model.CheckStatus == "未提交" || Model.CheckStatus == "审核失败") { } else { if (Model.RequestEditStatus == "已申请") { } else { } } } else { @if (User.IsInRole("城中区教育局管理员") && Model.CheckStatus == "审核成功") { 教育局管理员: } else if (User.IsInRole("学校管理员")) { @if (Model.CheckStatus == "待审核") { 学校管理员: } @if (Model.RequestEditStatus == "已申请") { 学校管理员: } } }
@section scripts{ }