feat: price_quality в конфигураторе; фикс пустого lot_description в экспорте цен

price_quality теперь синхронизируется не только в прайслист, но и в
LocalComponent/services.ComponentView (/api/components) — виден в
выпадающем списке поиска (цветная точка), в таблице конфигуратора
(левая колонка-пиктограмма) и на вкладке «Ценообразование» (подсветка
строки). Цветовая шкала вынесена в один модуль web/static/price-quality.js
(подключён в base.html), чтобы не дублировать расчёт цвета по шаблонам.
Шкала — градиент 0 (красный) → 5 (жёлтый) → 9 (зелёный).

Экспорт цен (internal/services/export.go): resolveLotDescriptions был
заглушкой, всегда возвращавшей пустую карту — строки BOM/не-BOM в
экспорте всегда оставались без описания LOT. Заменён на реальный
запрос к local_pricelist_items текущего выбранного прайслиста
(LocalDB.GetLocalDescriptionsForLots), по аналогии с уже существующим
GetLocalLotCategoriesByServerPricelistID.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-07-22 19:01:47 +03:00
co-authored by Claude Sonnet 5
parent 3348008198
commit ee92c3b392
11 changed files with 169 additions and 24 deletions
+18 -3
View File
@@ -1483,6 +1483,7 @@ function renderSingleSelectTab(categories) {
<table class="w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-2 py-2 w-6" title="Качество цены"></th>
<th class="px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase w-24">Тип</th>
<th class="px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase">LOT</th>
<th class="px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase">Описание</th>
@@ -1509,6 +1510,7 @@ function renderSingleSelectTab(categories) {
html += `
<tr class="hover:bg-gray-50">
<td class="px-2 py-2 text-center">${qualityDotHtml(comp?.price_quality)}</td>
<td class="px-3 py-2 text-sm font-medium text-gray-700">${catLabel}</td>
<td class="px-3 py-2">
<div class="autocomplete-wrapper relative">
@@ -1859,7 +1861,7 @@ function renderAutocomplete() {
return `
<div class="autocomplete-item ${idx === autocompleteIndex ? 'selected' : ''}"
onmousedown="${onmousedown}">
<div class="font-mono text-sm">${escapeHtml(comp.lot_name)}</div>
<div class="font-mono text-sm flex items-center gap-1.5">${qualityDotHtml(comp.price_quality)}${escapeHtml(comp.lot_name)}</div>
<div class="text-xs text-gray-500 truncate">${escapeHtml(comp.description || '')}</div>
</div>
`;
@@ -4539,6 +4541,7 @@ async function renderPricingTab() {
lotCell: escapeHtml(item.lot_name), lotText: item.lot_name,
vendorPN: null,
desc: (compMap[U(item.lot_name)] || {}).description || '',
priceQuality: (compMap[U(item.lot_name)] || {}).price_quality,
qty: item.quantity,
estUnit, warehouseUnit: u.warehouseUnit, competitorUnit: u.competitorUnit,
est: estUnit * item.quantity,
@@ -4586,6 +4589,7 @@ async function renderPricingTab() {
warehouse: u.warehouseUnit != null ? u.warehouseUnit * qty : null,
competitor: u.competitorUnit != null ? u.competitorUnit * qty : null,
estWorld: u.estWorld, whWorld: u.whWorld, compWorld: u.compWorld,
priceQuality: (compMap[U(baseLot)] || {}).price_quality,
});
}
allocs.forEach(a => {
@@ -4599,6 +4603,7 @@ async function renderPricingTab() {
warehouse: u.warehouseUnit != null ? u.warehouseUnit * qty : null,
competitor: u.competitorUnit != null ? u.competitorUnit * qty : null,
estWorld: u.estWorld, whWorld: u.whWorld, compWorld: u.compWorld,
priceQuality: (compMap[U(a.lot_name)] || {}).price_quality,
});
});
@@ -4611,6 +4616,7 @@ async function renderPricingTab() {
vendorOrig, vendorOrigUnit, isEstOnly: false,
groupStart: true, groupSize: 1,
estWorld: false, whWorld: false, compWorld: false,
priceQuality: null,
});
return;
}
@@ -4629,6 +4635,7 @@ async function renderPricingTab() {
groupStart: idx === 0,
groupSize: idx === 0 ? groupSize : 0,
estWorld: sub.estWorld, whWorld: sub.whWorld, compWorld: sub.compWorld,
priceQuality: sub.priceQuality,
});
});
});
@@ -4657,7 +4664,11 @@ async function renderPricingTab() {
rowData.forEach(r => {
const tr = document.createElement('tr');
tr.classList.add('pricing-row-buy');
if (r.isEstOnly) tr.classList.add('bg-blue-50');
if (typeof r.priceQuality === 'number') {
tr.setAttribute('style', qualityRowStyle(r.priceQuality));
} else if (r.isEstOnly) {
tr.classList.add('bg-blue-50');
}
tr.dataset.est = r.est;
tr.dataset.qty = r.qty;
tr.dataset.vendorOrig = r.vendorOrig != null ? r.vendorOrig : '';
@@ -4706,7 +4717,11 @@ async function renderPricingTab() {
rowData.forEach(r => {
const tr = document.createElement('tr');
tr.classList.add('pricing-row-sale');
if (r.isEstOnly) tr.classList.add('bg-blue-50');
if (typeof r.priceQuality === 'number') {
tr.setAttribute('style', qualityRowStyle(r.priceQuality));
} else if (r.isEstOnly) {
tr.classList.add('bg-blue-50');
}
const saleEstUnit = r.estUnit > 0 ? r.estUnit * saleUplift : 0;
const saleWhUnit = r.warehouseUnit != null ? r.warehouseUnit * SALE_FIXED_MULT : null;
const saleCompUnit = r.competitorUnit != null ? r.competitorUnit * SALE_FIXED_MULT : null;