Рабочий выбор файла для списка + фикс заголовка на форме со списком

This commit is contained in:
abazov73 2023-05-20 03:28:54 +04:00
parent b9f9b339ac
commit e71d4a92b9
3 changed files with 30 additions and 16 deletions

View File

@ -266,7 +266,7 @@ namespace OperatorApp.Controllers
} }
[HttpPost] [HttpPost]
public IActionResult PaymentsReport(List<int> payments, bool word, bool excel) public IActionResult PaymentsReport(List<int> payments, string doctype)
{ {
List<PaymentBindingModel> paymentBindings = new List<PaymentBindingModel>(); List<PaymentBindingModel> paymentBindings = new List<PaymentBindingModel>();
foreach (int paymentId in payments) foreach (int paymentId in payments)
@ -281,16 +281,16 @@ namespace OperatorApp.Controllers
DealPayments = paymentView.DealPayments DealPayments = paymentView.DealPayments
}); });
} }
//if (word) if (doctype.Equals("word"))
//{ {
MemoryStream list = _reportLogic.SavePaymentPurchaseToWord(new ReportBindingModel { FileName = "test" }, paymentBindings); MemoryStream list = _reportLogic.SavePaymentPurchaseToWord(new ReportBindingModel { FileName = "test" }, paymentBindings);
return File(list, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "testDoc.docx"); return File(list, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "testDoc.docx");
//} }
//else else
//{ {
// MemoryStream list = _reportLogic.SavePaymentPurchaseToExcel(new ReportBindingModel { FileName = "test" }, paymentBindings); MemoryStream list = _reportLogic.SavePaymentPurchaseToExcel(new ReportBindingModel { FileName = "test" }, paymentBindings);
// return File(list, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testExcel.xlsx"); return File(list, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testExcel.xlsx");
//} }
} }
[HttpGet] [HttpGet]

View File

@ -12,10 +12,13 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-8">Word</div> <div class="col-4">Word</div>
<div class="col-4"><input id="word" type="radio" name="doctype" /></div> @Html.RadioButton("doctype", "word", true)
<div class="col-8">Excel</div>
<div class="col-4"><input id="excel" type="radio" name="doctype" /></div> </div>
<div class="row">
<div class="col-4">Excel</div>
@Html.RadioButton("doctype", "excel")
</div> </div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>

View File

@ -5,7 +5,7 @@
ViewData["Title"] = "TransfersReport"; ViewData["Title"] = "TransfersReport";
} }
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Создание отчёта</h2> <h2 class="display-4">Создание списка</h2>
</div> </div>
<form asp-action="ViewReport" method="get"> <form asp-action="ViewReport" method="get">
<div class="row"> <div class="row">
@ -13,11 +13,22 @@
<div class="col-8"> <div class="col-8">
@Html.EditorFor(x => x.DateFrom, new { htmlAttributes = new { @class = "form-control my-3", @type = "date", @name="DateFrom", @required="true", @id="DateFrom" } }) @Html.EditorFor(x => x.DateFrom, new { htmlAttributes = new { @class = "form-control my-3", @type = "date", @name="DateFrom", @required="true", @id="DateFrom" } })
</div> </div>
</div>
<div class="row">
<div class="col-4">По:</div> <div class="col-4">По:</div>
<div class="col-8"> <div class="col-8">
@Html.EditorFor(x => x.DateTo, new { htmlAttributes = new { @class = "form-control my-3", @type = "date", @name="DateTo", @required="true", @id="DateTo" } }) @Html.EditorFor(x => x.DateTo, new { htmlAttributes = new { @class = "form-control my-3", @type = "date", @name="DateTo", @required="true", @id="DateTo" } })
</div> </div>
</div> </div>
<h1>Вывести на:</h1>
<div class="row">
<div class="col-4">На почту (.pdf)</div>
@Html.RadioButton("reptype", "pdf", true)
</div>
<div class="row">
<div class="col-4">На форму</div>
@Html.RadioButton("reptype", "onForm")
</div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div> <div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>