- Added shipping plan routes and controller to handle aggregate and batch save operations. - Introduced a new shipping plan editor component for bulk registration of shipping plans based on selected orders. - Enhanced API client functions for fetching aggregated shipping plan data and saving plans in bulk. - Updated the registry to include the new shipping plan editor component, improving the overall shipping management workflow. These changes aim to streamline the shipping plan process, allowing for efficient management and registration of shipping plans in the application.
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { apiClient } from "./client";
|
|
|
|
export interface EnrichedOrder {
|
|
sourceId: string;
|
|
orderNo: string;
|
|
partCode: string;
|
|
partName: string;
|
|
partnerName: string;
|
|
dueDate: string;
|
|
orderQty: number;
|
|
shipQty: number;
|
|
balanceQty: number;
|
|
}
|
|
|
|
export interface ExistingPlan {
|
|
id: number;
|
|
sourceId: string;
|
|
planQty: number;
|
|
planDate: string;
|
|
shipmentPlanNo: string;
|
|
status: string;
|
|
}
|
|
|
|
export interface AggregateResponse {
|
|
[partCode: string]: {
|
|
totalBalance: number;
|
|
totalPlanQty: number;
|
|
currentStock: number;
|
|
availableStock: number;
|
|
inProductionQty: number;
|
|
existingPlans: ExistingPlan[];
|
|
orders: EnrichedOrder[];
|
|
};
|
|
}
|
|
|
|
export interface BatchSavePlan {
|
|
sourceId: string;
|
|
planQty: number;
|
|
}
|
|
|
|
// ID만 전달 → 백엔드에서 소스 테이블 자동 감지 + JOIN
|
|
export async function getShippingPlanAggregate(ids: string[]) {
|
|
const res = await apiClient.get("/shipping-plan/aggregate", {
|
|
params: { ids: ids.join(",") },
|
|
});
|
|
return res.data as {
|
|
success: boolean;
|
|
data: AggregateResponse;
|
|
source: "master" | "detail";
|
|
};
|
|
}
|
|
|
|
export async function batchSaveShippingPlans(
|
|
plans: BatchSavePlan[],
|
|
source?: string
|
|
) {
|
|
const res = await apiClient.post("/shipping-plan/batch", { plans, source });
|
|
return res.data as { success: boolean; message?: string; data?: any };
|
|
}
|