92 lines
3.5 KiB
Plaintext
Raw Normal View History

2024-05-29 16:47:24 +04:00
@using ServiceStationContracts.ViewModels
@model List<CarViewModel>
2024-04-30 16:28:34 +04:00
@{
ViewData["Title"] = "UpdateTechnicalWork";
}
<form method="post">
2024-05-29 19:12:54 +04:00
<div class="container d-flex justify-content-center align-items-center w-75">
2024-04-30 16:28:34 +04:00
<div class="card-body ">
<div class="form-group">
<label>ТО: </label>
<select id="technicalWork" name="technicalWork" class="form-control" asp-items="@(new SelectList(@ViewBag.TechnicalWorks, "Id", "WorkType", "WorkPrice"))"></select>
2024-04-30 16:28:34 +04:00
</div>
<div class="form-group">
<label>Тип ТО</label>
2024-05-29 16:47:24 +04:00
<input type="text" id="worktype" placeholder="Введите тип то" name="worktype" class="form-control" />
2024-04-30 16:28:34 +04:00
</div>
<div class="form-group">
<label>Цена</label>
2024-05-29 16:47:24 +04:00
<input type="number" min="100" step="100" id="workPrice" placeholder="Введите цену" name="workPrice" class="form-control" />
2024-04-30 16:28:34 +04:00
</div>
2024-05-29 16:47:24 +04:00
<h5>Уже привязанные машины</h5>
2024-04-30 16:28:34 +04:00
<table class="table">
<thead>
<tr>
<th scope="col">Номер машины</th>
<th scope="col">Марка машины</th>
</tr>
</thead>
<tbody id="table-elements">
2024-04-30 16:28:34 +04:00
@* полученные машины *@
</tbody>
</table>
2024-05-29 16:47:24 +04:00
<h5>Изменить машины</h5>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Номер машины</th>
<th scope="col">Марка машины</th>
</tr>
</thead>
<tbody>
@foreach (var car in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="car[]" value="@car.Id" id="@car.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => car.CarNumber)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => car.CarBrand)</td>
</tr>
}
</tbody>
</table>
2024-04-30 16:28:34 +04:00
<br>
<div>
<input type="submit" value="Сохранить" class="btn btn-secondary text-center" />
</div>
</div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var technicalWork = $('#technicalWork').val();
if (technicalWork) {
$.ajax({
method: "GET",
url: "/Home/GetTechnicalWork",
data: { technicalWorkId: technicalWork },
success: function (result) {
2024-05-29 16:47:24 +04:00
$('#worktype').val(result.item1.workType);
$('#workPrice').val(result.item1.workPrice);
$('#table-elements').html(result.item2);
}
});
};
}
check();
$('#technicalWork').on('change', function () {
check();
});
</script>
}