нанофиксы

This commit is contained in:
sardq 2024-05-27 20:35:59 +04:00
parent e467c50904
commit 940fde0056
2 changed files with 116 additions and 19 deletions

View File

@ -215,25 +215,48 @@ namespace FactoryWorkerApp.Controllers
};
return View(reports);
}
[HttpGet]
public IActionResult WorkpieceTimeChoose()
{
if (!IsLoggedIn)
return RedirectToAction("Index");
return View();
}
[HttpPost]
public IActionResult SendReport()
{
return Ok();
}
[HttpPost]
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
{
if (!IsLoggedIn)
return RedirectToAction("Index");
HttpContext.Session.SetString("StartDate", startDate.ToString());
HttpContext.Session.SetString("EndDate", endDate.ToString());
return RedirectToAction("DetailTimeReport");
}
[HttpGet]
public IActionResult WorkpieceDateReport()
{
List<WorkpieceTimeReportViewModel> workpieceTimeReports = new List<WorkpieceTimeReportViewModel>
{
new WorkpieceTimeReportViewModel
{
WorkpieceName = "Заготовка А",
ExecutionPhases = new List<string> { "Этап 1", "Этап 2" },
Machines = new List<string> { "Станок X", "Станок Y" }
},
new WorkpieceTimeReportViewModel
{
WorkpieceName = "Деталь B",
ExecutionPhases = new List<string> { "Этап 3", "Этап 4" },
Machines = new List<string> { "Станок Z", "Станок W" }
}
};
return View(workpieceTimeReports);
var startDateStr = HttpContext.Session.GetString("StartDate");
var endDateStr = HttpContext.Session.GetString("EndDate");
var startDate = DateTime.Parse(startDateStr);
var endDate = DateTime.Parse(endDateStr).AddDays(1);
var values = _logic.GetTimeReport(startDate, endDate, UserId);
ViewBag.StartDate = startDate;
ViewBag.EndDate = endDate;
return View(values);
}
[HttpGet]

View File

@ -0,0 +1,74 @@
@{
ViewData["Title"] = "Создание отчета";
}
<div class="text-center">
<h2 class="display-4">Создание отчета</h2>
</div>
<form id="TimeReportWeb" method="post">
<div class="row mb-3">
<div class="col-4 text-right">
<label for="startDate">Дата начала:</label>
</div>
<div class="col-6">
<input type="date" id="startDate" name="startDate" class="form-control" required />
<span id="startDateError" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<div class="col-4 text-right">
<label for="endDate">Дата окончания:</label>
</div>
<div class="col-6">
<input type="date" id="endDate" name="endDate" class="form-control" required />
<span id="endDateError" class="text-danger"></span>
</div>
</div>
<div class="row mb-3">
<div class="col-6 text-right">
<button type="button" id="generateReport" class="btn btn-primary">Создать отчет</button>
</div>
</div>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
function validateDates() {
var startDate = new Date($('#startDate').val());
var endDate = new Date($('#endDate').val());
var today = new Date();
var isValid = true;
$('#startDateError').text('');
$('#endDateError').text('');
if (startDate > today) {
$('#startDateError').text('Дата начала не может быть больше сегодняшней даты.');
isValid = false;
}
if (endDate > today) {
$('#endDateError').text('Дата окончания не может быть больше сегодняшней даты.');
isValid = false;
}
if (startDate > endDate) {
$('#endDateError').text('Дата окончания не может быть раньше даты начала.');
isValid = false;
}
return isValid;
}
$('#generateReport').click(function () {
if (validateDates()) {
var formData = $('#TimeReportWeb').serialize();
$.post('/Home/TimeReportWeb', formData, function (response) {
window.location.href = '/Home/DetailTimeReport';
}).fail(function () {
alert('Произошла ошибка при создании отчета.');
});
}
});
});
</script>