diff --git a/src/components/production/WorkOrders/WorkOrderCreate.tsx b/src/components/production/WorkOrders/WorkOrderCreate.tsx index 3977a0e8..cf2ef9a9 100644 --- a/src/components/production/WorkOrders/WorkOrderCreate.tsx +++ b/src/components/production/WorkOrders/WorkOrderCreate.tsx @@ -151,7 +151,7 @@ export function WorkOrderCreate() { projectName: formData.projectName, processType: formData.processType, scheduledDate: formData.shipmentDate, - assigneeId: formData.assignees.length > 0 ? parseInt(formData.assignees[0]) : undefined, + assigneeIds: formData.assignees.map(id => parseInt(id)), memo: formData.note || undefined, }); diff --git a/src/components/production/WorkOrders/WorkOrderDetail.tsx b/src/components/production/WorkOrders/WorkOrderDetail.tsx index e5e61db9..16a2160b 100644 --- a/src/components/production/WorkOrders/WorkOrderDetail.tsx +++ b/src/components/production/WorkOrders/WorkOrderDetail.tsx @@ -275,7 +275,9 @@ export function WorkOrderDetail({ orderId }: WorkOrderDetailProps) { quantity: order.items.reduce((sum, item) => sum + item.quantity, 0), progress: order.currentStep * 20, // 대략적인 진행률 process: order.processType as 'screen' | 'slat' | 'bending', - assignees: [order.assignee], + assignees: order.assignees && order.assignees.length > 0 + ? order.assignees.map(a => a.name) + : [order.assignee], instruction: order.note || '', status: 'in_progress' as const, priority: order.priority <= 3 ? 'high' : order.priority <= 6 ? 'medium' : 'low', @@ -364,7 +366,11 @@ export function WorkOrderDetail({ orderId }: WorkOrderDetailProps) {

작업자

-

{order.assignee}

+

+ {order.assignees && order.assignees.length > 0 + ? order.assignees.map(a => a.name).join(', ') + : order.assignee} +

diff --git a/src/components/production/WorkOrders/actions.ts b/src/components/production/WorkOrders/actions.ts index 96e805cb..31a5a620 100644 --- a/src/components/production/WorkOrders/actions.ts +++ b/src/components/production/WorkOrders/actions.ts @@ -220,15 +220,23 @@ export async function getWorkOrderById(id: string): Promise<{ export async function createWorkOrder( data: Partial & { salesOrderId?: number; - assigneeId?: number; + assigneeId?: number; // 단일 담당자 (하위 호환) + assigneeIds?: number[]; // 다중 담당자 teamId?: number; } ): Promise<{ success: boolean; data?: WorkOrder; error?: string }> { try { + // 다중 담당자 우선, 없으면 단일 담당자 배열로 변환 + const assigneeIds = data.assigneeIds && data.assigneeIds.length > 0 + ? data.assigneeIds + : data.assigneeId + ? [data.assigneeId] + : undefined; + const apiData = { ...transformFrontendToApi(data), sales_order_id: data.salesOrderId, - assignee_id: data.assigneeId, + assignee_ids: assigneeIds, // 배열로 전송 team_id: data.teamId, }; @@ -384,11 +392,13 @@ export async function updateWorkOrderStatus( // ===== 담당자 배정 ===== export async function assignWorkOrder( id: string, - assigneeId: number, + assigneeIds: number | number[], // 단일 또는 다중 담당자 teamId?: number ): Promise<{ success: boolean; data?: WorkOrder; error?: string }> { try { - const body: { assignee_id: number; team_id?: number } = { assignee_id: assigneeId }; + // 배열로 통일 + const ids = Array.isArray(assigneeIds) ? assigneeIds : [assigneeIds]; + const body: { assignee_ids: number[]; team_id?: number } = { assignee_ids: ids }; if (teamId) body.team_id = teamId; console.log('[WorkOrderActions] PATCH assign request:', body);