Former-commit-id: 8e0beecf6751fb157f35cdef84af818382b6565d
Former-commit-id: f78490fece85f82a7cd770af1c9622a4fc2f5214
1.0
wanggang 5 years ago
parent eb92c6b529
commit 4ea72c2b84

@ -38,6 +38,12 @@ namespace Infrastructure.Extensions
}; };
return (T)target.InjectFrom(injection, source); return (T)target.InjectFrom(injection, source);
} }
public static T FromWhere<T>(this T target, object source, Func<PropertyInfo,PropertyInfo,bool> update)
{
var injection = new NullableInjection { update = update };
return (T)target.InjectFrom(injection, source);
}
} }
public class NullableInjection : LoopInjection public class NullableInjection : LoopInjection
@ -47,6 +53,8 @@ namespace Infrastructure.Extensions
public Func<PropertyInfo, bool> SkipFunc { get; set; } public Func<PropertyInfo, bool> SkipFunc { get; set; }
public bool SkipReadonly { get; set; } public bool SkipReadonly { get; set; }
public Func<PropertyInfo, PropertyInfo,bool> update { get; set; }
protected override bool MatchTypes(Type sourceType, Type targetType) protected override bool MatchTypes(Type sourceType, Type targetType)
{ {
var snt = Nullable.GetUnderlyingType(sourceType); var snt = Nullable.GetUnderlyingType(sourceType);
@ -59,6 +67,13 @@ namespace Infrastructure.Extensions
protected override void SetValue(object source, object target, PropertyInfo sp, PropertyInfo tp) protected override void SetValue(object source, object target, PropertyInfo sp, PropertyInfo tp)
{ {
if(this.update is not null)
{
if(!update.Invoke(sp,tp))
{
return;
}
}
if (sp is null) if (sp is null)
{ {
throw new ArgumentNullException(nameof(sp)); throw new ArgumentNullException(nameof(sp));

@ -210,8 +210,9 @@ namespace TeacherExt.Controllers
ToStatus = model.CheckStatus ToStatus = model.CheckStatus
}); });
} }
entity.From(model); this.UpdateInternal(entity,model);
this.ModelToEntity(model, entity); //entity.From(model);
//this.ModelToEntity(model, entity);
this._personRepo.SaveChanges(); this._personRepo.SaveChanges();
if (this.IsJsonRequest()) if (this.IsJsonRequest())
{ {
@ -223,6 +224,67 @@ namespace TeacherExt.Controllers
model.LoginName = login.LoginName; model.LoginName = login.LoginName;
return Result<EditTeacherModel>(model); return Result<EditTeacherModel>(model);
} }
private void UpdateInternal(Person entity, EditTeacherModel model)
{
var self = this.HttpContext.Request.Query.ContainsKey("self") || (this.HttpContext.Request.Method == "POST" && this.HttpContext.Request.Form.ContainsKey("self"));
if(self)
{
if (entity.CheckStatus==model.CheckStatus)
{
if(model.CheckStatus== "未提交"||model.CheckStatus== "审核失败")
{
entity.From(model);
this.ModelToEntity(model, entity);
}
else
{
if(entity.RequestEditStatus!=model.RequestEditStatus)
{
entity.RequestEditStatus = model.RequestEditStatus;
}
}
}
else
{
if (entity.CheckStatus == "未提交" || entity.CheckStatus == "审核失败")
{
if (model.CheckStatus == "待审核")
{
entity.From(model);
this.ModelToEntity(model, entity);
}
}
}
}
else
{
if (User.IsInRole("城中区教育局管理员"))
{
if (model.CheckStatus == "未提交"&&model.RequestEditStatus== "未申请")
{
entity.CheckStatus = model.CheckStatus;
entity.RequestEditStatus = model.RequestEditStatus;
entity.Comment = model.Comment;
}
}
else if (User.IsInRole("学校管理员"))
{
if (model.CheckStatus == "审核成功" || model.CheckStatus == "审核失败")
{
entity.Comment = model.Comment;
entity.CheckStatus = model.CheckStatus;
entity.FromWhere(model,(s,t)=>s.Name.EndsWith("Checked"));
}
if (entity.RequestEditStatus!=model.RequestEditStatus)
{
entity.CheckStatus = model.CheckStatus;
entity.RequestEditStatus = model.RequestEditStatus;
}
}
}
}
private void ValidModelStatus(Person entity, EditTeacherModel model) private void ValidModelStatus(Person entity, EditTeacherModel model)
{ {
var self = this.HttpContext.Request.Query.ContainsKey("self") || (this.HttpContext.Request.Method == "POST" && this.HttpContext.Request.Form.ContainsKey("self")); var self = this.HttpContext.Request.Query.ContainsKey("self") || (this.HttpContext.Request.Method == "POST" && this.HttpContext.Request.Form.ContainsKey("self"));
@ -271,11 +333,11 @@ namespace TeacherExt.Controllers
ModelState.AddModelError(nameof(model.CheckStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.CheckStatus}]状态"); ModelState.AddModelError(nameof(model.CheckStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.CheckStatus}]状态");
} }
} }
if(model.RequestEditStatus== "未申请") if(entity.RequestEditStatus != model.RequestEditStatus)
{ {
if(entity.RequestEditStatus!="已申请") if(entity.CheckStatus!="待审核"&& entity.CheckStatus != "审核成功")
{ {
ModelState.AddModelError(nameof(model.RequestEditStatus), $"无法从[{entity.CheckStatus}]状态修改为[{model.RequestEditStatus}]状态"); ModelState.AddModelError(nameof(model.RequestEditStatus), $"无法从[{entity.RequestEditStatus}]状态修改为[{model.RequestEditStatus}]状态");
} }
} }
} }

