diff --git a/labs/Teacher/TeacherExt/Controllers/HomeController.cs b/labs/Teacher/TeacherExt/Controllers/HomeController.cs index 3cfa7890..2bced4f7 100644 --- a/labs/Teacher/TeacherExt/Controllers/HomeController.cs +++ b/labs/Teacher/TeacherExt/Controllers/HomeController.cs @@ -121,36 +121,6 @@ namespace TeacherExt.Controllers return result; } - [HttpGet] - public IActionResult Edit(int id) - { - var person = this._personRepo.ReadOnlyTable().Where(o => o.Id == id).FirstOrDefault(); - var organ = this._organizationRepo.ReadOnlyTable().Where(o => o.Id == person.OrganId).FirstOrDefault(); - - var model = person.To(); - model.OrganName = organ.Name; - this.EntityToModel(person, model); - this.ToEditModel(person, model); - return Result(model); - } - - [HttpPost] - public IActionResult Edit([FromForm] EditTeacherModel model) - { - ValidEditModel(model); - var entity = this._personRepo.Table().Where(o => o.Id == model.Id).FirstOrDefault(); - if (ModelState.IsValid) - { - entity.From(model); - this.ModelToEntity(model,entity); - this._personRepo.SaveChanges(); - return Success(); - } - this.EntityToModel(entity, model); - this.ToEditModel(entity, model); - return View(model); - } - private void ModelToEntity(EditTeacherModel model, Person entity) { if(!string.IsNullOrWhiteSpace(entity.IdNumber)) @@ -163,42 +133,6 @@ namespace TeacherExt.Controllers } } - [HttpGet] - public IActionResult Details(int id) - { - return this.Edit(id); - } - - [HttpPost] - public IActionResult Details([FromForm] EditTeacherModel model) - { - ValidEditModel(model); - var entity = this._personRepo.Table().Where(o => o.Id == model.Id).FirstOrDefault(); - var login = this._loginRepo.ReadOnlyTable().Where(o => o.PersonId == model.Id).FirstOrDefault(); - if (ModelState.IsValid) - { - if (entity.CheckStatus != model.CheckStatus) - { - this._checkLogRepo.Add(new CheckLog - { - UpdateBy = User.Identity.Name, - UpdateAt = DateTime.Now, - LoginName = login.LoginName, - RealName = login.RealName, - FromStatus = entity.CheckStatus, - ToStatus = model.CheckStatus - }); - } - entity.From(model); - this.ModelToEntity(model, entity); - this._personRepo.SaveChanges(); - return Success(); - } - this.EntityToModel(entity, model); - this.ToEditModel(entity, model); - return Result(model); - } - [HttpGet] public IActionResult Update(int id) diff --git a/labs/Teacher/TeacherExt/Startup.cs b/labs/Teacher/TeacherExt/Startup.cs index 6a944730..3d0e4c1f 100644 --- a/labs/Teacher/TeacherExt/Startup.cs +++ b/labs/Teacher/TeacherExt/Startup.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; using System; +using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Text.Unicode; @@ -60,9 +61,19 @@ namespace TeacherExt services.AddTransient(); services.AddTransient(); services.AddTransient(); + + services.AddLocalization(options => options.ResourcesPath = null); services.AddMvc() .AddNewtonsoftJson() - .AddControllersAsServices(); + .AddControllersAsServices() + .AddDataAnnotationsLocalization(options => + { + options.DataAnnotationLocalizerProvider = (type, factory) => + { + var localizer = factory.Create("Resources.Resource", Assembly.GetEntryAssembly().GetName().Name); + return localizer; + }; + }); services.AddControllers() .ConfigureApiBehaviorOptions(options => { diff --git a/labs/Teacher/TeacherExt/Views/Account/Login.cshtml b/labs/Teacher/TeacherExt/Views/Account/Login.cshtml index 76cbe744..ae325523 100644 --- a/labs/Teacher/TeacherExt/Views/Account/Login.cshtml +++ b/labs/Teacher/TeacherExt/Views/Account/Login.cshtml @@ -44,26 +44,6 @@ -
-

- 测试账号(密码统一为6个1): -

-

- 局管理员:admin -

-

- 校管理员:admin1 admin2 -

-

- 校长:xiaozhang1 xiaozhang2 -

-

- 老师:laoshi1 laoshi2 -

-

- 职工:zhigong1 zhigong2 -

-

审核状态:未提交、待审核、审核成功、审核失败

\ No newline at end of file diff --git a/labs/Teacher/TeacherExt/Views/Home/Edit.cshtml b/labs/Teacher/TeacherExt/Views/Home/Edit.cshtml index c18fc744..2593f51e 100644 --- a/labs/Teacher/TeacherExt/Views/Home/Edit.cshtml +++ b/labs/Teacher/TeacherExt/Views/Home/Edit.cshtml @@ -84,7 +84,7 @@ @if (checkedProp != null) {
- @Html.Hidden(prop.PropertyName) + @Html.Hidden(checkedProp.PropertyName) @Html.Display(checkedProp.PropertyName, uihit)
} diff --git a/labs/Teacher/TeacherExt/Views/Home/Index.cshtml b/labs/Teacher/TeacherExt/Views/Home/Index.cshtml index 27e7f405..5e1ee60f 100644 --- a/labs/Teacher/TeacherExt/Views/Home/Index.cshtml +++ b/labs/Teacher/TeacherExt/Views/Home/Index.cshtml @@ -88,7 +88,7 @@ - + @@ -110,17 +110,25 @@
行号申请修改状态申请修改 审核状态 姓名 性别@item.nation_name @item.placeofbirth - @if (User.IsInRole("城中区教育局管理员") && item.CheckStatus == "审核成功") + @if (User.IsInRole("城中区教育局管理员")) { - 驳回 - } - else if (User.IsInRole("学校管理员") && item.CheckStatus == "待审核") - { - 审核 + 查看 + @if (item.CheckStatus == "审核成功") + { + 退回 + } } - else + @if (User.IsInRole("学校管理员")) { 查看 + @if (item.CheckStatus == "待审核") + { + 审核 + } + @if (item.RequestEditStatus == "已申请") + { + 批准 + } } diff --git a/labs/Teacher/TeacherExt/Views/Home/Update.cshtml b/labs/Teacher/TeacherExt/Views/Home/Update.cshtml index 960aeb7f..07da3b02 100644 --- a/labs/Teacher/TeacherExt/Views/Home/Update.cshtml +++ b/labs/Teacher/TeacherExt/Views/Home/Update.cshtml @@ -79,12 +79,12 @@ {
@if (isCheck) { - @Html.Editor(prop.PropertyName, uihit) + @Html.Editor(checkedProp.PropertyName) } else {
- @Html.Hidden(prop.PropertyName) + @Html.Hidden(checkedProp.PropertyName) @Html.Display(checkedProp.PropertyName, "Bool")
} @@ -118,20 +118,43 @@
- @if (Model != null) + @if (User.IsInRole("城中区教育局管理员")) { - if (new string[] { "未提交", "审核失败" }.Contains(Model.CheckStatus)) + @if (Model.CheckStatus == "审核成功") { - - + + } + } + else if (User.IsInRole("学校管理员")) + { + @if (Model.CheckStatus == "待审核") + { + + + } + @if (Model.RequestEditStatus == "已申请") + { + } - else if (Model.RequestEditStatus == "已申请") + else + { + + } + } + @if (User.Identity.Name == Model.LoginName) + { + if (Model.CheckStatus == "未提交" || Model.CheckStatus == "审核失败") { - + + } else { - if (new string[] { "待审核", "审核成功" }.Contains(Model.CheckStatus)) + if (Model.RequestEditStatus == "已申请") + { + + } + else { } @@ -146,17 +169,97 @@
@section scripts{ + +