- COMPANY_7: 자재 현황(material-status) 5개 페이지 신규 추가 (item / result / sales-order / work-instruction / index) - COMPANY_7: MaterialDetailModal 신규 추가, ProcessWork 자재 상세 연동 확장 - 다중 회사(7~10, 16, 28~31) POP 공통 컴포넌트(ProductionInbound / DefectTypeModal / ProcessDetailModal / WorkOrderList) 일관화 수정 - backend: materialStatusController / popProductionController / processWorkStandardController / workInstructionController 보강 - frontend/lib/api: materialStatus, workInstruction 클라이언트 확장 - COMPANY_7 POP.md 작업 규칙·상태 갱신 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
105 lines
2.4 KiB
TypeScript
105 lines
2.4 KiB
TypeScript
/**
|
|
* 자재현황 API 클라이언트
|
|
*/
|
|
|
|
import { apiClient } from "./client";
|
|
|
|
export interface WorkOrder {
|
|
id: string;
|
|
plan_no: string;
|
|
item_code: string;
|
|
item_name: string;
|
|
plan_qty: number;
|
|
completed_qty: number;
|
|
plan_date: string;
|
|
start_date: string | null;
|
|
end_date: string | null;
|
|
status: string;
|
|
work_order_no: string | null;
|
|
company_code: string;
|
|
}
|
|
|
|
export interface MaterialLocation {
|
|
location: string;
|
|
warehouse: string;
|
|
warehouse_name?: string;
|
|
qty: number;
|
|
}
|
|
|
|
export interface MaterialBreakdown {
|
|
planNo: string;
|
|
requiredQty: number;
|
|
}
|
|
|
|
export interface MaterialData {
|
|
code: string;
|
|
name: string;
|
|
required: number;
|
|
current: number;
|
|
unit: string;
|
|
locations: MaterialLocation[];
|
|
width?: string;
|
|
height?: string;
|
|
thickness?: string;
|
|
breakdown?: MaterialBreakdown[];
|
|
}
|
|
|
|
export interface WarehouseData {
|
|
warehouse_code: string;
|
|
warehouse_name: string;
|
|
warehouse_type: string | null;
|
|
}
|
|
|
|
interface ApiResponse<T> {
|
|
success: boolean;
|
|
data?: T;
|
|
message?: string;
|
|
}
|
|
|
|
export async function getWorkOrders(params: {
|
|
dateFrom?: string;
|
|
dateTo?: string;
|
|
itemCode?: string;
|
|
itemName?: string;
|
|
}): Promise<ApiResponse<WorkOrder[]>> {
|
|
try {
|
|
const queryParams = new URLSearchParams();
|
|
if (params.dateFrom) queryParams.append("dateFrom", params.dateFrom);
|
|
if (params.dateTo) queryParams.append("dateTo", params.dateTo);
|
|
if (params.itemCode) queryParams.append("itemCode", params.itemCode);
|
|
if (params.itemName) queryParams.append("itemName", params.itemName);
|
|
|
|
const qs = queryParams.toString();
|
|
const url = `/material-status/work-orders${qs ? `?${qs}` : ""}`;
|
|
const response = await apiClient.get(url);
|
|
return response.data;
|
|
} catch (error: any) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|
|
|
|
export async function getMaterialStatus(params: {
|
|
planIds: string[];
|
|
warehouseCode?: string;
|
|
source?: "work-instruction" | "sales-order";
|
|
}): Promise<ApiResponse<MaterialData[]>> {
|
|
try {
|
|
const response = await apiClient.post(
|
|
"/material-status/materials",
|
|
params
|
|
);
|
|
return response.data;
|
|
} catch (error: any) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|
|
|
|
export async function getWarehouses(): Promise<ApiResponse<WarehouseData[]>> {
|
|
try {
|
|
const response = await apiClient.get("/material-status/warehouses");
|
|
return response.data;
|
|
} catch (error: any) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|