feat: [equipment] 점검표 판정란 자동 합격/불합격 로직 추가
- 일일점검: 주말 제외, 전체 셀 good/repaired → 합격 - 기타 주기: 전체 열 good/repaired → 합격 - 공백 또는 X(bad) 존재 시 불합격 표시
This commit is contained in:
@@ -39,6 +39,27 @@
|
||||
$rowCount = $templates->count();
|
||||
@endphp
|
||||
|
||||
@php
|
||||
// 자동 판정 계산: 주말(daily) 제외, 모든 셀이 good/repaired면 합격
|
||||
$totalChecks = 0;
|
||||
$passedChecks = 0;
|
||||
foreach ($templates as $tmpl) {
|
||||
foreach ($labels as $ci => $lbl) {
|
||||
if ($isDaily && \App\Enums\InspectionCycle::isWeekend($period, $ci)) {
|
||||
continue;
|
||||
}
|
||||
$totalChecks++;
|
||||
$cd = \App\Enums\InspectionCycle::resolveCheckDate($cycle, $period, $ci);
|
||||
$k = $tmpl->id . '_' . $cd;
|
||||
$d = isset($details[$k]) ? $details[$k]->first() : null;
|
||||
if ($d && in_array($d->result, ['good', 'repaired'])) {
|
||||
$passedChecks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$autoJudgment = $totalChecks > 0 ? ($passedChecks === $totalChecks ? 'pass' : 'fail') : null;
|
||||
@endphp
|
||||
|
||||
@foreach($templates as $idx => $tmpl)
|
||||
<tr class="{{ $idx === 0 ? 'border-t-2 border-gray-400' : '' }}">
|
||||
@if($idx === 0)
|
||||
@@ -78,10 +99,10 @@
|
||||
@if($idx === 0)
|
||||
<td class="border border-gray-300 px-2 py-1 text-center whitespace-nowrap"
|
||||
rowspan="{{ $rowCount }}">
|
||||
@if($inspection && $inspection->overall_judgment)
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium {{ $inspection->judgment_color }}">
|
||||
{{ $inspection->judgment_label }}
|
||||
</span>
|
||||
@if($autoJudgment === 'pass')
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">합격</span>
|
||||
@elseif($autoJudgment === 'fail')
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">불합격</span>
|
||||
@else
|
||||
<span class="text-gray-400">-</span>
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user