@ -5,7 +5,7 @@
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<GenerateAssemblyProductAttribute>true</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>true</GenerateAssemblyProductAttribute>
<Version>0.7.0.0</Version> <Version>0.8.0.0</Version>
<UserSecretsId>13a75881-1072-47ca-88e9-4d78bd678d65</UserSecretsId> <UserSecretsId>13a75881-1072-47ca-88e9-4d78bd678d65</UserSecretsId>
</PropertyGroup> </PropertyGroup>

@ -81,7 +81,7 @@
} }
@Html.ValidationMessage(prop.PropertyName, new { @class = "text-danger" }) @Html.ValidationMessage(prop.PropertyName, new { @class = "text-danger" })
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2 checkbox">
@{ @{
var checkedProp = props.FirstOrDefault(o => o.PropertyName == prop.PropertyName + "Checked"); var checkedProp = props.FirstOrDefault(o => o.PropertyName == prop.PropertyName + "Checked");
@if (checkedProp != null) @if (checkedProp != null)
@ -130,11 +130,8 @@
</div> </div>
<div class="col-sm-2"></div> <div class="col-sm-2"></div>
</div> </div>
<div class="row"> <div class="row text-center">
<div class="col-sm-6"> <div class="col-sm-12">
<div class="form-group row">
<div class="col-sm-4"> </div>
<div class="col-sm-8">
@if (!iframe) @if (!iframe)
{ {
<a href="@Url.Action("Index","Home")" class="btn btn-primary">返回</a> <a href="@Url.Action("Index","Home")" class="btn btn-primary">返回</a>
@ -184,8 +181,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</form> </form>
</div> </div>
@section scripts{ @section scripts{

@ -163,3 +163,6 @@ button.swal2-styled{
.swal2-popup{ .swal2-popup{
width:16em!important; width:16em!important;
} }
.swal2-title {
font-size: 14px !important;
}

@ -42,7 +42,7 @@ $('#cancelModifyRequest').click(function () {
}); });
}); });
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//批准申请修改 //退回
$('#super').click(function () { $('#super').click(function () {
var form = $(this).parents('form'); var form = $(this).parents('form');
var msg = '确认' + $(this).text() + ''; var msg = '确认' + $(this).text() + '';
@ -55,6 +55,13 @@ $('#super').click(function () {
//审核成功 //审核成功
$('#admin1').click(function () { $('#admin1').click(function () {
var form = $(this).parents('form'); var form = $(this).parents('form');
if (form.find("input[name$='Checked']").filter(':visible').not(':checked').length > 0) {
Swal.fire({
position: 'bottom',
text: '请审核全部待审核项',
confirmButtonText: '确定'});
return;
}
var msg = '确认' + $(this).text() + ''; var msg = '确认' + $(this).text() + '';
submit(msg, function () { submit(msg, function () {
$('#Comment').val(''); $('#Comment').val('');
@ -65,6 +72,14 @@ $('#admin1').click(function () {
//审核失败 //审核失败
$('#admin2').click(function () { $('#admin2').click(function () {
var form = $(this).parents('form'); var form = $(this).parents('form');
if (!$('#Comment').val()) {
Swal.fire({
position: 'bottom',
text: '请填写审核失败原因',
confirmButtonText: '确定'
});
return;
}
var msg = '确认' + $(this).text() + ''; var msg = '确认' + $(this).text() + '';
submit(msg, function () { submit(msg, function () {
$('#CheckStatus').val('审核失败'); $('#CheckStatus').val('审核失败');

Loading…
Cancel
Save