Улучшены карточки товаров в POS: добавлены фото, артикул, цена и статус наличия
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
const CATEGORIES = JSON.parse(document.getElementById('categoriesData').textContent);
|
||||
const PRODUCTS = JSON.parse(document.getElementById('productsData').textContent);
|
||||
|
||||
// Отладка: проверить количество загруженных товаров
|
||||
console.log('Загружено категорий:', CATEGORIES.length);
|
||||
console.log('Загружено товаров:', PRODUCTS.length);
|
||||
console.log('Товары:', PRODUCTS);
|
||||
|
||||
let currentCategoryId = null;
|
||||
const cart = new Map(); // productId -> {id, name, price, qty}
|
||||
|
||||
@@ -85,16 +90,52 @@ function renderProducts() {
|
||||
const body = document.createElement('div');
|
||||
body.className = 'card-body';
|
||||
|
||||
// Изображение товара
|
||||
const imageDiv = document.createElement('div');
|
||||
imageDiv.className = 'product-image';
|
||||
if (p.image) {
|
||||
const img = document.createElement('img');
|
||||
img.src = p.image;
|
||||
img.alt = p.name;
|
||||
imageDiv.appendChild(img);
|
||||
} else {
|
||||
imageDiv.innerHTML = '<i class="bi bi-image"></i>';
|
||||
}
|
||||
|
||||
// Информация о товаре
|
||||
const info = document.createElement('div');
|
||||
info.className = 'product-info';
|
||||
|
||||
const name = document.createElement('div');
|
||||
name.className = 'product-name';
|
||||
name.textContent = p.name;
|
||||
|
||||
const stock = document.createElement('div');
|
||||
stock.className = 'product-stock';
|
||||
stock.textContent = 'В наличии';
|
||||
stock.textContent = p.in_stock ? 'В наличии' : 'Под заказ';
|
||||
if (!p.in_stock) {
|
||||
stock.style.color = '#dc3545';
|
||||
}
|
||||
|
||||
body.appendChild(name);
|
||||
body.appendChild(stock);
|
||||
const sku = document.createElement('div');
|
||||
sku.className = 'product-sku';
|
||||
|
||||
const skuText = document.createElement('span');
|
||||
skuText.textContent = p.sku || 'н/д';
|
||||
|
||||
const priceSpan = document.createElement('span');
|
||||
priceSpan.className = 'product-price';
|
||||
priceSpan.textContent = `${formatMoney(p.price)}`;
|
||||
|
||||
sku.appendChild(skuText);
|
||||
sku.appendChild(priceSpan);
|
||||
|
||||
info.appendChild(name);
|
||||
info.appendChild(stock);
|
||||
info.appendChild(sku);
|
||||
|
||||
body.appendChild(imageDiv);
|
||||
body.appendChild(info);
|
||||
card.appendChild(body);
|
||||
col.appendChild(card);
|
||||
grid.appendChild(col);
|
||||
@@ -218,3 +259,6 @@ document.getElementById('customerSelectBtn').addEventListener('click', () => {
|
||||
renderCategories();
|
||||
renderProducts();
|
||||
renderCart();
|
||||
|
||||
// Установить фокус на строку поиска
|
||||
document.getElementById('searchInput').focus();
|
||||
|
||||
Reference in New Issue
Block a user