feat:문서 템플릿 기본필드 field_key 연동키 드롭다운 추가

- DocumentTemplateController: common_codes(doc_template_basic_field) 조회하여 뷰에 전달
- prepareTemplateData: basic_fields에 field_key 포함
- DocumentTemplateApiController: basic_fields 저장 시 field_key 포함
- edit.blade.php: 기본필드 행에 '연동키 선택' 드롭다운 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 14:24:25 +09:00
parent 007abbfc44
commit f74288e5e5
5 changed files with 25 additions and 7 deletions

View File

@@ -593,6 +593,7 @@ private function saveRelations(DocumentTemplate $template, array $data, bool $de
DocumentTemplateBasicField::create([
'template_id' => $template->id,
'label' => $field['label'] ?? '',
'field_key' => $field['field_key'] ?? null,
'field_type' => $field['field_type'] ?? 'text',
'default_value' => $field['default_value'] ?? '',
'sort_order' => $index,

View File

@@ -4,6 +4,7 @@
use App\Models\DocumentTemplate;
use App\Models\DocumentTemplateFieldPreset;
use App\Models\Products\CommonCode;
use App\Models\Tenants\Tenant;
use App\Models\User;
use Illuminate\Http\Request;
@@ -39,6 +40,7 @@ public function create(): View
'categories' => $this->getCategories(),
'tenant' => $this->getCurrentTenant(),
'presets' => DocumentTemplateFieldPreset::orderBy('sort_order')->get(),
'basicFieldKeys' => $this->getBasicFieldKeys(),
]);
}
@@ -66,6 +68,7 @@ public function edit(int $id): View
'categories' => $this->getCategories(),
'tenant' => $this->getCurrentTenant(),
'presets' => DocumentTemplateFieldPreset::orderBy('sort_order')->get(),
'basicFieldKeys' => $this->getBasicFieldKeys(),
]);
}
@@ -79,6 +82,19 @@ private function getCurrentTenant(): ?Tenant
return $tenantId ? Tenant::find($tenantId) : null;
}
/**
* 기본필드 키 옵션 조회 (common_codes 기반)
*/
private function getBasicFieldKeys(): array
{
return CommonCode::query()
->where('code_group', 'doc_template_basic_field')
->where('is_active', true)
->orderBy('sort_order')
->get(['code', 'name'])
->toArray();
}
/**
* 문서분류 목록 조회 (common_codes 기반 + 기존 데이터 폴백)
*/
@@ -167,6 +183,7 @@ private function prepareTemplateData(DocumentTemplate $template): array
return [
'id' => $f->id,
'label' => $f->label,
'field_key' => $f->field_key,
'field_type' => $f->field_type,
'default_value' => $f->default_value,
];