diff --git a/app/Http/Controllers/BendingBaseController.php b/app/Http/Controllers/BendingBaseController.php index 216f34a0..c12bf0ea 100644 --- a/app/Http/Controllers/BendingBaseController.php +++ b/app/Http/Controllers/BendingBaseController.php @@ -37,27 +37,8 @@ public function index(Request $request): View|\Illuminate\Http\Response $params = $request->only(['item_sep', 'item_bending', 'material', 'model_UA', 'item_name', 'search', 'page', 'size']); $params['size'] = $params['size'] ?? 30; - $apiError = null; - try { - $response = $this->api()->get('/api/v1/bending-items', $params); - } catch (\Illuminate\Http\Client\ConnectionException $e) { - $apiError = 'API 서버에 연결할 수 없습니다. API 서비스 상태를 확인해 주세요.'; - $response = null; - } - - if ($response && $response->successful()) { - $body = $response->json('data', []); - } else { - $body = []; - if (! $apiError && $response) { - $apiError = match ($response->status()) { - 401 => 'API 인증이 필요합니다. SAM 서비스에 로그인하여 API를 연결해 주세요.', - 403 => 'API 접근 권한이 없습니다. 관리자에게 문의해 주세요.', - default => "API 오류가 발생했습니다. (HTTP {$response->status()})", - }; - } - } - + $response = $this->api()->get('/api/v1/bending-items', $params); + $body = $response->successful() ? $response->json('data', []) : []; $data = [ 'data' => $body['data'] ?? [], 'total' => $body['total'] ?? 0, @@ -65,15 +46,12 @@ public function index(Request $request): View|\Illuminate\Http\Response 'last_page' => $body['last_page'] ?? 1, ]; - $filterOptions = []; - if (! $apiError) { - $filterResponse = $this->api()->get('/api/v1/bending-items/filters'); - $filterOptions = $filterResponse->successful() ? $filterResponse->json('data', []) : []; - } + $filterResponse = $this->api()->get('/api/v1/bending-items/filters'); + $filterOptions = $filterResponse->successful() ? $filterResponse->json('data', []) : []; if ($request->header('HX-Request')) { if ($request->header('HX-Target') === 'items-table') { - return view('bending.base.partials.table', ['items' => $data, 'apiError' => $apiError]); + return view('bending.base.partials.table', ['items' => $data]); } return response('', 200)->header('HX-Redirect', route('bending.base.index', $request->query())); @@ -82,7 +60,6 @@ public function index(Request $request): View|\Illuminate\Http\Response return view('bending.base.index', [ 'items' => $data, 'filterOptions' => $filterOptions, - 'apiError' => $apiError, ]); } diff --git a/app/Http/Controllers/BendingProductController.php b/app/Http/Controllers/BendingProductController.php index 60c83390..761aaf8a 100644 --- a/app/Http/Controllers/BendingProductController.php +++ b/app/Http/Controllers/BendingProductController.php @@ -49,27 +49,8 @@ public function index(Request $request, string $category = 'GUIDERAIL_MODEL'): V $params['size'] = $params['size'] ?? 30; $params['item_category'] = $category; - $apiError = null; - try { - $response = $this->api()->get('/api/v1/guiderail-models', $params); - } catch (\Illuminate\Http\Client\ConnectionException $e) { - $apiError = 'API 서버에 연결할 수 없습니다. API 서비스 상태를 확인해 주세요.'; - $response = null; - } - - if ($response && $response->successful()) { - $body = $response->json('data', []); - } else { - $body = []; - if (! $apiError && $response) { - $apiError = match ($response->status()) { - 401 => 'API 인증이 필요합니다. SAM 서비스에 로그인하여 API를 연결해 주세요.', - 403 => 'API 접근 권한이 없습니다. 관리자에게 문의해 주세요.', - default => "API 오류가 발생했습니다. (HTTP {$response->status()})", - }; - } - } - + $response = $this->api()->get('/api/v1/guiderail-models', $params); + $body = $response->successful() ? $response->json('data', []) : []; $data = [ 'data' => $body['data'] ?? [], 'total' => $body['total'] ?? 0, @@ -77,17 +58,16 @@ public function index(Request $request, string $category = 'GUIDERAIL_MODEL'): V 'last_page' => $body['last_page'] ?? 1, ]; - $filterOptions = []; - if (! $apiError) { - $filterResponse = $this->api()->get('/api/v1/guiderail-models/filters'); - $filterOptions = $filterResponse->successful() ? $filterResponse->json('data', []) : []; - } + $filterResponse = $this->api()->get('/api/v1/guiderail-models/filters'); + $filterOptions = $filterResponse->successful() ? $filterResponse->json('data', []) : []; if ($request->header('HX-Request')) { + // 필터/검색 HTMX (hx-target="#items-table") → 파셜 반환 if ($request->header('HX-Target') === 'items-table') { - return view('bending.products.partials.table', ['items' => $data, 'config' => $config, 'category' => $category, 'apiError' => $apiError]); + return view('bending.products.partials.table', ['items' => $data, 'config' => $config, 'category' => $category]); } + // 사이드바 등 그 외 HTMX → 전체 페이지 리로드 return response('', 200)->header('HX-Redirect', route("bending.{$config['prefix']}.index", $request->query())); } @@ -96,7 +76,6 @@ public function index(Request $request, string $category = 'GUIDERAIL_MODEL'): V 'filterOptions' => $filterOptions, 'config' => $config, 'category' => $category, - 'apiError' => $apiError, ]); } diff --git a/resources/views/bending/base/partials/table.blade.php b/resources/views/bending/base/partials/table.blade.php deleted file mode 100644 index a70655ee..00000000 --- a/resources/views/bending/base/partials/table.blade.php +++ /dev/null @@ -1,179 +0,0 @@ -@php - $itemList = $items['data'] ?? $items ?? []; - $total = $items['total'] ?? count($itemList); - $currentPage = $items['current_page'] ?? 1; - $lastPage = $items['last_page'] ?? 1; -@endphp - -
| NO | -코드 | -대분류 | -인정 | -분류 | -품명 | -규격 | -재질 | -이미지 | -모델 | -폭합 | -절곡수 | -등록일 | -수정자 | -작업 | -
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $item['id'] }} | -{{ $item['code'] }} | -- - {{ $itemSep }} - - | -- @if($modelUA) - {{ $modelUA }} - @else - - - @endif - | -{{ $item['item_bending'] ?? '-' }} | -{{ $item['item_name'] ?? $item['name'] }} | -{{ $item['item_spec'] ?? '-' }} | -{{ $item['material'] ?? '-' }} | -
- @if(!empty($item['image_file_id']))
-
-
- @else
- -
- @endif
- |
- {{ $item['model_name'] ?? '-' }} | -{{ $widthSum ?? '-' }} | -- @if($bendCount > 0) - {{ $bendCount }} - @else - - - @endif - | -{{ $createdAt ? \Illuminate\Support\Str::before($createdAt, ' ') : '-' }} | -{{ $item['modified_by'] ?? '-' }} | -- 수정 - | -
|
- @if(!empty($apiError))
-
-
-
- @else
- 데이터가 없습니다.
- @endif
- {{ $apiError }} - |
- ||||||||||||||
전체 {{ $total }}건
- -| NO | - @if($isCase) -박스(가로×세로) | -점검구 | -전면밑 | -레일폭 | - @elseif($isBottom) -모델명 | -대분류 | -인정 | -가로×세로 | -마감 | - @else -모델명 | -대분류 | -인정 | -형상 | -레일폭×높이 | -마감 | - @endif -이미지 | -부품수 | -소요자재량 | -검색어 | -수정자 | -작업지시서 | -작업 | -
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $item['id'] }} | - @if($isCase) -- {{ $item['box_width'] ?? '-' }}×{{ $item['box_height'] ?? '-' }} - | -{{ $item['exit_direction'] ?? '-' }} | -{{ $item['front_bottom_width'] ?? '-' }} | -{{ $item['rail_width'] ?? '-' }} | - @elseif($isBottom) -{{ $item['model_name'] ?? $item['name'] }} | -- @php $sep = $item['item_sep'] ?? '-'; @endphp - {{ $sep }} - | -- @if($item['model_UA'] ?? null) - {{ $item['model_UA'] }} - @else - @endif - | -{{ ($item['bar_width'] ?? '-') }}×{{ ($item['bar_height'] ?? '-') }} | -{{ $item['finishing_type'] ?? '-' }} | - @else -{{ $item['model_name'] ?? $item['name'] }} | -- @php $sep = $item['item_sep'] ?? '-'; @endphp - {{ $sep }} - | -- @if($item['model_UA'] ?? null) - {{ $item['model_UA'] }} - @else - @endif - | -{{ $item['check_type'] ?? '-' }} | -{{ ($item['rail_width'] ?? '-') }}×{{ ($item['rail_length'] ?? '-') }} | -{{ $item['finishing_type'] ?? '-' }} | - @endif -
- @if(!empty($item['image_file_id']))
-
-
- @else
- -
- @endif
- |
- - {{ $item['component_count'] ?? 0 }} - | -- @foreach(($item['material_summary'] ?? []) as $mat => $total) - {{ $mat }}: {{ $total }} - @if(!$loop->last) | @endif - @endforeach - @if(empty($item['material_summary'])) - @endif - | -{{ $item['search_keyword'] ?? '-' }} | -{{ $item['modified_by'] ?? '-' }} | -- @if(!empty($item['id'])) - - @endif - | -- 수정 - | -
|
- @if(!empty($apiError))
-
-
-
- @else
- 데이터가 없습니다.
- @endif
- {{ $apiError }} - |
- ||||||||||||||||||||||
전체 {{ $total }}건
- -