feat:문서양식 검사기준서→테이블컬럼 자동 파생 (Phase 5.0)

- generateColumnsFromItems() JS 함수: items의 measurement_type 분석 → 정적+동적 columns 자동 생성
- 테이블 컬럼 탭에 "기준서에서 자동 생성" 버튼 및 상태 indicator 추가
- IncomingInspectionTemplateSeeder에 section_fields 6개 필드 추가
- MidInspectionTemplateSeeder에 section_fields 5개 필드 추가
- 시더 cleanup에 section_fields 삭제 로직 포함

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-10 15:36:39 +09:00
parent a57fbf5425
commit 98804811a2
3 changed files with 215 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
use App\Models\DocumentTemplateBasicField;
use App\Models\DocumentTemplateColumn;
use App\Models\DocumentTemplateSection;
use App\Models\DocumentTemplateSectionField;
use App\Models\DocumentTemplateSectionItem;
use Illuminate\Database\Seeder;
@@ -36,6 +37,7 @@ public function run(): void
$this->createApprovalLines($template->id);
$this->createBasicFields($template->id);
$this->createSection($template->id, $def['section_title'], $def['items']);
$this->createSectionFields($template->id);
$this->createColumns($template->id);
$this->command->info("{$def['name']} (ID: {$template->id})");
@@ -247,6 +249,28 @@ private function createSection(int $templateId, string $title, array $items): vo
}
}
/**
* 검사 기준서 동적 필드 정의 (수입검사 공통)
*/
private function createSectionFields(int $templateId): void
{
$fields = [
['field_key' => 'category', 'label' => '분류', 'field_type' => 'text', 'width' => '80px', 'is_required' => false, 'sort_order' => 1],
['field_key' => 'item', 'label' => '검사항목', 'field_type' => 'text', 'width' => '120px', 'is_required' => true, 'sort_order' => 2],
['field_key' => 'standard', 'label' => '검사기준', 'field_type' => 'text', 'width' => '150px', 'is_required' => true, 'sort_order' => 3],
['field_key' => 'method', 'label' => '검사방식', 'field_type' => 'select', 'width' => '100px', 'is_required' => false, 'sort_order' => 4],
['field_key' => 'frequency', 'label' => '검사주기', 'field_type' => 'text', 'width' => '80px', 'is_required' => false, 'sort_order' => 5],
['field_key' => 'regulation', 'label' => '관련규격', 'field_type' => 'text', 'width' => '100px', 'is_required' => false, 'sort_order' => 6],
];
foreach ($fields as $field) {
DocumentTemplateSectionField::create(array_merge(
['template_id' => $templateId],
$field,
));
}
}
/**
* 데이터 테이블 컬럼 (5130 공통 구조)
*/
@@ -288,6 +312,7 @@ private function cleanupExisting(string $name): void
}
DocumentTemplateColumn::where('template_id', $existing->id)->delete();
DocumentTemplateSectionField::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();

View File

@@ -7,6 +7,7 @@
use App\Models\DocumentTemplateBasicField;
use App\Models\DocumentTemplateColumn;
use App\Models\DocumentTemplateSection;
use App\Models\DocumentTemplateSectionField;
use App\Models\DocumentTemplateSectionItem;
use Illuminate\Database\Seeder;
@@ -40,6 +41,7 @@ public function run(): void
$this->createSection($template->id, $sectionDef['title'], $sectionDef['items'], $i + 1);
}
$this->createSectionFields($template->id);
$this->createColumns($template->id, $def['columns']);
$this->command->info("{$def['name']} (ID: {$template->id})");
@@ -465,6 +467,27 @@ private function createSection(int $templateId, string $title, array $items, int
}
}
/**
* 검사 기준서 동적 필드 정의 (중간검사 공통)
*/
private function createSectionFields(int $templateId): void
{
$fields = [
['field_key' => 'category', 'label' => '분류', 'field_type' => 'text', 'width' => '80px', 'is_required' => false, 'sort_order' => 1],
['field_key' => 'item', 'label' => '검사항목', 'field_type' => 'text', 'width' => '120px', 'is_required' => true, 'sort_order' => 2],
['field_key' => 'standard', 'label' => '검사기준', 'field_type' => 'text', 'width' => '150px', 'is_required' => true, 'sort_order' => 3],
['field_key' => 'method', 'label' => '검사방식', 'field_type' => 'select', 'width' => '100px', 'is_required' => false, 'sort_order' => 4],
['field_key' => 'frequency', 'label' => '검사주기', 'field_type' => 'text', 'width' => '80px', 'is_required' => false, 'sort_order' => 5],
];
foreach ($fields as $field) {
DocumentTemplateSectionField::create(array_merge(
['template_id' => $templateId],
$field,
));
}
}
/**
* 데이터 테이블 컬럼 (양식별 다름)
*/
@@ -489,6 +512,7 @@ private function cleanupExisting(string $name): void
}
DocumentTemplateColumn::where('template_id', $existing->id)->delete();
DocumentTemplateSectionField::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();