diff --git a/myproject/pos/static/pos/js/terminal.js b/myproject/pos/static/pos/js/terminal.js index 39905de..e6f6cea 100644 --- a/myproject/pos/static/pos/js/terminal.js +++ b/myproject/pos/static/pos/js/terminal.js @@ -677,11 +677,35 @@ function renderCart() { const multiplySign = document.createElement('span'); multiplySign.className = 'multiply-sign'; multiplySign.textContent = 'x'; - + + // Контейнер для кнопок количества + const qtyControl = document.createElement('div'); + qtyControl.className = 'd-flex align-items-center'; + qtyControl.style.gap = '2px'; + + // Кнопка минус + const minusBtn = document.createElement('button'); + minusBtn.className = 'btn btn-outline-secondary btn-sm'; + minusBtn.innerHTML = ''; + minusBtn.onclick = (e) => { + e.preventDefault(); + const currentQty = cart.get(cartKey).qty; + if (currentQty <= 1) { + removeFromCart(cartKey); + } else { + cart.get(cartKey).qty = currentQty - 1; + renderCart(); + saveCartToRedis(); + } + }; + // Поле ввода количества const qtyInput = document.createElement('input'); qtyInput.type = 'number'; - qtyInput.className = 'qty-input'; + qtyInput.className = 'qty-input form-control form-control-sm'; + qtyInput.style.width = '60px'; + qtyInput.style.textAlign = 'center'; + qtyInput.style.padding = '0.375rem 0.25rem'; qtyInput.value = item.qty; qtyInput.min = 1; qtyInput.onchange = (e) => { @@ -694,6 +718,22 @@ function renderCart() { saveCartToRedis(); // Сохраняем в Redis при изменении количества } }; + + // Кнопка плюс + const plusBtn = document.createElement('button'); + plusBtn.className = 'btn btn-outline-secondary btn-sm'; + plusBtn.innerHTML = ''; + plusBtn.onclick = (e) => { + e.preventDefault(); + cart.get(cartKey).qty += 1; + renderCart(); + saveCartToRedis(); + }; + + // Собираем контейнер + qtyControl.appendChild(minusBtn); + qtyControl.appendChild(qtyInput); + qtyControl.appendChild(plusBtn); // Сумма за позицию const itemTotal = document.createElement('div'); @@ -708,7 +748,7 @@ function renderCart() { row.appendChild(namePrice); row.appendChild(multiplySign); - row.appendChild(qtyInput); + row.appendChild(qtyControl); row.appendChild(itemTotal); row.appendChild(deleteBtn);