feat:문서관리 Phase 4.2 - show.blade.php 섹션 테이블 읽기전용 렌더링
- 5가지 컬럼 타입 렌더링 (complex/select/check/measurement/text) - select 판정값 배지 표시 (적합=초록, 부적합=빨강) - check 체크마크 SVG, measurement mono 폰트 - 정적 컬럼 매핑 (NO/검사항목/기준/방식/주기/규격/분류) - 종합판정 + 비고 Footer (마지막 섹션 하단) - 검사 기준 이미지 표시 - 버그 수정: field_key→Str::slug, field_type, section.name→title Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -108,12 +108,13 @@ class="bg-gray-200 hover:bg-gray-300 text-gray-700 px-4 py-2 rounded-lg transiti
|
||||
<dl class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
@foreach($document->template->basicFields as $field)
|
||||
@php
|
||||
$fieldData = $document->data->where('field_key', $field->field_key)->first();
|
||||
$fieldKey = \Illuminate\Support\Str::slug($field->label, '_');
|
||||
$fieldData = $document->data->where('field_key', $fieldKey)->first();
|
||||
$value = $fieldData?->field_value ?? '-';
|
||||
@endphp
|
||||
<div class="{{ $field->type === 'textarea' ? 'col-span-2' : '' }}">
|
||||
<div class="{{ $field->field_type === 'textarea' ? 'col-span-2' : '' }}">
|
||||
<dt class="text-sm font-medium text-gray-500">{{ $field->label }}</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 {{ $field->type === 'textarea' ? 'whitespace-pre-wrap' : '' }}">{{ $value }}</dd>
|
||||
<dd class="mt-1 text-sm text-gray-900 {{ $field->field_type === 'textarea' ? 'whitespace-pre-wrap' : '' }}">{{ $value }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
</dl>
|
||||
@@ -124,8 +125,163 @@ class="bg-gray-200 hover:bg-gray-300 text-gray-700 px-4 py-2 rounded-lg transiti
|
||||
@if($document->template?->sections && $document->template->sections->count() > 0)
|
||||
@foreach($document->template->sections as $section)
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
|
||||
<h2 class="text-lg font-semibold text-gray-800 mb-4">{{ $section->name }}</h2>
|
||||
<p class="text-sm text-gray-500">테이블 형태의 데이터 표시는 추후 구현 예정입니다.</p>
|
||||
<h2 class="text-lg font-semibold text-gray-800 mb-4">{{ $section->title }}</h2>
|
||||
@if($section->image_path)
|
||||
<img src="{{ asset($section->image_path) }}" alt="{{ $section->title }}" class="max-w-full h-auto mb-4 rounded border">
|
||||
@endif
|
||||
|
||||
{{-- 검사 데이터 테이블 (읽기 전용) --}}
|
||||
@if($section->items->count() > 0 && $document->template->columns->count() > 0)
|
||||
<div class="overflow-x-auto mt-4">
|
||||
<table class="min-w-full border border-gray-300 text-sm">
|
||||
{{-- 테이블 헤더 --}}
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
@foreach($document->template->columns as $col)
|
||||
@if($col->column_type === 'complex' && $col->sub_labels)
|
||||
<th colspan="{{ count($col->sub_labels) }}"
|
||||
class="px-2 py-2 text-center text-xs font-medium text-gray-600 uppercase border border-gray-300"
|
||||
style="min-width: {{ $col->width }}">
|
||||
{{ $col->label }}
|
||||
</th>
|
||||
@else
|
||||
<th rowspan="{{ $document->template->columns->contains(fn($c) => $c->column_type === 'complex' && $c->sub_labels) ? 2 : 1 }}"
|
||||
class="px-2 py-2 text-center text-xs font-medium text-gray-600 uppercase border border-gray-300"
|
||||
style="min-width: {{ $col->width }}">
|
||||
{{ $col->label }}
|
||||
</th>
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
{{-- 서브 라벨 행 --}}
|
||||
@if($document->template->columns->contains(fn($c) => $c->column_type === 'complex' && $c->sub_labels))
|
||||
<tr>
|
||||
@foreach($document->template->columns as $col)
|
||||
@if($col->column_type === 'complex' && $col->sub_labels)
|
||||
@foreach($col->sub_labels as $subLabel)
|
||||
<th class="px-2 py-1 text-center text-xs font-medium text-gray-500 border border-gray-300 bg-gray-50">
|
||||
{{ $subLabel }}
|
||||
</th>
|
||||
@endforeach
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
@endif
|
||||
</thead>
|
||||
{{-- 테이블 바디 (읽기 전용) --}}
|
||||
<tbody>
|
||||
@foreach($section->items as $rowIndex => $item)
|
||||
<tr class="hover:bg-gray-50">
|
||||
@foreach($document->template->columns as $col)
|
||||
@if($col->column_type === 'complex' && $col->sub_labels)
|
||||
{{-- complex: 서브 라벨별 데이터 --}}
|
||||
@foreach($col->sub_labels as $subIndex => $subLabel)
|
||||
@php
|
||||
$fieldKey = "s{$section->id}_r{$rowIndex}_c{$col->id}_sub{$subIndex}";
|
||||
$savedVal = $document->data->where('field_key', $fieldKey)->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<td class="px-2 py-2 border border-gray-300 text-center text-sm">{{ $savedVal ?: '-' }}</td>
|
||||
@endforeach
|
||||
@elseif($col->column_type === 'select')
|
||||
{{-- select: 판정 결과 --}}
|
||||
@php
|
||||
$fieldKey = "s{$section->id}_r{$rowIndex}_c{$col->id}";
|
||||
$savedVal = $document->data->where('field_key', $fieldKey)->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<td class="px-2 py-2 border border-gray-300 text-center text-sm">
|
||||
@if($savedVal)
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium
|
||||
{{ $savedVal === '적합' || $savedVal === '합격' || $savedVal === 'OK' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800' }}">
|
||||
{{ $savedVal }}
|
||||
</span>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
@elseif($col->column_type === 'check')
|
||||
{{-- check: 체크 결과 --}}
|
||||
@php
|
||||
$fieldKey = "s{$section->id}_r{$rowIndex}_c{$col->id}";
|
||||
$savedVal = $document->data->where('field_key', $fieldKey)->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<td class="px-2 py-2 border border-gray-300 text-center text-sm">
|
||||
@if($savedVal === 'OK')
|
||||
<svg class="w-5 h-5 text-green-500 mx-auto" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
@elseif($col->column_type === 'measurement')
|
||||
{{-- measurement: 수치 데이터 --}}
|
||||
@php
|
||||
$fieldKey = "s{$section->id}_r{$rowIndex}_c{$col->id}";
|
||||
$savedVal = $document->data->where('field_key', $fieldKey)->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<td class="px-2 py-2 border border-gray-300 text-center text-sm font-mono">{{ $savedVal ?: '-' }}</td>
|
||||
@else
|
||||
{{-- text: 정적 데이터 또는 입력된 텍스트 --}}
|
||||
@php
|
||||
$staticValue = match(true) {
|
||||
str_contains(strtolower($col->label), 'no') && strlen($col->label) <= 4 => $rowIndex + 1,
|
||||
in_array($col->label, ['검사항목', '항목']) => $item->item,
|
||||
in_array($col->label, ['검사기준', '기준']) => $item->standard,
|
||||
in_array($col->label, ['검사방식', '방식', '검사방법']) => $item->method,
|
||||
in_array($col->label, ['검사주기', '주기']) => $item->frequency,
|
||||
in_array($col->label, ['규격', '적용규격', '관련규정']) => $item->regulation,
|
||||
in_array($col->label, ['분류', '카테고리']) => $item->category,
|
||||
default => null,
|
||||
};
|
||||
@endphp
|
||||
@if($staticValue !== null)
|
||||
<td class="px-2 py-2 border border-gray-300 text-sm text-gray-700 {{ is_numeric($staticValue) ? 'text-center' : '' }}">
|
||||
{{ $staticValue }}
|
||||
</td>
|
||||
@else
|
||||
@php
|
||||
$fieldKey = "s{$section->id}_r{$rowIndex}_c{$col->id}";
|
||||
$savedVal = $document->data->where('field_key', $fieldKey)->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<td class="px-2 py-2 border border-gray-300 text-center text-sm">{{ $savedVal ?: '-' }}</td>
|
||||
@endif
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 종합판정 / 비고 (마지막 섹션에만) --}}
|
||||
@if($loop->last && $document->template->footer_judgement_label)
|
||||
<div class="mt-6 grid grid-cols-1 md:grid-cols-2 gap-4 pt-4 border-t border-gray-200">
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">{{ $document->template->footer_remark_label ?? '비고' }}</dt>
|
||||
@php
|
||||
$remarkVal = $document->data->where('field_key', 'footer_remark')->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<dd class="mt-1 text-sm text-gray-900 whitespace-pre-wrap">{{ $remarkVal ?: '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">{{ $document->template->footer_judgement_label ?? '종합판정' }}</dt>
|
||||
@php
|
||||
$judgementVal = $document->data->where('field_key', 'footer_judgement')->first()?->field_value ?? '';
|
||||
@endphp
|
||||
<dd class="mt-1">
|
||||
@if($judgementVal)
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium
|
||||
{{ $judgementVal === '적합' || $judgementVal === '합격' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800' }}">
|
||||
{{ $judgementVal }}
|
||||
</span>
|
||||
@else
|
||||
<span class="text-sm text-gray-500">-</span>
|
||||
@endif
|
||||
</dd>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user