diff --git a/myproject/pos/static/pos/css/terminal.css b/myproject/pos/static/pos/css/terminal.css index 28a7a70..6c69e67 100644 --- a/myproject/pos/static/pos/css/terminal.css +++ b/myproject/pos/static/pos/css/terminal.css @@ -20,6 +20,16 @@ body { max-width: 100%; padding: 1rem; height: 100%; + overflow: hidden; + display: flex; + flex-direction: column; +} + +/* Прокручиваемая область товаров */ +.products-scrollable { + overflow-y: auto; + overflow-x: hidden; + flex-grow: 1; } .product-card { @@ -63,6 +73,8 @@ body { justify-content: center; color: #adb5bd; font-size: 3rem; + flex-shrink: 0; + min-height: 150px; } .product-image img { diff --git a/myproject/pos/static/pos/js/terminal.js b/myproject/pos/static/pos/js/terminal.js index dc878ee..c85733c 100644 --- a/myproject/pos/static/pos/js/terminal.js +++ b/myproject/pos/static/pos/js/terminal.js @@ -1,12 +1,15 @@ // POS Terminal JavaScript const CATEGORIES = JSON.parse(document.getElementById('categoriesData').textContent); -const PRODUCTS = JSON.parse(document.getElementById('productsData').textContent); +const ITEMS = JSON.parse(document.getElementById('itemsData').textContent); // Единый массив товаров и комплектов -// Отладка: проверить количество загруженных товаров +// Отладка: проверить количество загруженных позиций console.log('Загружено категорий:', CATEGORIES.length); -console.log('Загружено товаров:', PRODUCTS.length); -console.log('Товары:', PRODUCTS); +console.log('Загружено позиций (товары + комплекты):', ITEMS.length); +const productsCount = ITEMS.filter(i => i.type === 'product').length; +const kitsCount = ITEMS.filter(i => i.type === 'kit').length; +console.log(` - Товаров: ${productsCount}, Комплектов: ${kitsCount}`); +console.log('Позиции:', ITEMS); let currentCategoryId = null; const cart = new Map(); // productId -> {id, name, price, qty} @@ -72,48 +75,48 @@ function renderProducts() { const searchTerm = document.getElementById('searchInput').value.toLowerCase(); let filtered = currentCategoryId - ? PRODUCTS.filter(p => (p.category_ids || []).includes(currentCategoryId)) - : PRODUCTS; + ? ITEMS.filter(item => (item.category_ids || []).includes(currentCategoryId)) + : ITEMS; if (searchTerm) { - filtered = filtered.filter(p => p.name.toLowerCase().includes(searchTerm)); + filtered = filtered.filter(item => item.name.toLowerCase().includes(searchTerm)); } - filtered.forEach(p => { + filtered.forEach(item => { 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 product-card'; - card.onclick = () => addToCart(p); + card.onclick = () => addToCart(item); const body = document.createElement('div'); body.className = 'card-body'; - // Изображение товара + // Изображение товара/комплекта const imageDiv = document.createElement('div'); imageDiv.className = 'product-image'; - if (p.image) { + if (item.image) { const img = document.createElement('img'); - img.src = p.image; - img.alt = p.name; + img.src = item.image; + img.alt = item.name; imageDiv.appendChild(img); } else { imageDiv.innerHTML = ''; } - // Информация о товаре + // Информация о товаре/комплекте const info = document.createElement('div'); info.className = 'product-info'; const name = document.createElement('div'); name.className = 'product-name'; - name.textContent = p.name; + name.textContent = item.name; const stock = document.createElement('div'); stock.className = 'product-stock'; - stock.textContent = p.in_stock ? 'В наличии' : 'Под заказ'; - if (!p.in_stock) { + stock.textContent = item.in_stock ? 'В наличии' : 'Под заказ'; + if (!item.in_stock) { stock.style.color = '#dc3545'; } @@ -121,11 +124,11 @@ function renderProducts() { sku.className = 'product-sku'; const skuText = document.createElement('span'); - skuText.textContent = p.sku || 'н/д'; + skuText.textContent = item.sku || 'н/д'; const priceSpan = document.createElement('span'); priceSpan.className = 'product-price'; - priceSpan.textContent = `${formatMoney(p.price)}`; + priceSpan.textContent = `${formatMoney(item.price)}`; sku.appendChild(skuText); sku.appendChild(priceSpan); @@ -142,11 +145,11 @@ function renderProducts() { }); } -function addToCart(p) { - if (!cart.has(p.id)) { - cart.set(p.id, { id: p.id, name: p.name, price: Number(p.price), qty: 1 }); +function addToCart(item) { + if (!cart.has(item.id)) { + cart.set(item.id, { id: item.id, name: item.name, price: Number(item.price), qty: 1, type: item.type }); } else { - cart.get(p.id).qty += 1; + cart.get(item.id).qty += 1; } renderCart(); } diff --git a/myproject/pos/templates/pos/terminal.html b/myproject/pos/templates/pos/terminal.html index cc3c204..0312200 100644 --- a/myproject/pos/templates/pos/terminal.html +++ b/myproject/pos/templates/pos/terminal.html @@ -10,9 +10,9 @@