89 lines
3.5 KiB
Plaintext
Raw Normal View History

2024-05-29 22:26:31 +04:00
@using ServiceStationContracts.ViewModels
@model List<SparePartViewModel>
@{
2024-04-30 20:36:13 +04:00
ViewData["Title"] = "UpdateWork";
}
<form method="post">
<div class="container d-flex justify-content-center align-items-center w-50">
<div class="card-body ">
<div class="form-group">
<label>Работа: </label>
<select id="work" name="work" class="form-control" asp-items="@(new SelectList(@ViewBag.Works, "Id", "WorkName", "WorkPrice"))"></select>
2024-04-30 20:36:13 +04:00
</div>
<div class="form-group">
<label>Название работы</label>
<input type="text" id="workName" placeholder="Введите название работы" name="workName" class="form-control" />
</div>
<div class="form-group">
<label>Стоимость работы</label>
<input type="number" min="0" step="100" id="workPrice" placeholder="Введите стоимость работы" name="workPrice" class="form-control" />
2024-04-30 20:36:13 +04:00
</div>
2024-05-29 22:26:31 +04:00
<h5>Уже привязанные запчасти</h5>
2024-04-30 20:36:13 +04:00
<table class="table">
<thead>
<tr>
<th scope="col">Название запчасти</th>
2024-05-29 22:26:31 +04:00
<th scope="col">Цена запчасти</th>
2024-04-30 20:36:13 +04:00
</tr>
</thead>
<tbody id="table-elements">
2024-05-29 22:26:31 +04:00
</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 sparepart in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="sparepart[]" value="@sparepart.Id" id="@sparepart.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartName)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartPrice)</td>
</tr>
}
2024-04-30 20:36:13 +04:00
</tbody>
</table>
<br>
<div class="text-center pb-3">
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center w-100" />
</div>
</div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var work = $('#work').val();
if (work) {
$.ajax({
method: "GET",
url: "/Home/GetWork",
data: { workId: work },
success: function (result) {
2024-05-29 22:26:31 +04:00
$('#workName').val(result.item1.workName);
$('#workPrice').val(result.item1.workPrice);
$('#table-elements').html(result.item2);
}
});
};
}
check();
$('#work').on('change', function () {
check();
});
</script>
}