fix: [작업일지] 재공품 공정별 작업일지 양식 자동 판별
This commit is contained in:
@@ -42,8 +42,10 @@ interface WorkLogModalProps {
|
||||
* 양식명 → 공정 타입 매핑
|
||||
* 공정관리에서 매핑된 양식명을 기반으로 콘텐츠 컴포넌트를 결정
|
||||
*/
|
||||
function resolveProcessTypeFromTemplate(templateName?: string): ProcessType | undefined {
|
||||
function resolveProcessTypeFromTemplate(templateName?: string): ProcessType | 'template' | undefined {
|
||||
if (!templateName) return undefined;
|
||||
// 재공품 전용 작업일지는 템플릿 기반(범용) 렌더링
|
||||
if (templateName.includes('재공품')) return 'template';
|
||||
if (templateName.includes('스크린')) return 'screen';
|
||||
if (templateName.includes('슬랫')) return 'slat';
|
||||
if (templateName.includes('절곡')) return 'bending';
|
||||
@@ -236,11 +238,16 @@ export function WorkLogModal({
|
||||
// 1순위: 공정관리에서 매핑된 양식명으로 결정
|
||||
const templateType = resolveProcessTypeFromTemplate(workLogTemplateName);
|
||||
|
||||
// 2순위: processType 폴백 (양식 미매핑 시)
|
||||
const type = templateType || processType || order.processType;
|
||||
// 2순위: 작업지시 공정명에서 판별 (process_id가 자식 공정인 경우)
|
||||
const orderProcessType = order.processName?.includes('재공품')
|
||||
? 'template' as const
|
||||
: undefined;
|
||||
|
||||
// 3순위: processType 폴백 (양식 미매핑 시)
|
||||
const type = templateType || orderProcessType || processType || order.processType;
|
||||
|
||||
// 양식이 매핑되어 있지 않은 경우 안내
|
||||
if (!workLogTemplateId && !processType) {
|
||||
if (!workLogTemplateId && !processType && !orderProcessType) {
|
||||
return renderNoTemplate();
|
||||
}
|
||||
|
||||
@@ -256,15 +263,28 @@ export function WorkLogModal({
|
||||
lotNoMap[lot.item_code] = lot.lot_no;
|
||||
}
|
||||
}
|
||||
return <BendingWorkLogContent data={order} lotNoMap={lotNoMap} bendingImages={bendingImages} />;
|
||||
// STOCK 단일부품: 원자재 LOT 번호를 직접 전달
|
||||
const rawMaterialLotNo = materialLots.find(lot => !lot.item_code.startsWith('BD-'))?.lot_no;
|
||||
return (
|
||||
<BendingWorkLogContent
|
||||
data={order}
|
||||
lotNoMap={lotNoMap}
|
||||
bendingImages={bendingImages}
|
||||
rawMaterialLotNo={rawMaterialLotNo}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case 'template':
|
||||
// 재공품 등 템플릿 기반 작업일지 → 범용 WorkLogContent
|
||||
return <WorkLogContent data={order} />;
|
||||
default:
|
||||
return <WorkLogContent data={order} />;
|
||||
}
|
||||
};
|
||||
|
||||
// 양식명으로 문서 제목 결정
|
||||
const documentTitle = workLogTemplateName || '작업일지';
|
||||
// 양식명으로 문서 제목 결정 (작업지시 공정명 폴백)
|
||||
const documentTitle = workLogTemplateName
|
||||
|| (order?.processName ? `${order.processName} 작업일지` : '작업일지');
|
||||
|
||||
const toolbarExtra = (
|
||||
<Button onClick={handleSave} disabled={isSaving} size="sm">
|
||||
|
||||
Reference in New Issue
Block a user