From 96694599208fc9dbc6c3aef297aa279cee1a05a0 Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Sun, 16 Nov 2025 19:42:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D1=83?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- myproject/pos/static/pos/js/terminal.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/myproject/pos/static/pos/js/terminal.js b/myproject/pos/static/pos/js/terminal.js index 8f16308..c4ece3a 100644 --- a/myproject/pos/static/pos/js/terminal.js +++ b/myproject/pos/static/pos/js/terminal.js @@ -3,14 +3,6 @@ const CATEGORIES = JSON.parse(document.getElementById('categoriesData').textContent); const ITEMS = JSON.parse(document.getElementById('itemsData').textContent); // Единый массив товаров и комплектов -// Отладка: проверить количество загруженных позиций -console.log('Загружено категорий:', CATEGORIES.length); -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(); // "type-id" -> {id, name, price, qty, type} @@ -147,9 +139,8 @@ function renderProducts() { function addToCart(item) { const cartKey = `${item.type}-${item.id}`; // Уникальный ключ: "product-1" или "kit-1" - const isNew = !cart.has(cartKey); - if (isNew) { + if (!cart.has(cartKey)) { cart.set(cartKey, { id: item.id, name: item.name, price: Number(item.price), qty: 1, type: item.type }); } else { cart.get(cartKey).qty += 1; @@ -160,8 +151,7 @@ function addToCart(item) { // Автоматический фокус на поле количества setTimeout(() => { const qtyInputs = document.querySelectorAll('.qty-input'); - const cartItems = Array.from(cart.keys()); - const itemIndex = cartItems.indexOf(cartKey); + const itemIndex = Array.from(cart.keys()).indexOf(cartKey); if (itemIndex !== -1 && qtyInputs[itemIndex]) { qtyInputs[itemIndex].focus(); @@ -170,14 +160,6 @@ function addToCart(item) { }, 50); } -function updateQty(id, delta) { - if (!cart.has(id)) return; - const item = cart.get(id); - item.qty += delta; - if (item.qty <= 0) cart.delete(id); - renderCart(); -} - function renderCart() { const list = document.getElementById('cartList'); list.innerHTML = ''; @@ -212,7 +194,7 @@ function renderCart() { qtyInput.className = 'qty-input'; qtyInput.value = item.qty; qtyInput.min = 1; - qtyInput.onchange = (e) => { + qtyInput.oninput = (e) => { const newQty = parseInt(e.target.value) || 1; if (newQty <= 0) { removeFromCart(cartKey);