|
|
@model EditTeacherModel
|
|
|
@using System.Reflection
|
|
|
@using System.ComponentModel
|
|
|
@using Microsoft.AspNetCore.Mvc.Controllers
|
|
|
@using Infrastructure.Web.Mvc
|
|
|
@{
|
|
|
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
|
|
|
var controller = this.ViewContext.RouteData.Values["controller"].ToString();
|
|
|
var action = this.ViewContext.RouteData.Values["action"].ToString();
|
|
|
var url = HtmlAction ?? (ViewData.Keys.Any(o => o.ToLower() == "returnurl") ? Url.Action(null, null, new { ReturnUrl = ViewData["ReturnUrl"] }) : Url.Action(null, null));
|
|
|
var props = ViewData.ModelMetadata.Properties;
|
|
|
}
|
|
|
<div class="card card-info">
|
|
|
<form action="@url" method="post" class="form-horizontal">
|
|
|
<div class="card-body">
|
|
|
<div class="row">
|
|
|
@Html.AntiForgeryToken()
|
|
|
<div class="col-sm-12">
|
|
|
<div class="form-group row">
|
|
|
<div class="col-sm-2 col-form-label"></div>
|
|
|
@Html.ValidationSummary(true, "错误:", new { @class = "text-danger col-sm-10" }, "div")
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="row">
|
|
|
@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<DescriptionAttribute>().FirstOrDefault() as DescriptionAttribute)?.Description;
|
|
|
if (prop.PropertyName.EndsWith("Checked"))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (isHidden)
|
|
|
{
|
|
|
@Html.Hidden(prop.PropertyName)
|
|
|
continue;
|
|
|
}
|
|
|
if (action == "Edit")
|
|
|
{
|
|
|
isReadOnly = isReadOnly || metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(ReadOnlyForEditAttribute));
|
|
|
}
|
|
|
if (prop.HideSurroundingHtml || isDisplayOnly)
|
|
|
{
|
|
|
@Html.Hidden(prop.PropertyName)
|
|
|
continue;
|
|
|
}
|
|
|
var uihit = prop.DataTypeName ?? prop.TemplateHint;
|
|
|
<div class="col-sm-4">
|
|
|
<div class="form-group row @prop.ModelType.Name @uihit">
|
|
|
@Html.Label(prop.PropertyName, prop.GetDisplayName() + ":", new { @class = "col-sm-5 col-form-label" })
|
|
|
<div class="col-sm-6" title="@desc">
|
|
|
@if (isReadOnly|| prop.PropertyName.EndsWith("Comment"))
|
|
|
{
|
|
|
<div class="form-control" style="border-color:transparent;height:auto;padding-left:0;">
|
|
|
@Html.Hidden(prop.PropertyName)
|
|
|
@Html.Display(prop.PropertyName, uihit)
|
|
|
</div>
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var checkedProp = props.FirstOrDefault(o => o.PropertyName == prop.PropertyName + "Checked");
|
|
|
@if (!new string[] { "未提交", "校级审核失败", "局级审核失败" }.Contains(Model.CheckStatus))
|
|
|
{
|
|
|
@Html.Hidden(prop.PropertyName)
|
|
|
<div class="form-control" style="border-color:transparent;height:auto;padding-left:0;">
|
|
|
@Html.Display(prop.PropertyName, uihit)
|
|
|
</div>
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@Html.Editor(prop.PropertyName, uihit)
|
|
|
}
|
|
|
}
|
|
|
@Html.ValidationMessage(prop.PropertyName, new { @class = "text-danger" })
|
|
|
</div>
|
|
|
<div class="col-sm-1">
|
|
|
@if (!isReadOnly)
|
|
|
{
|
|
|
var checkedProp = props.FirstOrDefault(o => o.PropertyName == prop.PropertyName + "Checked");
|
|
|
@if (checkedProp != null)
|
|
|
{
|
|
|
<div class="form-control" style="border-color:transparent;padding-left:0;">
|
|
|
@Html.Hidden(checkedProp.PropertyName)
|
|
|
@Html.Display(checkedProp.PropertyName, uihit)
|
|
|
</div>
|
|
|
}
|
|
|
}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
}
|
|
|
</div>
|
|
|
<div class="row">
|
|
|
<div class="col-sm-6">
|
|
|
<div class="form-group row">
|
|
|
<div class="col-sm-4"> </div>
|
|
|
<div class="col-sm-8">
|
|
|
@if (Model != null)
|
|
|
{
|
|
|
if (new string[] { "未提交", "审核失败" }.Contains(Model.CheckStatus))
|
|
|
{
|
|
|
<button class="btn btn-primary" type="submit">保存</button>
|
|
|
<button id="submitCheckRequest" type="button" class="btn btn-primary">提交审核</button>
|
|
|
}
|
|
|
if (Model.RequestEditStatus == "已申请")
|
|
|
{
|
|
|
<button id="cancelModifyRequest" type="button" class="btn btn-primary">取消申请</button>
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (new string[] { "待审核", "审核成功" }.Contains(Model.CheckStatus))
|
|
|
{
|
|
|
<button id="submitModifyRequest" type="button" class="btn btn-primary">申请修改</button>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
|
@section scripts{
|
|
|
@(await Html.PartialAsync("_Script"))
|
|
|
<script>
|
|
|
$('#submitCheckRequest').click(function () {
|
|
|
$('#CheckStatus').val('待审核');
|
|
|
$(this).parents('form').submit();
|
|
|
});
|
|
|
$('#cancelModifyRequest').click(function () {
|
|
|
$('#RequestEditStatus').val('未申请');
|
|
|
$(this).parents('form').submit();
|
|
|
});
|
|
|
$('#submitModifyRequest').click(function () {
|
|
|
$('#RequestEditStatus').val('已申请');
|
|
|
$(this).parents('form').submit();
|
|
|
});
|
|
|
</script>
|
|
|
} |