From a35376ced9bb49ec56caea9e20f34d4602e206c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Fri, 13 Mar 2026 20:09:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[sales]=20=EA=B0=80=EA=B2=A9=EC=8B=9C?= =?UTF-8?q?=EB=AE=AC=EB=A0=88=EC=9D=B4=ED=84=B0=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EC=83=81=ED=98=B8=20=EB=B0=B0=ED=83=80=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 업종 선택 카드 UI 추가 (제조업/공사업체 중 하나만 선택) - 카테고리 전환 시 기존 상품 선택 초기화 + 새 카테고리 필수상품만 자동 선택 - 다른 카테고리 상품이 동시에 체크되지 않도록 제한 --- .../sales/price-simulator/index.blade.php | 72 +++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/resources/views/sales/price-simulator/index.blade.php b/resources/views/sales/price-simulator/index.blade.php index 5e3c0ba0..2c05ca96 100644 --- a/resources/views/sales/price-simulator/index.blade.php +++ b/resources/views/sales/price-simulator/index.blade.php @@ -615,13 +615,30 @@ class="w-4 h-4 rounded border-gray-300 text-emerald-600 focus:ring-emerald-500"> - {{-- 카테고리별 상품 목록 --}} + {{-- 업종 카테고리 선택 --}} +
+

업종 선택

+
+ @foreach($categories as $category) +
+
{{ $category->name }}
+
{{ $category->products->count() }}개 상품 / {{ $category->base_storage }}
+
+ @endforeach +
+
+ + {{-- 선택된 카테고리의 상품 목록 --}} @foreach($categories as $category) -
+
-

{{ $category->name }}

-

기본 제공: {{ $category->base_storage }}

+

{{ $category->name }} 상품

+

필요한 상품을 체크하세요

{{ $category->products->count() }}개 상품 @@ -638,7 +655,7 @@ class="w-4 h-4 rounded border-gray-300 text-emerald-600 focus:ring-emerald-500"> :checked="isSelected({{ $product->id }})" x-on:change="toggleProduct({{ $product->id }})" class="w-4 h-4 rounded border-gray-300 text-emerald-600 focus:ring-emerald-500" - @if($product->is_required) checked disabled @endif> + @if($product->is_required) :disabled="isSelected({{ $product->id }})" @endif>
@@ -865,25 +882,36 @@ function priceSimulator() { }); }); - // 필수 상품 ID 수집 - const requiredIds = Object.values(productMap) - .filter(p => p.is_required) - .map(p => p.id); + // 카테고리별 필수 상품 선택 세트 생성 + function buildRequiredSelected(catId) { + const result = {}; + Object.values(productMap) + .filter(p => p.categoryId === catId && p.is_required) + .forEach(p => { + result[p.id] = { + adjustedFee: Number(p.registration_fee) || Math.floor(Number(p.development_fee) * 0.25), + }; + }); + return result; + } - // 초기 선택 상태: 필수 상품은 기본 선택 + 기본 가입비 적용 - const initialSelected = {}; - requiredIds.forEach(id => { - const p = productMap[id]; - initialSelected[id] = { - adjustedFee: Number(p.registration_fee) || Math.floor(Number(p.development_fee) * 0.25), - }; - }); + // 첫 번째 카테고리를 기본 선택 + const firstCategoryId = categoriesData.length > 0 ? categoriesData[0].id : null; return { showHelp: false, signupType: 'individual', hasReferrer: false, - selected: { ...initialSelected }, + selectedCategoryId: firstCategoryId, + selected: buildRequiredSelected(firstCategoryId), + + // --- 카테고리 선택 (상호 배타) --- + selectCategory(catId) { + if (this.selectedCategoryId === catId) return; + this.selectedCategoryId = catId; + // 전체 초기화 후 새 카테고리의 필수 상품만 선택 + this.selected = buildRequiredSelected(catId); + }, // --- 상품 선택/해제 --- isSelected(id) { @@ -893,7 +921,10 @@ function priceSimulator() { toggleProduct(id) { const p = productMap[id]; if (!p) return; - if (p.is_required) return; // 필수 상품은 해제 불가 + // 현재 카테고리 상품만 토글 가능 + if (p.categoryId !== this.selectedCategoryId) return; + // 필수 상품은 해제 불가 + if (p.is_required && this.isSelected(id)) return; if (this.isSelected(id)) { const copy = { ...this.selected }; @@ -1029,7 +1060,8 @@ function priceSimulator() { resetAll() { this.signupType = 'individual'; this.hasReferrer = false; - this.selected = { ...initialSelected }; + this.selectedCategoryId = firstCategoryId; + this.selected = buildRequiredSelected(firstCategoryId); }, }; }