Сделал формы предпродажных
This commit is contained in:
parent
a560a155c4
commit
d30bf4f7ec
190
CarCenter/CarCenterWorkerApp/Views/Home/CreatePresale.cshtml
Normal file
190
CarCenter/CarCenterWorkerApp/Views/Home/CreatePresale.cshtml
Normal file
@ -0,0 +1,190 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@using CarCenterDataModels.Enums;
|
||||
|
||||
@model PresaleViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreatePresale";
|
||||
ViewBag.Bundlings = Model.PresaleBundlings;
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание предпродажной работы</h2>
|
||||
</div>
|
||||
<form id="presaleForm" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Статус:</div>
|
||||
<div class="col-8">
|
||||
<select name="PresaleStatus" id="PresaleStatus" value="@Model.PresaleStatus">
|
||||
@foreach (var value in Enum.GetValues(typeof(PresaleStatus)))
|
||||
{
|
||||
<option value="@value">@value</option>
|
||||
}
|
||||
</select>
|
||||
<span id="PresaleStatusError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="Description" id="Description" value="@Model.Description" />
|
||||
<span id="DescriptionError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Выполнить до:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="DueTill" id="DueTill" value="@Model.DueTill" />
|
||||
<span id="DueTillError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Комплектации</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="bundlingsTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID комплектации</th>
|
||||
<th> </th>
|
||||
<th>Стоимость</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var bundling in ViewBag.Bundlings)
|
||||
{
|
||||
<tr data-bundling-id="@bundling.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="bundlingIds" value="@bundling.Value.Id" />@bundling.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="bundling-price" data-price="@bundling.Value.Price">@bundling.Value.Price</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteBundling" data-bundling-id="@bundling.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="bundlingSelect" class="form-control">
|
||||
<option value="">Выберите комплектацию</option>
|
||||
@foreach (var bundling in ViewBag.AllBundlings)
|
||||
{
|
||||
<option value="@bundling.Id" data-price="@bundling.Price">Комплектация @bundling.Id</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addBundling" class="btn btn-secondary">Добавить комплектацию</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена предпродажной работы:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="Price" id="Price" value="@Model.Price" />
|
||||
<span id="PriceError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
function updateSum() {
|
||||
var sum = 0;
|
||||
$('#bundlingsTable tbody tr').each(function () {
|
||||
var price = $(this).find('.bundling-price').data('price');
|
||||
sum += parseFloat(price);
|
||||
});
|
||||
var presalePrice = parseFloat($('#Price').val());
|
||||
if (!isNaN(presalePrice)) {
|
||||
sum += presalePrice;
|
||||
}
|
||||
$('#sum').val(sum.toFixed(2));
|
||||
}
|
||||
|
||||
$(document).on('click', '.deleteBundling', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#addBundling').click(function () {
|
||||
var selectedBundling = $('#bundlingSelect option:selected');
|
||||
if (selectedBundling.val()) {
|
||||
var bundlingId = selectedBundling.val();
|
||||
var exists = false;
|
||||
$('#bundlingsTable tbody tr').each(function () {
|
||||
if ($(this).data('bundling-id') == bundlingId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта комплектация уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var bundlingName = selectedBundling.text();
|
||||
var bundlingPrice = selectedBundling.data('price');
|
||||
|
||||
var newRow = `
|
||||
<tr data-bundling-id="${bundlingId}">
|
||||
<td>
|
||||
<input type="hidden" name="bundlingIds" value="${bundlingId}" />
|
||||
${bundlingId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="bundling-price" data-price="${bundlingPrice}">${bundlingPrice}</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteBundling" data-bundling-id="${bundlingId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#bundlingsTable tbody').append(newRow);
|
||||
|
||||
$('.deleteBundling').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#bundlingSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите комплектацию для добавления');
|
||||
}
|
||||
});
|
||||
|
||||
$('#presaleForm').submit(function (event) {
|
||||
var PresaleStatus = $('#PresaleStatus').val();
|
||||
var Description = $('#Description').val();
|
||||
var DueTill = $('#DueTill').val();
|
||||
var Price = $('#Price').val();
|
||||
var isValid = true;
|
||||
|
||||
$('#PresaleStatusError').text('');
|
||||
$('#DescriptionError').text('');
|
||||
$('#DueTillError').text('');
|
||||
$('#PriceError').text('');
|
||||
var totalBundlings = $('#bundlingsTable tbody tr').length;
|
||||
if (totalBundlings == 0) {
|
||||
alert('Пожалуйста, добавьте хотя бы одну комплектацию.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
updateSum();
|
||||
});
|
||||
</script>
|
||||
|
82
CarCenter/CarCenterWorkerApp/Views/Home/IndexPresale.cshtml
Normal file
82
CarCenter/CarCenterWorkerApp/Views/Home/IndexPresale.cshtml
Normal file
@ -0,0 +1,82 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
|
||||
@model List<PresaleViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Presales";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Предпродажные работы</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreatePresale" asp-route-id="0">Создать предпродажную работу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Статус работы
|
||||
</th>
|
||||
<th>
|
||||
Описание
|
||||
</th>
|
||||
<th>
|
||||
Выполнить до
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
<th>
|
||||
Изменить работу
|
||||
</th>
|
||||
<th>
|
||||
Удалить работу
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PresaleStatus)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DueTill)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Price)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="CreatePresale" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post">
|
||||
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
||||
<input type="submit" class="btn btn-danger" value="Удалить" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -1,31 +0,0 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@using CarCenterDataModels.Enums;
|
||||
@{
|
||||
ViewData["Title"] = "PresaleCreate";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание предпродажной работы</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Выполнить до:</div>
|
||||
<div class="col-8"><input type="datetime" name="dueTill" id="dueTill" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="price" id="price" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">Комплектации:</div>
|
||||
<!--Без реализации логики четко не ясно что тут писать-->
|
||||
<select id="presale" name="presale" class="form-control" asp-items="@(new SelectList(@ViewBag.Presales,"Id"))"></select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,19 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "PresaleDelete";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удалить предпродажную работу</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<select id="presale" name="presale" class="form-control" asp-items="@(new SelectList(@ViewBag.Presales,"Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,45 +0,0 @@
|
||||
@using CarCenterDataModels.Enums;
|
||||
@{
|
||||
ViewData["Title"] = "PresaleUpdate";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4 mb-5">Обновить предпродажную работу</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Предпродажная работа:</div>
|
||||
<div class="col-8">
|
||||
<select id="presale" name="presale" class="form-control" asp-items="@(new SelectList(@ViewBag.Presales,"Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Статус:</div>
|
||||
<div class="col-8">
|
||||
<select name="presaleStatus" id="presaleStatus">
|
||||
@foreach (var value in Enum.GetValues(typeof(PresaleStatus)))
|
||||
{
|
||||
<option value="@value">@value</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Выполнить до:</div>
|
||||
<div class="col-8"><input type="datetime" name="dueTill" id="dueTill" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="price" id="price" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">Комплектации:</div>
|
||||
<!--Без реализации логики четко не ясно что тут писать-->
|
||||
<select id="presale" name="presale" class="form-control" asp-items="@(new SelectList(@ViewBag.Bundlings,"Id"))"></select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="submit" value="Обновить" class="btn btn-primary" /></div>
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,60 +0,0 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@model List<PresaleViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Presales";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Предпродажные работы</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h2 class="display-4">Надо войти в аккаунт.</h2>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать предпродажную работу</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить предпродажную работу</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить предпродажную работу</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Статус предпродажной работы
|
||||
</th>
|
||||
<th>
|
||||
Описание предпродажной работы
|
||||
</th>
|
||||
<th>
|
||||
Выполнить до
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var presale in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => presale.PresaleStatus)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => presale.Description)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => presale.DueTill)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => presale.Price)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user