@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("城中区教育局管理员"); }
@Html.AntiForgeryToken() @if (Context.Request.Query.ContainsKey("iframe")||(Context.Request.Method=="POST"&&Context.Request.Form.ContainsKey("iframe"))) { @Html.Hidden("iframe","") }
@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 ((Model.CheckStatus == "未提交" || Model.CheckStatus == "审核失败") && User.Identity.Name == Model.LoginName) { @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 (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 (isCheck) { @Html.TextAreaFor(o => o.Comment, new { @class = "form-control" }) } else {
@Html.HiddenFor(o => o.Comment) @Html.DisplayFor(o => o.Comment)
}
@if (!Context.Request.Query.ContainsKey("iframe")) { 返回 } @if (User.Identity.Name == Model.LoginName) { @if (Model.CheckStatus == "未提交" || Model.CheckStatus == "审核失败") { } else { if (Model.RequestEditStatus == "已申请") { } else { } } } @if (User.IsInRole("城中区教育局管理员") && Model.CheckStatus == "审核成功") { 教育局管理员: } else if (User.IsInRole("学校管理员")) { @if (Model.CheckStatus == "待审核") { 学校管理员: } @if (Model.RequestEditStatus == "已申请") { 学校管理员: } }
@section scripts{ }