feat(pos): Display showcase kits in POS interface

- Added get_showcase_kits_for_pos() function to retrieve showcase kits with active reservations
- Modified POS terminal to show showcase kits when 'Витрина' button is clicked
- Showcase kits displayed as product cards with showcase name badge (🌺 icon)
- Added isShowcaseView flag to toggle between regular and showcase view modes
- Implemented distinct styling for active showcase button:
  * Bright orange background (#ff6600)
  * Black text for contrast
  * Thicker border (3px)
  * Enhanced shadow and scale effect (1.05)
- Showcase kits can be added to cart for sale from POS interface
This commit is contained in:
2025-11-16 21:36:55 +03:00
parent 156f646252
commit 852bb92cfb
4 changed files with 114 additions and 34 deletions

View File

@@ -2,8 +2,10 @@
const CATEGORIES = JSON.parse(document.getElementById('categoriesData').textContent);
const ITEMS = JSON.parse(document.getElementById('itemsData').textContent); // Единый массив товаров и комплектов
const SHOWCASE_KITS = JSON.parse(document.getElementById('showcaseKitsData').textContent); // Витринные комплекты
let currentCategoryId = null;
let isShowcaseView = false; // Флаг режима просмотра витринных букетов
const cart = new Map(); // "type-id" -> {id, name, price, qty, type}
function formatMoney(v) {
@@ -18,33 +20,14 @@ function renderCategories() {
const showcaseCol = document.createElement('div');
showcaseCol.className = 'col-6 col-sm-4 col-md-3 col-lg-2';
const showcaseCard = document.createElement('div');
showcaseCard.className = 'card category-card showcase-card';
showcaseCard.className = 'card category-card showcase-card' + (isShowcaseView ? ' active' : '');
showcaseCard.style.backgroundColor = '#fff3cd';
showcaseCard.style.borderColor = '#ffc107';
showcaseCard.onclick = async () => {
try {
const response = await fetch('/pos/api/showcase-items/');
const data = await response.json();
if (data.success && data.showcases.length > 0) {
let message = '🌺 ВИТРИННЫЕ БУКЕТЫ\n\n';
data.showcases.forEach(showcase => {
message += `${showcase.name} (Склад: ${showcase.warehouse})\n`;
showcase.items.forEach(item => {
message += ` - ${item.product_name}: ${item.quantity} шт\n`;
});
message += '\n';
});
alert(message);
} else {
alert('Витрины пусты');
}
} catch (error) {
console.error('Error fetching showcase items:', error);
alert('Ошибка загрузки витринных букетов');
}
showcaseCard.onclick = () => {
isShowcaseView = true;
currentCategoryId = null;
renderCategories();
renderProducts();
};
const showcaseBody = document.createElement('div');
showcaseBody.className = 'card-body';
@@ -60,9 +43,10 @@ function renderCategories() {
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.className = 'card category-card' + (currentCategoryId === null && !isShowcaseView ? ' active' : '');
allCard.onclick = () => {
currentCategoryId = null;
isShowcaseView = false;
renderCategories();
renderProducts();
};
@@ -82,9 +66,10 @@ function renderCategories() {
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.className = 'card category-card' + (currentCategoryId === cat.id && !isShowcaseView ? ' active' : '');
card.onclick = () => {
currentCategoryId = cat.id;
isShowcaseView = false;
renderCategories();
renderProducts();
};
@@ -108,9 +93,17 @@ function renderProducts() {
grid.innerHTML = '';
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
let filtered = currentCategoryId
? ITEMS.filter(item => (item.category_ids || []).includes(currentCategoryId))
: ITEMS;
let filtered;
// Если выбран режим витрины - показываем витринные комплекты
if (isShowcaseView) {
filtered = SHOWCASE_KITS;
} else {
// Обычный режим - показываем товары и комплекты
filtered = currentCategoryId
? ITEMS.filter(item => (item.category_ids || []).includes(currentCategoryId))
: ITEMS;
}
if (searchTerm) {
filtered = filtered.filter(item => item.name.toLowerCase().includes(searchTerm));
@@ -149,9 +142,17 @@ function renderProducts() {
const stock = document.createElement('div');
stock.className = 'product-stock';
stock.textContent = item.in_stock ? 'В наличии' : 'Под заказ';
if (!item.in_stock) {
stock.style.color = '#dc3545';
// Для витринных комплектов показываем название витрины
if (item.type === 'showcase_kit') {
stock.textContent = `🌺 ${item.showcase_name}`;
stock.style.color = '#856404';
stock.style.fontWeight = 'bold';
} else {
stock.textContent = item.in_stock ? 'В наличии' : 'Под заказ';
if (!item.in_stock) {
stock.style.color = '#dc3545';
}
}
const sku = document.createElement('div');