92 lines
3.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@using ServiceStationContracts.ViewModels
@model List<CarViewModel>
@{
ViewData["Title"] = "UpdateTechnicalWork";
}
<form method="post">
<div class="container d-flex justify-content-center align-items-center w-75">
<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>
</div>
<div class="form-group">
<label>Тип ТО</label>
<input type="text" id="worktype" placeholder="Введите тип то" name="worktype" class="form-control" />
</div>
<div class="form-group">
<label>Цена</label>
<input type="number" min="100" id="workPrice" placeholder="Введите цену" name="workPrice" class="form-control" />
</div>
<h5>Уже привязанные машины</h5>
<table class="table">
<thead>
<tr>
<th scope="col">Номер машины</th>
<th scope="col">Марка машины</th>
</tr>
</thead>
<tbody id="table-elements">
@* полученные машины *@
</tbody>
</table>
<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>
<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) {
$('#worktype').val(result.item1.workType);
$('#workPrice').val(result.item1.workPrice);
$('#table-elements').html(result.item2);
}
});
};
}
check();
$('#technicalWork').on('change', function () {
check();
});
</script>
}