- 템플릿별 동적 필드 정의 (document_template_section_fields) - 외부 키 매핑 동적화 (document_template_links + link_values) - 문서 레벨 연결 (document_links) - 시스템 프리셋 (document_template_field_presets) - section_items에 field_values JSON 컬럼 추가 - 기존 고정 필드 → 동적 field_values 데이터 마이그레이션 - search_api → source_table 전환 마이그레이션 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
149 lines
9.4 KiB
PHP
149 lines
9.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DocumentTemplateFieldPresetSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$now = now();
|
|
|
|
DB::table('document_template_field_presets')->truncate();
|
|
|
|
// 수입검사 프리셋
|
|
DB::table('document_template_field_presets')->insert([
|
|
'name' => '수입검사 기본 필드 세트',
|
|
'category' => '수입검사',
|
|
'fields' => json_encode([
|
|
['field_key' => 'category', 'label' => '구분', 'field_type' => 'text', 'width' => '65px', 'is_required' => false],
|
|
['field_key' => 'item', 'label' => '검사항목', 'field_type' => 'text', 'width' => '130px', 'is_required' => true],
|
|
['field_key' => 'standard', 'label' => '검사기준', 'field_type' => 'text', 'width' => '180px', 'is_required' => false],
|
|
['field_key' => 'standard_criteria', 'label' => '기준범위', 'field_type' => 'json_criteria', 'width' => '100px', 'is_required' => false],
|
|
['field_key' => 'tolerance', 'label' => '공차/범위', 'field_type' => 'json_tolerance', 'width' => '120px', 'is_required' => false],
|
|
['field_key' => 'method', 'label' => '검사방식', 'field_type' => 'select_api', 'width' => '110px', 'is_required' => false, 'options' => [
|
|
'api_endpoint' => '/api/admin/common-codes/inspection_method',
|
|
'auto_map' => [
|
|
'target_field' => 'measurement_type',
|
|
'mapping' => [
|
|
'visual' => 'checkbox',
|
|
'check' => 'numeric',
|
|
'mill_sheet' => 'single_value',
|
|
'certified_agency' => 'single_value',
|
|
'substitute_cert' => 'substitute',
|
|
'other' => 'text',
|
|
],
|
|
],
|
|
]],
|
|
['field_key' => 'measurement_type', 'label' => '측정유형', 'field_type' => 'select', 'width' => '100px', 'is_required' => false, 'options' => [
|
|
'choices' => [
|
|
['code' => 'checkbox', 'name' => 'OK/NG 체크'],
|
|
['code' => 'numeric', 'name' => '수치입력(3)'],
|
|
['code' => 'single_value', 'name' => '단일값'],
|
|
['code' => 'substitute', 'name' => '성적서 대체'],
|
|
['code' => 'text', 'name' => '자유입력'],
|
|
],
|
|
]],
|
|
['field_key' => 'frequency', 'label' => '검사주기', 'field_type' => 'composite_frequency', 'width' => '120px', 'is_required' => false],
|
|
['field_key' => 'regulation', 'label' => '관련규정', 'field_type' => 'text', 'width' => '80px', 'is_required' => false],
|
|
], JSON_UNESCAPED_UNICODE),
|
|
'links' => json_encode([
|
|
['link_key' => 'items', 'label' => '연결 품목 (RM, SM)', 'link_type' => 'multiple', 'source_table' => 'items', 'search_params' => ['item_type' => 'RM,SM'], 'display_fields' => ['title' => 'name', 'subtitle' => 'code']],
|
|
], JSON_UNESCAPED_UNICODE),
|
|
'sort_order' => 0,
|
|
'created_at' => $now,
|
|
'updated_at' => $now,
|
|
]);
|
|
|
|
// 품질검사 프리셋
|
|
DB::table('document_template_field_presets')->insert([
|
|
'name' => '품질검사 기본 필드 세트',
|
|
'category' => '품질검사',
|
|
'fields' => json_encode([
|
|
['field_key' => 'category', 'label' => '구분', 'field_type' => 'text', 'width' => '65px', 'is_required' => false],
|
|
['field_key' => 'item', 'label' => '검사항목', 'field_type' => 'text', 'width' => '130px', 'is_required' => true],
|
|
['field_key' => 'standard', 'label' => '검사기준', 'field_type' => 'text', 'width' => '180px', 'is_required' => false],
|
|
['field_key' => 'standard_criteria', 'label' => '기준범위', 'field_type' => 'json_criteria', 'width' => '100px', 'is_required' => false],
|
|
['field_key' => 'tolerance', 'label' => '공차/범위', 'field_type' => 'json_tolerance', 'width' => '120px', 'is_required' => false],
|
|
['field_key' => 'method', 'label' => '검사방식', 'field_type' => 'select_api', 'width' => '110px', 'is_required' => false, 'options' => [
|
|
'api_endpoint' => '/api/admin/common-codes/inspection_method',
|
|
'auto_map' => [
|
|
'target_field' => 'measurement_type',
|
|
'mapping' => [
|
|
'visual' => 'checkbox',
|
|
'check' => 'numeric',
|
|
'mill_sheet' => 'single_value',
|
|
'certified_agency' => 'single_value',
|
|
'substitute_cert' => 'substitute',
|
|
'other' => 'text',
|
|
],
|
|
],
|
|
]],
|
|
['field_key' => 'measurement_type', 'label' => '측정유형', 'field_type' => 'select', 'width' => '100px', 'is_required' => false, 'options' => [
|
|
'choices' => [
|
|
['code' => 'checkbox', 'name' => 'OK/NG 체크'],
|
|
['code' => 'numeric', 'name' => '수치입력(3)'],
|
|
['code' => 'single_value', 'name' => '단일값'],
|
|
['code' => 'substitute', 'name' => '성적서 대체'],
|
|
['code' => 'text', 'name' => '자유입력'],
|
|
],
|
|
]],
|
|
['field_key' => 'frequency', 'label' => '검사주기', 'field_type' => 'composite_frequency', 'width' => '120px', 'is_required' => false],
|
|
['field_key' => 'regulation', 'label' => '관련규정', 'field_type' => 'text', 'width' => '80px', 'is_required' => false],
|
|
], JSON_UNESCAPED_UNICODE),
|
|
'links' => json_encode([
|
|
['link_key' => 'process', 'label' => '연결 공정', 'link_type' => 'single', 'source_table' => 'processes', 'search_params' => null, 'display_fields' => ['title' => 'process_name', 'subtitle' => 'process_code']],
|
|
], JSON_UNESCAPED_UNICODE),
|
|
'sort_order' => 1,
|
|
'created_at' => $now,
|
|
'updated_at' => $now,
|
|
]);
|
|
|
|
// 출하검사 프리셋
|
|
DB::table('document_template_field_presets')->insert([
|
|
'name' => '출하검사 기본 필드 세트',
|
|
'category' => '출하검사',
|
|
'fields' => json_encode([
|
|
['field_key' => 'category', 'label' => '구분', 'field_type' => 'text', 'width' => '65px', 'is_required' => false],
|
|
['field_key' => 'item', 'label' => '검사항목', 'field_type' => 'text', 'width' => '130px', 'is_required' => true],
|
|
['field_key' => 'standard', 'label' => '검사기준', 'field_type' => 'text', 'width' => '180px', 'is_required' => false],
|
|
['field_key' => 'standard_criteria', 'label' => '기준범위', 'field_type' => 'json_criteria', 'width' => '100px', 'is_required' => false],
|
|
['field_key' => 'tolerance', 'label' => '공차/범위', 'field_type' => 'json_tolerance', 'width' => '120px', 'is_required' => false],
|
|
['field_key' => 'method', 'label' => '검사방식', 'field_type' => 'select_api', 'width' => '110px', 'is_required' => false, 'options' => [
|
|
'api_endpoint' => '/api/admin/common-codes/inspection_method',
|
|
'auto_map' => [
|
|
'target_field' => 'measurement_type',
|
|
'mapping' => [
|
|
'visual' => 'checkbox',
|
|
'check' => 'numeric',
|
|
'mill_sheet' => 'single_value',
|
|
'certified_agency' => 'single_value',
|
|
'substitute_cert' => 'substitute',
|
|
'other' => 'text',
|
|
],
|
|
],
|
|
]],
|
|
['field_key' => 'measurement_type', 'label' => '측정유형', 'field_type' => 'select', 'width' => '100px', 'is_required' => false, 'options' => [
|
|
'choices' => [
|
|
['code' => 'checkbox', 'name' => 'OK/NG 체크'],
|
|
['code' => 'numeric', 'name' => '수치입력(3)'],
|
|
['code' => 'single_value', 'name' => '단일값'],
|
|
['code' => 'substitute', 'name' => '성적서 대체'],
|
|
['code' => 'text', 'name' => '자유입력'],
|
|
],
|
|
]],
|
|
['field_key' => 'frequency', 'label' => '검사주기', 'field_type' => 'composite_frequency', 'width' => '120px', 'is_required' => false],
|
|
['field_key' => 'regulation', 'label' => '관련규정', 'field_type' => 'text', 'width' => '80px', 'is_required' => false],
|
|
], JSON_UNESCAPED_UNICODE),
|
|
'links' => json_encode([
|
|
['link_key' => 'lot', 'label' => '로트번호', 'link_type' => 'single', 'source_table' => 'lots', 'search_params' => null, 'display_fields' => ['title' => 'lot_no', 'subtitle' => 'item_name']],
|
|
], JSON_UNESCAPED_UNICODE),
|
|
'sort_order' => 2,
|
|
'created_at' => $now,
|
|
'updated_at' => $now,
|
|
]);
|
|
}
|
|
}
|