feat: 문서 양식 관리 및 수입검사 양식 개선
- 문서 양식 API 컨트롤러 및 뷰 개선 - 수입검사 양식 시더 업데이트 - 문서 미리보기 뷰 개선 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -213,7 +213,18 @@ private function prepareTemplateData(DocumentTemplate $template): array
|
||||
'is_required' => $f->is_required,
|
||||
];
|
||||
})->toArray(),
|
||||
'template_links' => $template->links->map(function ($l) {
|
||||
'template_links' => $this->buildTemplateLinks($template),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* template_links 데이터 빌드 (linked_item_ids 레거시 호환)
|
||||
*/
|
||||
private function buildTemplateLinks(DocumentTemplate $template): array
|
||||
{
|
||||
// 신규 template_links가 있으면 그대로 사용
|
||||
if ($template->links->isNotEmpty()) {
|
||||
return $template->links->map(function ($l) {
|
||||
$values = $l->linkValues->map(function ($v) use ($l) {
|
||||
$displayText = $this->resolveDisplayText($l->source_table, $v->linkable_id, $l->display_fields);
|
||||
|
||||
@@ -235,8 +246,35 @@ private function prepareTemplateData(DocumentTemplate $template): array
|
||||
'is_required' => $l->is_required,
|
||||
'values' => $values,
|
||||
];
|
||||
})->toArray(),
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
// 레거시: linked_item_ids만 있고 template_links가 없는 경우 가상 엔트리 생성
|
||||
$linkedItemIds = $template->linked_item_ids;
|
||||
if (! empty($linkedItemIds) && is_array($linkedItemIds)) {
|
||||
$displayFields = ['title' => 'name', 'subtitle' => 'code'];
|
||||
$values = collect($linkedItemIds)->map(function ($itemId) use ($displayFields) {
|
||||
return [
|
||||
'id' => $itemId,
|
||||
'linkable_id' => $itemId,
|
||||
'display_text' => $this->resolveDisplayText('items', $itemId, $displayFields),
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
return [[
|
||||
'id' => 'legacy',
|
||||
'link_key' => 'items',
|
||||
'label' => '연결 품목',
|
||||
'link_type' => 'multiple',
|
||||
'source_table' => 'items',
|
||||
'search_params' => null,
|
||||
'display_fields' => $displayFields,
|
||||
'is_required' => false,
|
||||
'values' => $values,
|
||||
]];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user