From 2862f668e36e3f7729cc5cac99af6f6fdad22f76 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Fri, 3 Apr 2026 14:34:12 +0700 Subject: [PATCH] fix(catalog): remove box quantity from sku filters --- .../catalog/CatalogConfigurator.vue | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/app/components/catalog/CatalogConfigurator.vue b/app/components/catalog/CatalogConfigurator.vue index 37f610d..f6e6ad2 100644 --- a/app/components/catalog/CatalogConfigurator.vue +++ b/app/components/catalog/CatalogConfigurator.vue @@ -4,7 +4,7 @@ import { ClientProductsDocument, type ClientProductsQuery } from '~/composables/ import { useClientCart } from '~/composables/useClientCart'; type ProductNode = ClientProductsQuery['clientProducts'][number]; -type ParamFieldKey = 'widthMm' | 'lengthM' | 'thicknessMicron' | 'sleeveBrand' | 'quantityPerBox'; +type ParamFieldKey = 'widthMm' | 'lengthM' | 'thicknessMicron' | 'sleeveBrand'; type ParamValue = number | string; type ParsedProduct = ProductNode & { @@ -14,6 +14,7 @@ type ParsedProduct = ProductNode & { thicknessMicron: number | null; sleeveBrand: string | null; quantityPerBox: string | null; + quantityPerBoxOptions: string[]; }; type ProductGroup = { @@ -27,17 +28,15 @@ type GroupState = { lengthM: number | null; thicknessMicron: number | null; sleeveBrand: string | null; - quantityPerBox: string | null; isExpanded: boolean; }; -const PARAM_KEYS: ParamFieldKey[] = ['widthMm', 'lengthM', 'thicknessMicron', 'sleeveBrand', 'quantityPerBox']; +const PARAM_KEYS: ParamFieldKey[] = ['widthMm', 'lengthM', 'thicknessMicron', 'sleeveBrand']; const parameterFields: Array<{ key: ParamFieldKey; label: string }> = [ { key: 'widthMm', label: 'Ширина, мм' }, { key: 'lengthM', label: 'Длина, м' }, { key: 'thicknessMicron', label: 'Толщина, мкм' }, { key: 'sleeveBrand', label: 'Бренд втулки' }, - { key: 'quantityPerBox', label: 'Количество в коробе' }, ]; const coverPresets = [ @@ -90,6 +89,7 @@ function parseProductMeta(product: ProductNode) { const thicknessMatch = normalizedName.match(/(\d+)\s*мкм/i); const sleeveMatch = normalizedName.match(/втулка\s+([^,]+)/i); const quantityMatch = normalizedName.match(/короб\s+([^,]+)/i); + const quantityPerBox = quantityMatch?.[1]?.trim() ?? null; return { productTypeLabel: typeLabel, @@ -97,7 +97,10 @@ function parseProductMeta(product: ProductNode) { lengthM: sizeMatch ? Number.parseInt(sizeMatch[2] ?? '', 10) : null, thicknessMicron: thicknessMatch ? Number.parseInt(thicknessMatch[1] ?? '', 10) : null, sleeveBrand: sleeveMatch?.[1]?.trim() ?? null, - quantityPerBox: quantityMatch?.[1]?.trim() ?? null, + quantityPerBox, + quantityPerBoxOptions: quantityPerBox + ? quantityPerBox.split('/').map((value) => value.trim()).filter(Boolean) + : [], }; } @@ -215,7 +218,6 @@ function createGroupState(group: ProductGroup): GroupState { lengthM: null, thicknessMicron: null, sleeveBrand: null, - quantityPerBox: null, isExpanded: false, }; @@ -294,6 +296,22 @@ function selectedFieldValue(group: ProductGroup, field: ParamFieldKey) { return formatOptionLabel(field, value); } +function boxQuantityLabel(group: ProductGroup) { + const product = selectedProduct(group); + if (product?.quantityPerBox) { + return product.quantityPerBox; + } + + const values = new Set(); + for (const item of group.products) { + for (const option of item.quantityPerBoxOptions) { + values.add(option); + } + } + + return sortParamValues([...values]).join(' / ') || '—'; +} + function incrementProduct(product: ProductNode) { if (getQuantity(product.id) === 0) { addProduct({ @@ -379,6 +397,7 @@ function decrementSelected(group: ProductGroup) {
SKU: {{ selectedProduct(group)?.sku ?? '—' }} Совпадений: {{ matchingCount(group) }} + Короб: {{ boxQuantityLabel(group) }}