Добавлен блок категорий в POS-терминал: компактные карточки с фильтрацией товаров

This commit is contained in:
2025-11-16 14:09:59 +03:00
parent 8cf076c49e
commit bb51a72f4c
3 changed files with 115 additions and 19 deletions

View File

@@ -4,9 +4,22 @@ body {
background-color: #e9ecef; background-color: #e9ecef;
} }
/* Основной контейнер POS */
.pos-main-container {
position: fixed;
top: 56px; /* высота navbar */
left: 0;
right: 0;
bottom: 0;
background-color: white;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
overflow: hidden;
}
.pos-container { .pos-container {
max-width: 100%; max-width: 100%;
padding: 0 1rem; padding: 1rem;
height: 100%;
} }
.product-card { .product-card {
@@ -52,17 +65,54 @@ body {
font-style: italic; font-style: italic;
} }
/* Карточки категорий */
.category-card {
cursor: pointer;
user-select: none;
transition: all 0.2s;
border-radius: 12px;
border: 2px solid #dee2e6;
background: white;
height: 100%;
min-height: 40px;
}
.category-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
border-color: #0d6efd;
}
.category-card.active {
background: #0d6efd;
border-color: #0d6efd;
color: white;
}
.category-card .card-body {
padding: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
.category-name {
font-weight: 600;
font-size: 0.85rem;
}
/* Фиксация правой панели (корзина + кнопки) */ /* Фиксация правой панели (корзина + кнопки) */
.right-panel-fixed { .right-panel-fixed {
position: fixed; position: absolute;
top: 56px; /* высота navbar */ top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
width: 33.333%; /* 4/12 колонок */ width: 33.333%; /* 4/12 колонок */
overflow-y: auto; overflow-y: auto;
padding: 1rem; padding: 1rem;
padding-right: 1.5rem; padding-right: 1.5rem;
z-index: 100; z-index: 10;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }

View File

@@ -10,6 +10,57 @@ function formatMoney(v) {
return (Number(v)).toFixed(2); return (Number(v)).toFixed(2);
} }
function renderCategories() {
const grid = document.getElementById('categoryGrid');
grid.innerHTML = '';
// Кнопка "Все"
const allCol = document.createElement('div');
allCol.className = 'col-6 col-sm-4 col-md-3 col-lg-2';
const allCard = document.createElement('div');
allCard.className = 'card category-card' + (currentCategoryId === null ? ' active' : '');
allCard.onclick = () => {
currentCategoryId = null;
renderCategories();
renderProducts();
};
const allBody = document.createElement('div');
allBody.className = 'card-body';
const allName = document.createElement('div');
allName.className = 'category-name';
allName.textContent = 'Все товары';
allBody.appendChild(allName);
allCard.appendChild(allBody);
allCol.appendChild(allCard);
grid.appendChild(allCol);
// Категории
CATEGORIES.forEach(cat => {
const col = document.createElement('div');
col.className = 'col-6 col-sm-4 col-md-3 col-lg-2';
const card = document.createElement('div');
card.className = 'card category-card' + (currentCategoryId === cat.id ? ' active' : '');
card.onclick = () => {
currentCategoryId = cat.id;
renderCategories();
renderProducts();
};
const body = document.createElement('div');
body.className = 'card-body';
const name = document.createElement('div');
name.className = 'category-name';
name.textContent = cat.name;
body.appendChild(name);
card.appendChild(body);
col.appendChild(card);
grid.appendChild(col);
});
}
function renderProducts() { function renderProducts() {
const grid = document.getElementById('productGrid'); const grid = document.getElementById('productGrid');
grid.innerHTML = ''; grid.innerHTML = '';
@@ -153,8 +204,6 @@ document.getElementById('scheduleLater').onclick = async () => {
alert('Функционал будет подключен позже: создание заказа на доставку/самовывоз.'); alert('Функционал будет подключен позже: создание заказа на доставку/самовывоз.');
}; };
// Categories removed from this view - can be added as filter dropdown later if needed
// Search functionality // Search functionality
document.getElementById('searchInput').addEventListener('input', () => { document.getElementById('searchInput').addEventListener('input', () => {
renderProducts(); renderProducts();
@@ -166,5 +215,6 @@ document.getElementById('customerSelectBtn').addEventListener('click', () => {
}); });
// Инициализация // Инициализация
renderCategories();
renderProducts(); renderProducts();
renderCart(); renderCart();

View File

@@ -7,7 +7,8 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<!-- Main Content --> <!-- Main POS Container -->
<div class="pos-main-container">
<div class="pos-container"> <div class="pos-container">
<div class="row g-3"> <div class="row g-3">
<!-- Products Grid (Left side - 8/12) --> <!-- Products Grid (Left side - 8/12) -->
@@ -17,6 +18,11 @@
<input type="text" class="form-control" id="searchInput" placeholder="Поиск по товарам..."> <input type="text" class="form-control" id="searchInput" placeholder="Поиск по товарам...">
</div> </div>
<!-- Categories -->
<div class="mb-3">
<div class="row g-3" id="categoryGrid"></div>
</div>
<div class="row g-3" id="productGrid"></div> <div class="row g-3" id="productGrid"></div>
</div> </div>
@@ -39,16 +45,6 @@
<h5 class="mb-0">Итого:</h5> <h5 class="mb-0">Итого:</h5>
<h5 class="mb-0 text-primary" id="cartTotal">0.00</h5> <h5 class="mb-0 text-primary" id="cartTotal">0.00</h5>
</div> </div>
<div class="mb-3">
<label class="form-label small">Способ оплаты</label>
<select class="form-select form-select-sm" id="paymentMethod">
<option value="cash_to_courier">Наличные</option>
<option value="card_to_courier">Карта</option>
<option value="online">Онлайн</option>
<option value="bank_transfer">Банк. перевод</option>
</select>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -103,7 +99,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}
{% block extra_js %} {% block extra_js %}