feat: [approval] 반려 이력 관리 기능 추가
- rejection_history JSON 컬럼으로 반려 이력 누적 저장 - 재상신 시 반려자, 사유, 일시를 이력에 기록 - 상세 페이지에 반려 이력 섹션 표시 (빨간 테두리) - 수정 페이지에 이전 반려 이력 표시 (주황 배경)
This commit is contained in:
@@ -23,6 +23,7 @@ class Approval extends Model
|
||||
'drafter_read_at' => 'datetime',
|
||||
'current_step' => 'integer',
|
||||
'resubmit_count' => 'integer',
|
||||
'rejection_history' => 'array',
|
||||
'is_urgent' => 'boolean',
|
||||
];
|
||||
|
||||
@@ -43,6 +44,7 @@ class Approval extends Model
|
||||
'drafter_read_at',
|
||||
'current_step',
|
||||
'resubmit_count',
|
||||
'rejection_history',
|
||||
'attachments',
|
||||
'recall_reason',
|
||||
'parent_doc_id',
|
||||
|
||||
@@ -243,9 +243,24 @@ public function submit(int $id): Approval
|
||||
throw new \InvalidArgumentException('결재선을 설정해주세요.');
|
||||
}
|
||||
|
||||
// 반려 후 재상신이면 모든 step 초기화 + 재상신 카운트 증가
|
||||
// 반려 후 재상신이면 반려 이력 저장 + 모든 step 초기화 + 재상신 카운트 증가
|
||||
$isResubmit = $approval->status === Approval::STATUS_REJECTED;
|
||||
if ($isResubmit) {
|
||||
// 반려 이력 저장
|
||||
$rejectedStep = $approval->steps
|
||||
->firstWhere('status', ApprovalStep::STATUS_REJECTED);
|
||||
if ($rejectedStep) {
|
||||
$history = $approval->rejection_history ?? [];
|
||||
$history[] = [
|
||||
'round' => $approval->resubmit_count + 1,
|
||||
'approver_name' => $rejectedStep->approver_name ?? ($rejectedStep->approver?->name ?? ''),
|
||||
'approver_position' => $rejectedStep->approver_position ?? '',
|
||||
'comment' => $rejectedStep->comment,
|
||||
'rejected_at' => $rejectedStep->acted_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
$approval->rejection_history = $history;
|
||||
}
|
||||
|
||||
$approval->steps()->update([
|
||||
'status' => ApprovalStep::STATUS_PENDING,
|
||||
'comment' => null,
|
||||
|
||||
@@ -35,6 +35,28 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 반려 이력 (재상신 문서인 경우) --}}
|
||||
@if(!empty($approval->rejection_history))
|
||||
<div class="bg-orange-50 border border-orange-200 p-4 mb-6 rounded-lg" style="max-width: 960px; margin-left: auto; margin-right: auto;">
|
||||
<h4 class="text-sm font-semibold text-orange-800 mb-2 flex items-center gap-2">
|
||||
이전 반려 이력
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-orange-200 text-orange-700">{{ count($approval->rejection_history) }}회</span>
|
||||
</h4>
|
||||
<div class="space-y-2">
|
||||
@foreach($approval->rejection_history as $history)
|
||||
<div class="text-sm border-l-2 border-orange-300 pl-3 py-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-xs font-medium text-orange-600">{{ $history['round'] ?? '-' }}차</span>
|
||||
<span class="font-medium text-gray-800">{{ $history['approver_name'] ?? '' }}</span>
|
||||
<span class="text-gray-400 text-xs">{{ $history['rejected_at'] ?? '' }}</span>
|
||||
</div>
|
||||
<p class="text-gray-600 mt-0.5">{{ $history['comment'] ?? '' }}</p>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mx-auto" style="max-width: 960px;">
|
||||
<div class="bg-white rounded-lg shadow-sm p-6">
|
||||
<h2 class="text-lg font-semibold text-gray-800 mb-4">문서 내용</h2>
|
||||
|
||||
@@ -92,6 +92,31 @@ class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg transition
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 반려 이력 --}}
|
||||
@if(!empty($approval->rejection_history))
|
||||
<div class="bg-white rounded-lg shadow-sm p-6 mb-6">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center gap-2">
|
||||
반려 이력
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-700">{{ count($approval->rejection_history) }}회</span>
|
||||
</h3>
|
||||
<div class="space-y-3">
|
||||
@foreach($approval->rejection_history as $history)
|
||||
<div class="border-l-3 border-red-300 pl-4 py-2" style="border-left: 3px solid #fca5a5;">
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-50 text-red-600">{{ $history['round'] ?? '-' }}차 반려</span>
|
||||
<span class="font-medium text-gray-800">{{ $history['approver_name'] ?? '' }}</span>
|
||||
@if(!empty($history['approver_position']))
|
||||
<span class="text-gray-400 text-xs">{{ $history['approver_position'] }}</span>
|
||||
@endif
|
||||
<span class="text-gray-400 text-xs">{{ $history['rejected_at'] ?? '' }}</span>
|
||||
</div>
|
||||
<p class="text-sm text-gray-700 mt-1">{{ $history['comment'] ?? '' }}</p>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 결재 의견 --}}
|
||||
@php
|
||||
$stepsWithComments = $approval->steps->filter(fn($s) => $s->comment);
|
||||
|
||||
Reference in New Issue
Block a user