Добавлен блок категорий в 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;
}
/* Основной контейнер 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 {
max-width: 100%;
padding: 0 1rem;
padding: 1rem;
height: 100%;
}
.product-card {
@@ -52,17 +65,54 @@ body {
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 {
position: fixed;
top: 56px; /* высота navbar */
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 33.333%; /* 4/12 колонок */
overflow-y: auto;
padding: 1rem;
padding-right: 1.5rem;
z-index: 100;
z-index: 10;
display: flex;
flex-direction: column;
}

View File

@@ -10,6 +10,57 @@ function formatMoney(v) {
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() {
const grid = document.getElementById('productGrid');
grid.innerHTML = '';
@@ -153,8 +204,6 @@ document.getElementById('scheduleLater').onclick = async () => {
alert('Функционал будет подключен позже: создание заказа на доставку/самовывоз.');
};
// Categories removed from this view - can be added as filter dropdown later if needed
// Search functionality
document.getElementById('searchInput').addEventListener('input', () => {
renderProducts();
@@ -166,5 +215,6 @@ document.getElementById('customerSelectBtn').addEventListener('click', () => {
});
// Инициализация
renderCategories();
renderProducts();
renderCart();

View File

@@ -7,7 +7,8 @@
{% endblock %}
{% block content %}
<!-- Main Content -->
<!-- Main POS Container -->
<div class="pos-main-container">
<div class="pos-container">
<div class="row g-3">
<!-- Products Grid (Left side - 8/12) -->
@@ -17,6 +18,11 @@
<input type="text" class="form-control" id="searchInput" placeholder="Поиск по товарам...">
</div>
<!-- Categories -->
<div class="mb-3">
<div class="row g-3" id="categoryGrid"></div>
</div>
<div class="row g-3" id="productGrid"></div>
</div>
@@ -39,16 +45,6 @@
<h5 class="mb-0">Итого:</h5>
<h5 class="mb-0 text-primary" id="cartTotal">0.00</h5>
</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>
@@ -103,7 +99,7 @@
</div>
</div>
</div>
</div>
{% endblock %}
{% block extra_js %}