Word/Excel отчеты
This commit is contained in:
parent
2b59f88981
commit
0d12590f78
@ -18,7 +18,8 @@ namespace TeacherWebClient.Controllers
|
||||
private readonly ITaskLogic _task;
|
||||
private readonly IMaterialLogic _material;
|
||||
private readonly ITeacherLogic _teacher;
|
||||
public HomeController(ILogger<HomeController> logger, IProductLogic product, ILessonLogic lesson, ITaskLogic task, IMaterialLogic material, ITeacherLogic teacher)
|
||||
private readonly IReportLogic _report;
|
||||
public HomeController(ILogger<HomeController> logger, IProductLogic product, ILessonLogic lesson, ITaskLogic task, IMaterialLogic material, ITeacherLogic teacher, IReportLogic report)
|
||||
{
|
||||
_logger = logger;
|
||||
_product = product;
|
||||
@ -26,6 +27,7 @@ namespace TeacherWebClient.Controllers
|
||||
_task = task;
|
||||
_material = material;
|
||||
_teacher = teacher;
|
||||
_report = report;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -417,5 +419,31 @@ namespace TeacherWebClient.Controllers
|
||||
});
|
||||
Response.Redirect("/Home/Tasks");
|
||||
}
|
||||
public IActionResult Reports()
|
||||
{
|
||||
var list = _material.ReadList(new MaterialSearchModel { TeacherId = APIClient.Teacher.Id });
|
||||
var simpMaterial = list.Select(x => new { MaterialId = x.Id, MaterialName = x.Title });
|
||||
ViewBag.Materials = new MultiSelectList(simpMaterial, "MaterialId", "MaterialName");
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult GetPartial(int[] materials, string mode)
|
||||
{
|
||||
var list = materials.Select(x => _material.ReadElement(new MaterialSearchModel { Id = x })).ToList();
|
||||
if (mode.Equals("Excel"))
|
||||
{
|
||||
_report.SaveDiyMaterialToExcelFile
|
||||
(new ReportBindingModel { FileName = $"C:\\Университет\\2 курс\\4 семестр\\РПП\\Курсач РПП\\Reports\\{APIClient.Teacher.Name}-{DateTime.Now.ToString("dd/MM/yyyy")}.xlsx", Materials = list, TeacherId = APIClient.Teacher.Id });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_report.SaveDiyMaterialToWordFile
|
||||
(new ReportBindingModel { FileName = $"C:\\Университет\\2 курс\\4 семестр\\РПП\\Курсач РПП\\Reports\\{APIClient.Teacher.Name}-{DateTime.Now.ToString("dd/MM/yyyy")}.docx", Materials = list, TeacherId = APIClient.Teacher.Id });
|
||||
|
||||
}
|
||||
var items = _report.GetDiyMaterial(new ReportBindingModel { Materials = list, TeacherId = APIClient.Teacher.Id });
|
||||
return PartialView("_DiyListPartial", items);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Изделие:</div>
|
||||
<div class="col-8">
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "Title"))"></select>
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "Title", Model.ProductId))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
23
SchoolAgainStudy/TeacherWebClient/Views/Home/Reports.cshtml
Normal file
23
SchoolAgainStudy/TeacherWebClient/Views/Home/Reports.cshtml
Normal file
@ -0,0 +1,23 @@
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
<form id="my_form" asp-action="Reports" method="get" data-ajax="true" data-ajax-method="get" data-ajax-update="#panel" data-ajax-mode='replace' data-ajax-url="@Url.Action("GetPartial","Home")">
|
||||
<select id="mode" name="mode">
|
||||
<option>Excel</option>
|
||||
<option>Word</option>
|
||||
</select>
|
||||
<div class="row">
|
||||
<div class="col-4">Материалы:</div>
|
||||
<div class="col-8">
|
||||
@Html.ListBox("materials", (MultiSelectList)ViewBag.Materials)
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="row pr-3 pl-3" id="panel">
|
||||
@section scripts{
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
@using SchoolAgainStudyContracts.ViewModel;
|
||||
@model List<ReportDiyMaterialViewModel>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Материалы
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
<select asp-items="@(new SelectList(item.Diys))"></select>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user