feat: 수입검사 성적서 템플릿 시더 및 미리보기 구현

- InspectionTemplateSeeder: 검사항목 4개(겉모양, 두께, 폭, 길이) 생성
- 템플릿 미리보기를 React 성적서 양식과 동일한 형태로 구현
  - 헤더: 로고, 제목, 결재란
  - 기본정보 테이블 (목업 데이터)
  - 검사항목 테이블: NO, 검사항목, 검사기준, 검사방식, 검사주기, 측정값(n1,n2,n3), 판정
  - 종합판정 영역
- 문서 목록/상세/편집 뷰 개선

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-29 01:06:53 +09:00
parent 1e70d2edbf
commit 6d708cfdda
5 changed files with 276 additions and 160 deletions

View File

@@ -0,0 +1,78 @@
<?php
namespace Database\Seeders;
use App\Models\DocumentTemplate;
use App\Models\DocumentTemplateApprovalLine;
use App\Models\DocumentTemplateBasicField;
use App\Models\DocumentTemplateColumn;
use App\Models\DocumentTemplateSection;
use App\Models\DocumentTemplateSectionItem;
use Illuminate\Database\Seeder;
class InspectionTemplateSeeder extends Seeder
{
/**
* 수입검사 성적서 템플릿 - 검사항목 테이블만
*/
public function run(): void
{
$tenantId = 1;
$this->cleanupExisting($tenantId);
// 템플릿 생성
$template = DocumentTemplate::create([
'tenant_id' => $tenantId,
'name' => '철제품 수입검사 성적서',
'category' => '품질/수입검사',
'title' => '수입검사 성적서',
'is_active' => true,
]);
// 검사항목 섹션
$section = DocumentTemplateSection::create([
'template_id' => $template->id,
'title' => '검사 항목',
'sort_order' => 1,
]);
// 검사항목 (React 모달과 동일)
$items = [
['item' => '겉모양', 'standard' => '외관 이상 없음', 'method' => '육안'],
['item' => '두께', 'standard' => 't 1.0', 'method' => '계측'],
['item' => '폭', 'standard' => 'W 1,000mm', 'method' => '계측'],
['item' => '길이', 'standard' => 'L 2,000mm', 'method' => '계측'],
];
foreach ($items as $i => $item) {
DocumentTemplateSectionItem::create([
'section_id' => $section->id,
'item' => $item['item'],
'standard' => $item['standard'],
'method' => $item['method'],
'sort_order' => $i + 1,
]);
}
$this->command->info("✅ 템플릿 생성 완료 (ID: {$template->id})");
}
private function cleanupExisting(int $tenantId): void
{
$existing = DocumentTemplate::where('tenant_id', $tenantId)
->where('name', '철제품 수입검사 성적서')
->first();
if ($existing) {
DocumentTemplateColumn::where('template_id', $existing->id)->delete();
$sections = DocumentTemplateSection::where('template_id', $existing->id)->get();
foreach ($sections as $section) {
DocumentTemplateSectionItem::where('section_id', $section->id)->delete();
}
DocumentTemplateSection::where('template_id', $existing->id)->delete();
DocumentTemplateBasicField::where('template_id', $existing->id)->delete();
DocumentTemplateApprovalLine::where('template_id', $existing->id)->delete();
$existing->forceDelete();
}
}
}